All practice tests

Module 3 practice: Claude Code and MCP, safely

15 questions · Claude Code · Tools and MCP · Security and Safety

Practice questions written by Sanjay Shah. Not exam questions, not affiliated with or endorsed by Anthropic.

  1. Question 1

    You are about to change how tenant data is migrated in a repo you've never worked in. You want Claude Code to explore the code and propose an approach without changing anything. Which permission mode fits?

    • A) acceptEdits
    • B) plan
    • C) bypassPermissions
    • D) dontAsk
    Show answer

    Answer: B

    • A: acceptEdits applies file edits without asking.
    • B: plan is read-only: Claude explores and proposes.
    • C: bypassPermissions skips all checks.
    • D: dontAsk is for unattended runs. It refuses anything not pre-allowed and changes nothing about exploring safely.
  2. Question 2

    The shared .claude/settings.json has "deny": ["Bash(git push *)"]. A developer adds "allow": ["Bash(git push *)"] to their own .claude/settings.local.json. What happens when Claude tries git push origin main?

    • A) It is allowed, because local settings have higher precedence than project settings.
    • B) Claude Code asks the developer, because the rules conflict.
    • C) It is allowed only in acceptEdits mode.
    • D) It is denied, because deny rules are checked first and a deny at any level beats an allow.
    Show answer

    Answer: D

    • A: File precedence doesn't let an allow defeat a deny rule.
    • B: There is no "ask on conflict". The deny matches first.
    • C: Permission modes don't override a deny.
    • D: Deny rules are checked first, and a deny at any level wins.
  3. Question 3

    You want a PreToolUse hook to stop Claude from reading .env files and tell Claude why. Which two hook behaviours block the call? (Choose TWO.)

    • A) Print a warning and exit with code 1.
    • B) Write the reason to stderr and exit with code 2.
    • C) Print the warning to stdout and exit with code 0.
    • D) Print JSON with hookSpecificOutput.permissionDecision set to "deny" and a permissionDecisionReason.
    • E) Sleep until the hook times out.
    Show answer

    Answer: B, D

    • A: Exit codes other than 2 are non-blocking errors, so the action goes ahead.
    • B: Exit 2 blocks the call, and stderr is fed back to Claude.
    • C: Exit 0 means success, and the plain warning is ignored.
    • D: A JSON deny decision with a reason blocks the call.
    • E: A timeout is not a block. The action goes ahead.
  4. Question 4

    A PostToolUse hook on Edit|Write runs npm test and exits 2 when tests fail. Claude edits a file and the tests fail. What happens?

    • A) The edit is rolled back automatically.
    • B) Claude Code stops the session.
    • C) The edit stays in place; the hook's stderr is fed back to Claude, which can then fix the failure.
    • D) Nothing happens, because PostToolUse hooks ignore exit codes.
    Show answer

    Answer: C

    • A: There is no automatic rollback.
    • B: The session continues.
    • C: PostToolUse runs after the tool ran, so exit 2 reports the failure back to Claude.
    • D: The exit code matters. Exit 2 is the feedback channel.
  5. Question 5

    You want every developer who clones the repo to get the same tenant-SQL hook and the same deny rules. Where do they go?

    • A) ~/.claude/settings.json on your machine
    • B) .claude/settings.json in the repo, committed
    • C) .claude/settings.local.json in the repo
    • D) CLAUDE.md
    Show answer

    Answer: B

    • A: User settings apply only to you.
    • B: The shared project settings file is committed with the code.
    • C: settings.local.json is personal and kept out of Git.
    • D: CLAUDE.md can't define hooks or deny rules.
  6. Question 6

    Your CLAUDE.md is 300 lines of style advice, history and rules. Claude Code sometimes ignores the rule "every query on tickets filters by tenant_id". Which two changes are best? (Choose TWO.)

    • A) Trim CLAUDE.md to commands, a folder map and hard rules, and move material that's only needed sometimes into skills or path-scoped rules.
    • B) Move the 300 lines into docs/notes.md and pull them back in with an @docs/notes.md import, so they no longer use context.
    • C) Back the tenant rule with a PreToolUse hook or a deny rule, so it is enforced rather than just requested.
    • D) Repeat the tenant rule in five places in the file.
    • E) Write the tenant rule in capital letters at the top.
    Show answer

    Answer: A, C

    • A: A short file keeps hard rules visible and costs fewer tokens on every request.
    • B: Imports load eagerly, so the same 300 lines still go into context.
    • C: A rule that must never break needs enforcement, not just guidance.
    • D: Repetition adds noise and enforces nothing.
    • E: Capitals don't turn guidance into enforcement.
  7. Question 7

    An MCP server exposes this tool:

    server.registerTool("get_ticket",
      { description: "Get a ticket", inputSchema: z.object({ tenant: z.string(), id: z.string() }) },
      async ({ tenant, id }) => ({ content: [{ type: "text", text: JSON.stringify(await db.ticket(tenant, id)) }] }));

    What is the most important problem?

    • A) The model chooses tenant, so a prompt or ticket can request another tenant's data; the tenant should be fixed in the server's configuration.
    • B) The description should be longer.
    • C) JSON.stringify output can't be returned as text content.
    • D) id should be a number.
    Show answer

    Answer: A

    • A: Any tool argument is chosen by the model, so the tenant must come from server config.
    • B: A longer description would help, but it is minor next to a cross-tenant leak.
    • C: Returning JSON as text content is fine.
    • D: The type of id is a detail.
  8. Question 8

    Your stdio MCP server prints console.log("helpdesk server started") at startup. Claude Code shows connection or parse errors for the server. Why?

    • A) stdio servers must print a startup banner to stderr *and* stdout.
    • B) MCP doesn't support Node.js.
    • C) In the stdio transport, stdout carries only protocol messages; the log line corrupts the stream. Log to stderr instead.
    • D) The server needs --transport http to log.
    Show answer

    Answer: C

    • A: Writing a banner to stdout is exactly the bug.
    • B: MCP has official SDKs for TypeScript, Python and more.
    • C: stdout is the protocol channel in stdio, so log to stderr.
    • D: Changing transport isn't needed.
  9. Question 9

    Which three capabilities can an MCP server offer?

    • A) Hooks, skills and plugins
    • B) Tools, resources and prompts
    • C) Models, embeddings and fine-tunes
    • D) Tokens, contexts and windows
    Show answer

    Answer: B

    • A: Hooks, skills and plugins are Claude Code features.
    • B: MCP servers offer tools, resources and prompts.
    • C: These aren't MCP concepts.
    • D: These aren't MCP concepts.
  10. Question 10

    You want everyone on the repo to have the helpdesk MCP server, configured the same way. Which scope fits, and what should teammates expect?

    • A) local; it's stored in each user's own config.
    • B) user; it applies to all of their projects.
    • C) Any scope; Claude Code shares all servers automatically.
    • D) project; it's stored in .mcp.json at the repo root, and Claude Code asks each user to approve it before use.
    Show answer

    Answer: D

    • A: local scope is personal.
    • B: user scope is personal, across your projects.
    • C: Servers aren't shared automatically.
    • D: .mcp.json travels with the repo, and each user approves it before use.
  11. Question 11

    A "tenant-auditor" subagent edited two files during a review. Its frontmatter has name and description but no tools line. What is the most likely reason?

    • A) Without a tools line, a subagent inherits all available tools, including edit tools.
    • B) Subagents always have edit rights.
    • C) The description gave it permission to edit.
    • D) Subagents ignore the main session's permission mode.
    Show answer

    Answer: A

    • A: Leave out tools and the subagent inherits everything, so list only read tools for an auditor.
    • B: A tools list can restrict it.
    • C: The description says when to use the subagent. It grants nothing.
    • D: The issue is its tool set, not the permission mode.
  12. Question 12

    You want one PreToolUse hook to run for every tool of the MCP server named helpdesk. Which matcher is right?

    • A) helpdesk
    • B) mcp
    • C) mcp__helpdesk__.*
    • D) Bash|Read
    Show answer

    Answer: C

    • A: This would only match a tool literally named helpdesk.
    • B: No tool is literally named mcp.
    • C: MCP tools are named mcp__<server>__<tool>, and this regex matches all of them.
    • D: This matches built-in tools, not MCP tools.
  13. Question 13

    During a session, Claude Code ran a database migration through Bash and edited three files. You use /rewind to go back to before the change. What is restored?

    • A) Both the files and the database.
    • B) The file edits Claude made with its own edit tools, but not the database changes from the shell command.
    • C) Only the database.
    • D) Nothing, because /rewind only works in plan mode.
    Show answer

    Answer: B

    • A: The database is outside what checkpoints track.
    • B: Checkpoints cover edits made by Claude's file tools, not shell side effects.
    • C: Database changes aren't tracked.
    • D: /rewind works outside plan mode.
  14. Question 14

    You're building an MCP server for your company CRM, used by an agent working on one tenant's tickets. Which two credential properties are best? (Choose TWO.)

    • A) One long-lived admin API key shared by all tenants, stored in .mcp.json.
    • B) Scoped to one tenant and read-only.
    • C) The developer's own personal login, so actions are traceable.
    • D) Short-lived, issued to the server, with every call logged.
    • E) No credential; let the model ask the user for a password when needed.
    Show answer

    Answer: B, D

    • A: A shared admin key is broad, long-lived and committed to a file: the worst case.
    • B: Least privilege: the narrowest scope that does the job.
    • C: Personal credentials give the agent everything that person can do.
    • D: Short-lived tokens limit how long a leak is useful, and logs make calls traceable.
    • E: The model should never collect passwords.
  15. Question 15

    You want Claude Code to run a scripted check in CI: non-interactive, limited to certain tools, and with a cap on the number of turns. Which command shape fits?

    • A) claude -p "<task>" --allowedTools "Read,Grep" --max-turns 5 --output-format json
    • B) claude --permission-mode bypassPermissions with the task typed in by a bot
    • C) claude mcp add ci -- <task>
    • D) /init followed by the task
    Show answer

    Answer: A

    • A: -p runs the task non-interactively, and the flags limit tools, turns and output format.
    • B: Bypassing permissions in CI removes your gates.
    • C: claude mcp add registers servers. It doesn't run tasks.
    • D: /init drafts a CLAUDE.md.

↑ ↓ navigate · ↵ select · esc close