How an MCP tool works
A basic tool interaction has two stages:- The client discovers tools with
tools/list. - The client invokes a selected tool with
tools/call.
What defines a tool?
A tool definition includes a programmatic name, a description, and a JSON Schema for its inputs. It can also include a display title, output schema, icons, and behavioral annotations.Tool results
A tool result can contain text, images, audio, resource links, embedded resources, or structured content supported by the negotiated protocol version. For predictable machine-readable output, a server can define anoutputSchema and return matching structuredContent. It can also include text content for clients that display or process conversational results.
Tool execution errors should be returned in the tool result when the model may be able to correct its input or recover. Protocol errors are for problems with the MCP request itself.
Tools are model-controlled
“Model-controlled” describes the intended interaction pattern. It does not mean a model should have unrestricted authority. An MCP application should:- Show which tools are available to the model
- Make tool calls visible to the user
- Ask for confirmation before sensitive or destructive actions
- Let the user deny a tool call
- Display results and failures clearly
Tools vs resources
Use a resource when the main purpose is to supply readable context. Use a tool when the model needs to perform an operation or request computed, parameterized work.
Examples of MCP tools
Start with a small, focused tool set. Exposing every API endpoint can consume context and make correct tool selection harder.
Design tools that models can use reliably
- Give each tool one clear purpose.
- Use descriptive names and parameter labels.
- Explain formats, units, limits, and required identifiers.
- Define narrow input schemas.
- Validate every argument on the server.
- Return concise, actionable errors.
- Return structured output when downstream processing needs stable fields.
- Avoid placing secrets in descriptions or results.
readOnlyHint, destructiveHint, idempotentHint, and openWorldHint can help clients present a tool appropriately. They are untrusted hints, not security controls.
Security responsibilities
Before executing a tool, the server should:- Authenticate the caller when required
- Authorize the exact operation and target
- Validate and sanitize inputs
- Apply rate and resource limits
- Protect credentials and private data
- Log security-relevant events without logging secrets