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.
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:
acceptEditsapplies file edits without asking. - B:
planis read-only: Claude explores and proposes. - C:
bypassPermissionsskips all checks. - D:
dontAskis for unattended runs. It refuses anything not pre-allowed and changes nothing about exploring safely.
- A)
Question 2
The shared
.claude/settings.jsonhas"deny": ["Bash(git push *)"]. A developer adds"allow": ["Bash(git push *)"]to their own.claude/settings.local.json. What happens when Claude triesgit 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
acceptEditsmode. - 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.
Question 3
You want a
PreToolUsehook to stop Claude from reading.envfiles 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.permissionDecisionset to"deny"and apermissionDecisionReason. - 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
denydecision with a reason blocks the call. - E: A timeout is not a block. The action goes ahead.
Question 4
A
PostToolUsehook onEdit|Writerunsnpm testand 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.
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.jsonon your machine - B)
.claude/settings.jsonin the repo, committed - C)
.claude/settings.local.jsonin 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.jsonis personal and kept out of Git. - D:
CLAUDE.mdcan't define hooks or deny rules.
- A)
Question 6
Your
CLAUDE.mdis 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.mdto 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.mdand pull them back in with an@docs/notes.mdimport, so they no longer use context. - C) Back the tenant rule with a
PreToolUsehook 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.
- A) Trim
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.stringifyoutput can't be returned as text content. - D)
idshould 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
idis a detail.
- A) The model chooses
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 httpto 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.
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.
Question 10
You want everyone on the repo to have the
helpdeskMCP 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.jsonat the repo root, and Claude Code asks each user to approve it before use.
Show answer
Answer: D
- A:
localscope is personal. - B:
userscope is personal, across your projects. - C: Servers aren't shared automatically.
- D:
.mcp.jsontravels with the repo, and each user approves it before use.
- A)
Question 11
A "tenant-auditor" subagent edited two files during a review. Its frontmatter has
nameanddescriptionbut notoolsline. What is the most likely reason?- A) Without a
toolsline, a subagent inherits all available tools, including edit tools. - B) Subagents always have edit rights.
- C) The
descriptiongave it permission to edit. - D) Subagents ignore the main session's permission mode.
Show answer
Answer: A
- A: Leave out
toolsand the subagent inherits everything, so list only read tools for an auditor. - B: A
toolslist 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.
- A) Without a
Question 12
You want one
PreToolUsehook to run for every tool of the MCP server namedhelpdesk. 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.
- A)
Question 13
During a session, Claude Code ran a database migration through Bash and edited three files. You use
/rewindto 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
/rewindonly works inplanmode.
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:
/rewindworks outside plan mode.
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.
- A) One long-lived admin API key shared by all tenants, stored in
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 bypassPermissionswith the task typed in by a bot - C)
claude mcp add ci -- <task> - D)
/initfollowed by the task
Show answer
Answer: A
- A:
-pruns the task non-interactively, and the flags limit tools, turns and output format. - B: Bypassing permissions in CI removes your gates.
- C:
claude mcp addregisters servers. It doesn't run tasks. - D:
/initdrafts aCLAUDE.md.
- A)