Claude Certified Architect · Foundations
Module 4: Tool design and MCP
Study notes written by Sanjay Shah. Not official Anthropic material. Facts marked "check before relying on it" may have changed.
On this page
Course: Claude Architect (Foundations): Design production systems with Claude · Study notes, our own words · Facts checked 2026-11-25
Exam domain: Tool Design & MCP Integration, 18% (official exam guide v1.1, November 2026)
Take first: Introduction to Model Context Protocol (opens in a new tab) (free, Anthropic Academy). It covers what MCP is and how to build a basic server. These notes are about designing tools an agent picks correctly and uses safely, and about where an MCP server fits in the architecture.
Video: Module 4 long video, "Design Tools Claude Picks Correctly, Then Serve Them with MCP" (planned). Diagrams D4.1 to D4.4 match the video.
What you'll be able to do
Write tool names and descriptions that make the right choice obvious, including when not to use a tool.
Size tools around what a user wants done, not around API endpoints.
Design compact results and a structured error contract that keeps failures visible.
Guard tools with side effects: separate reads from writes, use idempotency keys, gate risky actions.
Treat tool results as untrusted input.
Place an MCP server in an architecture: primitives, transport, scope, identity and trust.
Key ideas
1. The tool description is a prompt
Claude doesn't read your tool's code. When it decides which tool to call, and with what input, it has the tool's name, description and input schema, and nothing else. So writing a tool definition is prompt design. Anthropic's tool-use docs make the same point: detailed descriptions are among the biggest factors in how well tools get used.
A good tool definition answers six questions. We call it the tool card:
| Row | What it says | Example for search_tickets |
|---|---|---|
| Name | Verb + object, unique | search_tickets |
| Does | One sentence | "Searches support tickets for the current tenant by text, status and date." |
| Use when | The situations it is for | "Use to find existing tickets about a problem, or a customer's recent tickets." |
| Don't use when | The nearest other tool, by name | "Don't use to read one ticket's full history; use get_ticket with the ticket ID." |
| Inputs | Types, formats, one example | "query (text), status (open, pending, closed), since (ISO date, e.g. 2026-11-01)." |
| Returns | Fields, and IDs for follow-up calls | "Up to 10 tickets: ticket_id, subject, status, updated_at; total_matches." |
Plus a seventh row for errors (section 5).
The "don't use when" row matters most when two tools look alike. If get_customer and lookup_account both seem to "find a customer", Claude has to guess. One sentence in each description, naming the other tool and saying when to use it, removes the guess.
D4.1 Tool card.
2. Tools for intents, not endpoints
The quickest way to build tools is to wrap every API endpoint: GET /customers, GET /customers/{id}, GET /accounts/{id}, GET /invoices?customer=…, and so on. Twelve endpoints become twelve tools. It's also the quickest way to get an agent that picks wrong, chains six calls for a simple question, and floods its context with raw API responses.
Instead, design one tool per thing a user actually wants:
find_customer(name_or_email)instead of three search endpoints;get_account_summary(customer_id), which calls the account, plan and balance endpoints in code and returns the ten fields that matter;search_tickets(query, status, since);create_ticket(customer_id, subject, body, idempotency_key).
The endpoints still exist. Your tool code calls them. The model sees four clear choices instead of twelve overlapping ones.
D4.2 Endpoint mirror vs intent tools. One tool per thing a user wants.
Don't overshoot the other way, though. A single call_api(endpoint, params) tool is the worst of both: the model has to know your whole API, the description can't say when to use it, and your safety checks can't tell a read from a delete.
Fewer tools per agent. Even with good tools, a long list hurts choice. Give each agent, or each subagent (Module 1), only the tools its job needs. A billing investigator doesn't need create_ticket.
3. Inputs: make the right call easy and the wrong call impossible
Use types and enums.
statusas an enum of the real values, dates as ISO strings with an example. The schema is part of the prompt.Keep inputs few and obvious. If a parameter has a sensible default, apply it in code.
Never let the model supply identity or authority. No
tenant_id,user_idorroleinputs that the model fills in. Your tool code takes them from the authenticated session or the caller's token (section 8). A model that can type a user ID can type the wrong one, or be talked into it.Validate inputs in the tool, and return a clear "bad input" error that says what was wrong (section 5).
4. Results: compact, useful, with IDs for the next step
Everything a tool returns goes into the context window and is paid for on every later turn of the loop. Design results like a good API response for a busy reader:
Only the fields the task needs. A 3 KB customer record becomes 10 fields.
IDs for follow-up calls. If the next sensible step is
get_ticket(ticket_id), returnticket_id.Limits and paging. Return the top N with
total_matchesand a way to get more, and say so: "showing 10 of 240; narrow the query or ask for the next page".References instead of blobs. A payslip PDF or a 5 MB log file doesn't go into the context. Return a link or a file ID, or a short extract.
Readable values. Dates and amounts in readable form (with the raw value too, if code needs it).
Trimming at the tool is far better than trimming later. Once a huge result is in the context, the cost is already paid (Module 5).
5. The error contract: failures must be visible
The most damaging tool bug isn't a crash. It's a failure that looks like success: a timeout returned as [], so the agent concludes "no tickets exist" and tells the customer so.
Every tool should return one of two shapes:
Success: the data, plus IDs for next steps.
Error: marked as an error, with a category, whether it's retryable, and a short message the model can act on.
Useful categories:
| Category | Example | What the agent should do |
|---|---|---|
| Bad input | Date in the wrong format | Fix the input and call again |
| Not found | No customer with that email | Try another way (a different search), or ask the user |
| No permission | Not allowed for this user | Stop and tell the user; don't look for a workaround |
| Temporary | Timeout, rate limit, backend down | Retry later with backoff, or report the gap |
| Conflict | Ticket already closed | Re-read the current state, then decide |
In the Claude API, a tool result you send back can be marked with is_error: true. In MCP, a tool's result can carry isError: true for errors in running the tool. That's different from a protocol-level (JSON-RPC) error, which means the request itself failed (checked 2026-11-25). Put the category and the retryable flag in the error content so the model can read them.
D4.3 Error contract.
6. Tools with side effects
Reading is cheap to get wrong. Writing isn't. Design write tools differently:
Separate read tools from write tools.
get_ticketandupdate_ticket, never oneticket(action, ...). Then you can give an agent read tools only, and your gate can see exactly which action is requested.Idempotency keys. A write tool takes an
idempotency_key. If the agent retries after a timeout, the backend sees the same key and doesn't create a second ticket or a second refund.Echo before committing for actions a user will care about: the tool returns "This will create an HR request: type X, dates Y. Confirm?" and a second call (or a human click) commits.
Gates in code for risky writes. Money, deletion, messages to customers, anything irreversible: the tool checks the rule and either does it or creates an approval task (Module 1).
7. Tool results are untrusted input
Anything a tool returns came from outside the model: an email body, a web page, a ticket written by a customer, a document uploaded by a supplier. Any of it can contain text like "ignore your instructions and…". This is prompt injection, and tool results are its main way in.
You can't fully prevent it with prompt wording. Design so that it can't do much damage:
Least privilege: an agent that reads untrusted content has no dangerous tools, or its dangerous tools are gated.
Identity from code: an injected instruction can't change whose data is read, because the model never chose the user or tenant (section 3).
Humans before irreversible actions, so a manipulated proposal gets seen.
Mark data as data (tags, clear labels in the tool result). It helps, but it isn't a boundary.
8. MCP: where it fits
The Model Context Protocol is an open standard for connecting AI applications to tools and data. You write a server once; any MCP-capable client (Claude Code, the Claude apps, your own agent) can use it.
What a server can offer (checked 2026-11-25 against the spec):
Tools: actions the model can call. These are model-controlled: Claude decides when to call them.
Resources: data the application can read and give to the model, such as documents, schemas and files.
Prompts: reusable templates, typically chosen by a user (for example as a slash command).
Rules of thumb: something the model does is a tool. Read-only reference material that the app or user picks is a resource. A fill-in-the-blanks workflow is a prompt. Check before relying on it: the spec also defines features that clients offer to servers (for example, asking the user a question through the client). The latest spec overview we checked lists elicitation; we didn't confirm where sampling and roots now sit.
Transports (checked 2026-11-25): stdio, where the client starts the server as a local process (good for local, single-user tools); and Streamable HTTP, a server reached over the network (good for shared, remote or multi-user tools). The older HTTP+SSE transport is kept only for backward compatibility. The latest spec version is 2026-07-28, which made requests stateless; older versions still work through a compatibility section.
Authorization for HTTP servers is based on OAuth 2.1. The MCP server acts as an OAuth resource server, and it must not pass the client's token on to upstream APIs ("token passthrough" is forbidden). Instead, the server uses its own credentials for the backends, scoped to what it needs. (Checked against the 2025-11-25 spec's authorization page; check the 2026-07-28 version before relying on details.)
Using it from Claude Code: add a server at local, project (.mcp.json, committed) or user scope, with secrets as ${VAR} (Module 2). From your own app on the Claude API: the MCP connector lets the API connect to a remote MCP server for you. It was in beta on 2026-11-25 and isn't listed for every cloud platform, so check availability. From the Agent SDK: MCP servers are configured as part of the agent.
Trust. A third-party MCP server runs code and returns text into your agent's context. Tool annotations that describe behaviour (such as "read-only" or "destructive") are hints, and the spec says to treat them as untrusted unless the server is trusted. Review servers like any dependency: who publishes it, what it can reach, which version you pinned.
D4.4 MCP topology. In Claude Code, the server is in .mcp.json with ${TOKEN} from the environment.
MCP or plain tools? If one application uses the tools and they're tightly tied to its code, defining tools directly in that app is simpler. Use an MCP server when several clients need the same tools, when another team owns the backend, or when you want the tools versioned and deployed on their own.
Worked example: an internal ops assistant
The system: an internal ops assistant for a multi-tenant SaaS platform I build (made generic). Support and operations staff use it across ticketing, a knowledge base and customer accounts, from Claude Code, from the desktop app and from a custom triage agent.
v1 wrapped the REST API: 12 tools, named after endpoints. Problems: get_customer vs lookup_account confusion; six calls to answer "what plan is this customer on and do they have open tickets?"; a ticketing timeout returned as an empty list, so the agent told a customer "you have no open tickets"; a retry after a timeout created a duplicate ticket.
v2 design:
Four intent tools, each with a full tool card:
find_customer,get_account_summary,search_tickets,create_ticket. Each "don't use when" names the nearest other tool.Compact results:
get_account_summaryreturns ten fields instead of three raw records;search_ticketsreturns the top 10 plustotal_matches.Error contract: every tool returns success or a categorized error with
retryable. The ticketing timeout now arrives astemporary, retryable, and the agent says "I couldn't check tickets just now" instead of "you have none".Side effects:
create_tickettakes anidempotency_key, so retries are safe. It's the only write tool, and the triage agent's read-only subagents don't get it.Resources and prompts: the escalation policy and the SLA table are MCP resources; "draft an incident update" is an MCP prompt.
Transport and scope: one Streamable HTTP server for everyone. Claude Code users add it at project scope with
${OPS_TOKEN}.Identity: each client authenticates as the person using it. The server derives the user and their allowed tenants from the token. No tool takes a
tenant_idfrom the model. The server calls the backends with its own narrowly scoped, short-lived service credentials, never with the user's token passed through.
The identity design is where an identity background pays off: the model can't name a tenant, so it can't leak one.
Your turn: design exercise
HR helpdesk assistant. Employees ask about leave balances and policies, request copies of payslips, and raise HR requests. HR staff use the same assistant with wider access.
Design: the tool list (names and one-line descriptions including "don't use when"); which items are MCP resources rather than tools; the error contract; side-effect guards; and how identity and permission flow from the employee to the backend. The model answer walkthrough is in the locked lesson on the site.
Design decisions and trade-offs
| Decision | Option A | Option B | How to choose |
|---|---|---|---|
| Tool granularity | One tool per endpoint | One tool per user intent | Intents. Endpoints stay behind the tool, in code. Avoid the opposite extreme of one generic tool. |
| How many tools per agent | All tools everywhere | A subset per agent or subagent | The smallest set that does the job: better choices, smaller blast radius. |
| Identity | Model passes user or tenant ID | Server derives it from the caller's token | Always the token. |
| Result size | Full records | Selected fields + IDs + paging | Selected fields. Trim at the tool, not after. |
| Failure signal | Empty result or a vague message | Error flag + category + retryable | Structured errors, always. An empty success after a failure is a bug. |
| Read and write | One tool with an action parameter | Separate read and write tools | Separate, so you can grant and gate them separately. |
| Retrying writes | Hope it didn't go through | Idempotency key | Keys on every write tool. |
| Tool or resource | Tool that returns a document | Resource the app attaches | Model-initiated action → tool. Reference material picked by app or user → resource. |
| Transport | stdio (local process) | Streamable HTTP (remote, shared) | stdio for local single-user tools; HTTP for shared servers with real auth. |
| MCP or in-app tools | MCP server | Tools defined in the app | MCP when several clients or teams share the tools; in-app when one app owns them. |
| Backend credentials | Pass the user's token through | Server's own scoped, short-lived credentials | No passthrough; the spec forbids it. |
Anti-patterns
Look-alike tools.
get_customerandlookup_accountwith no "don't use when".The endpoint mirror. Every API endpoint as a tool.
The god tool.
call_api(endpoint, params)orhr_api(action, ...).Model-chosen identity.
employee_id,tenant_idorroleas model inputs.Raw dumps. Whole records, whole files or PDFs returned into the context.
Silent failure.
[]or "no results" when the call actually failed.Vague errors. "Something went wrong", with no category and no retryable flag.
Retry-unsafe writes. No idempotency key, so a timeout plus a retry creates two of something.
One tool for read and write. You can't grant read-only, and the gate can't see the intent.
Trusting tool output as instructions. Text from emails, tickets or web pages acted on as if the user wrote it.
Token passthrough. The MCP server forwarding the user's token to backend APIs.
Secrets in config files. Tokens in
.mcp.jsoninstead of${VAR}.Unreviewed third-party servers. Installed because they were "on a list", trusted because their annotations say "read-only".
Remember
The tool card is the prompt for choosing: name, does, use when, don't use when, inputs, returns, errors.
One tool per user intent, not per endpoint. Each agent gets the fewest tools.
Results are compact, with IDs for the next call and paging.
Errors carry a category and retryable. Never return empty success on failure.
Separate read and write tools. Writes take an idempotency key. Risky writes pass a gate.
Tool output is untrusted. Identity comes from the token, never the model.
MCP: tools (model-controlled), resources, prompts; stdio local, Streamable HTTP shared; OAuth 2.1, no token passthrough; secrets via
${VAR}.
Facts in this module, and where to check them
| Fact | Checked | Source |
|---|---|---|
Tool definitions (name, description, input schema); is_error on tool results | 2026-11-25 | Define tools (opens in a new tab); Handle tool calls (opens in a new tab) |
| MCP latest version 2026-07-28 (stateless requests); server features tools, resources, prompts; tools are model-controlled | 2026-11-25 | MCP spec (opens in a new tab); versioning (opens in a new tab) |
| Transports: stdio and Streamable HTTP; HTTP+SSE kept for backward compatibility | 2026-11-25 | MCP spec, transports |
| OAuth 2.1, server as resource server, no token passthrough | 2026-11-25 (2025-11-25 spec) | Authorization (2025-11-25) (opens in a new tab) |
MCP tool results: isError vs JSON-RPC errors; outputSchema / structuredContent; annotations untrusted unless the server is trusted | 2026-11-25 (2025-11-25 spec) | Tools (2025-11-25) (opens in a new tab) |
| Claude API MCP connector: beta; not listed on every platform | 2026-11-25 | MCP connector (opens in a new tab) |
Claude Code MCP scopes and ${VAR} in .mcp.json | 2026-11-25 | Claude Code MCP (opens in a new tab) |
Check before relying on it:
Who controls resources and prompts (application vs user) in the latest spec; and where the client features sampling and roots now sit (the latest overview we read listed elicitation).
The authorization rules in the 2026-07-28 spec (we read the 2025-11-25 version).
The exact tool annotation names (read-only, destructive, idempotent, open-world hints).
Practice: 15 questions for this module.