A tool is an interface between a probabilistic caller and a deterministic system. The model chooses tools from names and descriptions, fills arguments from schemas, and interprets results. Most tool failures are interface failures, not model failures.
Pattern: one outcome per tool
Prefer a tool that completes a recognizable task:
get_pull_request_diffcreate_issue_draftlist_open_alerts
A tool that mirrors an entire upstream API (api_request) forces the model to learn a second API. It also gives your server the union of all permissions. Narrow tools make approval, logging, and testing tractable.
Exception: a generic query tool can be appropriate for a database when paired with a read-only role, a query allow-list, row limits, and a clearly documented SQL dialect. The constraints are the tool design.
Pattern: separate reads from writes
Read and write tools should be distinct even when they share a resource. A read tool can be granted broadly; a write tool needs stronger approval and audit. Distinct tools also let you annotate behavior accurately:
{
"readOnlyHint": true,
"destructiveHint": false,
"idempotentHint": true,
"openWorldHint": false
}
Annotations inform the client but do not enforce anything. A write tool must enforce its own authorization and confirmation policy.
Pattern: make destructive actions explicit
Name the effect, not the mechanism:
send_invoice_emailclose_issuedelete_branch
Require a target identifier, echo the intended effect in the result, and keep a human approval step for irreversible actions. A tool called manage_issue with a mode parameter hides the risk from both the user and the approval UI.
Pattern: bound every collection
Every list result needs a limit and a continuation. Default to a small number, cap the maximum, and return a cursor. Include enough metadata for the model to know whether it saw everything:
{
"items": [],
"returned": 0,
"nextCursor": null,
"truncated": false
}
For text, state truncation explicitly. For logs, redact before truncation. Truncating in the middle of a secret does not make the secret safe.
Pattern: deterministic errors
Return a failure that a caller can act on:
- What failed.
- Which resource.
- The upstream status or error code, if safe.
- The next step.
Do not return a stack trace. Do not return an empty success. Use isError for tool-level failures and structured content for machine-readable details. A model can recover from “permission denied; request access to repository X” far better than from “something went wrong.”
Pattern: idempotency for retries
Network-backed tools will be retried. For create operations, accept an idempotency key when the upstream API supports it, or document that repeated calls may duplicate work. For updates, make the desired state explicit (set_status) rather than relative (toggle_status). Retries must not turn a transient timeout into a double charge or duplicate message.
Pattern: context-friendly results
The model’s context is a finite resource. Return the fields needed to decide and cite, not the full upstream object. Prefer:
- IDs and URLs for verification.
- Short summaries with dates.
- A pointer to a tool or resource for details.
- Explicit unknown values.
Images, audio, and binary resources should only be returned when the client supports them. Otherwise return a link or an explanatory text block.
Pattern: version the contract
Tool names and schemas are an API. Renaming a field breaks prompts. Additive changes are safer. If a breaking change is necessary, introduce a new tool name or a versioned parameter and keep the old tool for a deprecation window. Document the change in the server README.
Anti-patterns to reject
| Anti-pattern | Why it fails |
|---|---|
One execute tool for everything |
No contract, no least privilege, no meaningful approval |
| Credentials as arguments | Secrets enter model context and logs |
| Unbounded queries | Resource exhaustion and context flooding |
| Success-shaped errors | The agent reports a failure as success |
| Hidden side effects | A “read” tool changes state and violates trust |
| Auto-approving write tools | Removes the human check at the highest-risk step |
A review checklist
- Can a new engineer explain what the tool does from its name and description?
- Are required, optional, and default values obvious?
- Are units and formats in field descriptions?
- Is the result bounded and citable?
- Can the tool fail safely without crashing the server?
- Is the permission scope narrower than the credential’s maximum?
- Does a retry risk a duplicate side effect?
- Is there a human approval path for irreversible actions?
Tool design is where product intent, security, and protocol mechanics meet. Treat it as an interface design problem, not an API wrapper exercise. For the implementation side in TypeScript, read tool schemas; for Python, read Pydantic contracts.
Sources
Sources were checked on Oct 23, 2026. Versions and client behavior can change; confirm the current documentation before relying on a configuration.