Summary

MCP made it cheap to expose a function to an agent. It also made it cheap to expose the wrong one. One ledger_admin(action, payload) tool hides twelve actions behind a free-form object; the same work fits in five named tools with typed inputs and stable error codes. Good MCP tools do one thing, name their units, fail with codes the model can act on, keep output small, and check authorization on the server. This post walks through the rules I use and the failures they prevent. The example is a design sketch, not a benchmark, and the last section says what it does not prove.

A tool is an API for a caller that is confident, fast, and sometimes wrong.

I rebuilt the tool list for a small ledger server twice in one week. The first version wrapped twelve actions in one ledger_admin(action, payload) tool. It took an afternoon and looked tidy. The second split the work into five named tools. It took longer, and it is the one I would ship.

The difference was not the protocol. It was the shape of the contract.

MCP standardizes how an agent discovers and calls tools. A server author can expose a function in a few lines. That convenience is useful, and easy to misread.

The agent sees a list of names and descriptions and picks one. It does not read my source, my incident history, or my on-call runbook. It may call the tool thirty times in one session. It may retry after a timeout. It may pass a plausible but wrong value because the schema allowed it.

The failure is rarely in the protocol. It is in the tool.

A tool that returns four megabytes of JSON fills the context and crowds out the task. A tool with an action field and a free-form payload makes the model guess at structure. A tool that fails with a stack trace teaches the model nothing, so it retries the same call. A tool that trusts a tenantId argument turns a model mistake into a cross-tenant write.

What I built

The running example is the ledger server from that week. It has to read one invoice, list invoices, create a refund request, approve it, and send it.

The first version wraps all of that in one admin tool. The second exposes five tools. Both are sketches, not a library, but the difference in shape is the point.

The god tool was the easy one to write. That is part of why it is dangerous.

A tool is an API for an unreliable caller

A normal API caller is a service. It has credentials, docs, tests, and a stable request in mind. An agent caller is a language model with a context window, no memory of yesterday's incident, and a habit of retrying.

That changes the requirements.

  • The schema must carry constraints, because the caller may skim the description.

  • The error must teach the next attempt.

  • The output must be small enough to keep in context.

  • Writes must tolerate a retry.

  • Authorization must not depend on a model-supplied id.

None of this is specific to MCP. It is API design for a caller that is confident, fast, and sometimes wrong.

Write the schema for a caller that skims. Start with the one tool your agent calls most.

The god tool that looks efficient

The fastest way to make a bad MCP tool is to wrap an admin API.

ledger_admin(action, payload) 

This tool has an enum of twelve actions and a payload typed as an object. The schema cannot validate much. The description turns into a manual. The server has to switch on the action before it can check permissions. The audit log says someone called ledger_admin, which tells an investigator nothing.

One ledger\_admin tool holding twelve action chips next to five named tools with typed signatures

Compare a small set.

get_invoice list_invoices create_refund_request approve_refund send_refund 

Each name says the verb and the resource. Each one can have its own schema, its own policy, and its own error codes. If an action needs a different approval rule, it can have one.

The rule is blunt. If the description needs the phrase "depending on the action," you have more than one tool. Split it.

Naming matters because the model picks by name. Use verb_resource. Use singular for one item and a list_ prefix for a collection. Avoid fetch_data, handle, process, or run. A vague name makes the model choose by description, which is a weaker signal.

A small server sketch:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; const server = new McpServer({ name: "ledger", version: "1.0.0" }); server.registerTool( "get_invoice", { title: "Get one invoice", description: "Return one invoice by id. Read only. Amounts are minor units. Use list_invoices to search.", inputSchema: { invoiceId: z.string().uuid() }, annotations: { readOnlyHint: true }, }, async ({ invoiceId }) => { const invoice = await ledger.getInvoice(invoiceId); if (!invoice) { return { isError: true, content: [ { type: "text", text: "INVOICE_NOT_FOUND: no invoice with that id." }, ], }; } return { content: [{ type: "text", text: JSON.stringify(invoice) }] }; }, ); await server.connect(new StdioServerTransport()); 

Check the SDK version you use. The registration shape has changed across releases. The design points survive the changes.

Count the actions in your biggest tool. If its description says "depending on the action," split it.

Schemas, units, and loud failures

The schema is the part of the contract a model can follow without reading prose.

For inputs:

  • Use a typed string with a format for ids, not any.

  • Use amountMinor as an integer and a separate currency code. Never send money as a float.

  • Use RFC 3339 timestamps with a timezone.

  • Use enums for states instead of free text.

  • Bound arrays and strings. A tool that accepts 10,000 ids in one call will eventually get 10,000 ids.

  • Prefer separate fields over a filters object with unknown shape.

For outputs:

  • Return one small object, not the raw upstream response.

  • Paginate collections with a small default and a hard maximum. A default of 20 and a maximum of 50 is fine for most tools.

  • Leave out secrets, internal hostnames, raw stack traces, and unrelated customer records.

  • If your SDK and client support structured tool output, use it. Otherwise return one compact JSON document in a text block.

For failures, use the protocol's error result and a stable code.

{ "code": "AMOUNT_EXCEEDS_LIMIT", "message": "Refund amount 250000 is above the limit 100000.", "limitMinor": 100000, "hint": "Create an approval request, then call send_refund with its id." } 

The model can act on AMOUNT_EXCEEDS_LIMIT. It cannot act on "Internal Server Error." A code should identify the class of failure. The message should include the numbers needed to correct the call. The hint should name the next tool or the missing approval, not a paragraph of policy.

Keep terminal and retryable failures distinct. A missing invoice will not appear on retry. A rate limit will clear. If the result does not say which one happened, the model retries both.

Do not leak internals in the error. A stack trace in a tool result is both noise and an information leak.

Pick one money tool and move its amount to amountMinor plus currency. Do it before the next float reaches production.

Reads are broad, writes are narrow

MCP tool annotations include hints such as readOnlyHint, destructiveHint, idempotentHint, and openWorldHint. Clients can use them to warn a user or ask for approval. Treat them as labels, not enforcement.

Read tools can be broad. They should still be bounded and cheap. A read tool that scans a table without a limit is a denial-of-service tool with a nice name.

Write tools should be few and narrow. Two rules make them safe to retry.

First, accept an idempotency key, or derive one from an approval record. An agent that times out on a refund will retry. Without a key, the customer gets two refunds. With a key, the second call returns the first result.

Second, split irreversible actions into preview and confirm. Preview validates the action and returns a digest. Confirm accepts only the digest. Bind the digest to the exact arguments, give it a short expiry, and consume it once.

preview_refund(paymentId, amount) -> { digest, summary } send_refund(digest) -> { refundId, status } 

This also gives a human something concrete to approve. A digest cannot be edited by injected text between preview and send.

Preview returns a digest bound to the refund arguments, a human approves it, and send\_refund accepts only the digest

Avoid batch write tools unless the domain needs them. A tool that accepts an array of refunds needs a policy for partial failure, ordering, and atomicity. Most agents can loop over single calls and report each result.

Find one write tool without an idempotency key. Add the key before the next retry arrives.

Descriptions are part of the contract

The model chooses tools by name and description. A weak description causes wrong tool selection even when every schema is correct.

Weak:

Gets invoice. 

Strong:

Return one invoice by id. Read only. Amounts are minor units. Does not list invoices; use list_invoices. Fails with INVOICE_NOT_FOUND. 

State what the tool does, what it does not do, the units, the side effects, the limits, and the alternative tool. That is enough. Marketing language wastes context and makes the tool sound less precise.

Descriptions are claims by the server. A third-party server can describe a read tool that writes, or a narrow tool that proxies a shell. The client trusts the server code, not the description. Install servers you trust, and do not let an agent install a new one without review.

Rewrite one description with four things: what it does, what it does not do, the units, and the tool to use instead.

Authorization belongs in the server

MCP transport authentication identifies a session. For HTTP transports, that may be an OAuth token. Transport authentication does not answer whether this call may touch invoice 4412 for tenant 12.

Never accept tenantId or userId as ordinary tool arguments and trust them. If the model supplies the tenant, injected text can supply the tenant. Derive the principal from the authenticated session, then check the resource against it.

If your transport cannot carry a principal, run one server instance per tenant or keep a server-side mapping from session to principal. Do not push the mapping into the model.

Scope credentials per server. A read-only server and a write server should not share a token. If the agent only needs to read invoices, do not give that server a payment key. A compromise or a bad prompt then has less to reach.

Log every call with the authenticated principal, tool name, redacted arguments, and result code. Return a correlation id in the error payload so support can find the call. Keep it short.

Tool annotations do not enforce any of this. A readOnlyHint on a writing tool changes client behavior and nothing else. The server is the authority.

Check where your server reads tenantId. If it comes from the arguments, move it to the session.

Results: twelve actions against five tools

The sample is the ledger server above, with five operations. Here is what each design asks of the server and the caller.

Property

ledger_admin

Five named tools

Tools to choose from

1

5

Actions per schema

12, behind an enum

1 per tool

Input typing

Free-form payload

Typed fields per tool

Validation before the handler

Little

Per action

Permission check

Switch on action

Per tool

Audit log entry

ledger_admin

send_refund, get_invoice

Error codes

Generic

Stable per tool

Retry safety

Depends on the action

Idempotency key or digest

The numbers describe the two sketches. They are design accounting, not a measurement of your server. Run the same count on yours: tools, actions per tool, typed fields, stable error codes, and one retry test per write.

What this does not prove

This post has no benchmark. I did not measure token use, latency, or model accuracy for the two designs, so I cannot claim the five-tool version saves a fixed percentage of context. The claim is narrower: a typed, named, bounded tool is easier for a model to call correctly and easier for a person to audit.

Splitting a god tool can also backfire. Five tools with near-identical names force the model to choose by description, which is the weaker signal I warned about earlier. If two tools are hard to tell apart, merge them or rename them. The count is not the goal.

The rules also cost code. Stable error codes, idempotency keys, and preview digests add handlers, storage, and tests. For an internal read-only tool with no side effects, most of this is unnecessary.

The part people miss is that annotations are advisory. A server can mark a write as read-only and nothing in the protocol stops it. Do not treat a client's approval prompt as a security control.

If your split creates two tools the model cannot tell apart, merge them and fix the description instead of adding a sixth.

Try it

  1. List every tool your server exposes. Count the actions hidden inside each one.

  2. Split any tool whose description needs "depending on the action."

  3. Give every money tool amountMinor and currency.

  4. Add a stable error code and one corrective number to each failure path.

  5. Add an idempotency key to every write, and a preview digest to every irreversible one.

  6. Move tenantId and userId out of the arguments and into the session.

  7. Run a loop test: ask a model to find the tool, fill it, recover from one error, and stop when done. A unit test does not cover that path.

Start with step 1 and report the count. If one tool hides more than three actions, that is your first split.

I build payment and agent infrastructure at work; the ledger here is a sketch, not a customer system.

Which tool in your server would you split first, and what stable error codes would it return?

References

Get new posts in your inbox
Subscribe