Study FAQ
How should an MCP server list and call tools and return errors?
Also asked as 2
- How do tools/list and tools/call work in MCP 2026-07-28?
- When should an MCP tool return isError versus a JSON-RPC error?
Answer
In MCP 2026-07-28, expose eligible tools through tools/list and invoke an authorized tool through tools/call. For a malformed JSON-RPC tool request or unknown tool, return the appropriate protocol error. For a recognized tool that cannot perform the action, return a tool result with isError: true and actionable, safe feedback.
Give each tool a clear name, description, input JSON Schema, and, when useful, an output schema. Return an authorized and deterministically ordered listing for an unchanged eligible set. A 2026-07-28 listing carries ttlMs and cacheScope; use private for caller-specific data. With the advertised list-change capability and a matching active subscription, send a notification when the available list changes. Recheck authorization and validate arguments at invocation, even if the tool appeared in the list. Treat annotations as hints from the server, with trust determined separately.
MCP results can include content and an optional structuredContent value. When you define an output schema, validate structured results against it. Check resultType to distinguish a complete result from a request for more input. For example, a recognized reservation tool might return an in-tool validation error for a past date. A request to a nonexistent tool belongs at the protocol layer. Record an owner, protocol revision, versioned schemas, and data and logging policy for the server. Bound request size, concurrency, execution time, and result size. Test denied access, invalid inputs, cancellation, and dependency failure, and verify that caches and handles are tenant-scoped.
Full explanation
MCP Server Development and Choosing Between Tools, Skills, and MCP
Study guide · CCDV-F
Read the full explanation