Skip to content

Commit fe36698

Browse files
authored
Merge pull request modelcontextprotocol#2425 from jonathanhefner/reorganize-tool-error-handling-section
Reorganize tool error handling section for clarity
2 parents 02a78ab + 018d117 commit fe36698

1 file changed

Lines changed: 35 additions & 37 deletions

File tree

docs/specification/draft/server/tools.mdx

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -454,51 +454,49 @@ Providing an output schema helps clients and LLMs understand and properly handle
454454

455455
Tools use two error reporting mechanisms:
456456

457-
1. **Protocol Errors**: Standard JSON-RPC errors for issues like:
458-
- Unknown tools
457+
1. **Protocol Errors** indicate issues with the request structure itself that models are less likely to be able to fix:
458+
- Unknown tool
459459
- Malformed requests (requests that fail to satisfy [CallToolRequest schema](/specification/draft/schema#calltoolrequest))
460460
- Server errors
461461

462-
2. **Tool Execution Errors**: Reported in tool results with `isError: true`:
462+
They are returned as standard JSON-RPC errors:
463+
464+
```json
465+
{
466+
"jsonrpc": "2.0",
467+
"id": 3,
468+
"error": {
469+
"code": -32602,
470+
"message": "Unknown tool: invalid_tool_name"
471+
}
472+
}
473+
```
474+
475+
2. **Tool Execution Errors** contain actionable feedback that language models can use to self-correct and retry with adjusted parameters:
463476
- API failures
464477
- Input validation errors (e.g., date in wrong format, value out of range)
465478
- Business logic errors
466479

467-
**Tool Execution Errors** contain actionable feedback that language models can use to self-correct and retry with adjusted parameters.
468-
**Protocol Errors** indicate issues with the request structure itself that models are less likely to be able to fix.
469-
Clients **SHOULD** provide tool execution errors to language models to enable self-correction.
470-
Clients **MAY** provide protocol errors to language models, though these are less likely to result in successful recovery.
471-
472-
Example protocol error:
473-
474-
```json
475-
{
476-
"jsonrpc": "2.0",
477-
"id": 3,
478-
"error": {
479-
"code": -32602,
480-
"message": "Unknown tool: invalid_tool_name"
481-
}
482-
}
483-
```
484-
485-
Example tool execution error (input validation):
480+
They are reported in tool results with `isError: true`:
481+
482+
```json
483+
{
484+
"jsonrpc": "2.0",
485+
"id": 4,
486+
"result": {
487+
"content": [
488+
{
489+
"type": "text",
490+
"text": "Invalid departure date: must be in the future. Current date is 08/08/2025."
491+
}
492+
],
493+
"isError": true
494+
}
495+
}
496+
```
486497

487-
```json
488-
{
489-
"jsonrpc": "2.0",
490-
"id": 4,
491-
"result": {
492-
"content": [
493-
{
494-
"type": "text",
495-
"text": "Invalid departure date: must be in the future. Current date is 08/08/2025."
496-
}
497-
],
498-
"isError": true
499-
}
500-
}
501-
```
498+
Clients **MAY** provide protocol errors to language models, though these are less likely to result in successful recovery.
499+
Clients **SHOULD** provide tool execution errors to language models to enable self-correction.
502500

503501
## Security Considerations
504502

0 commit comments

Comments
 (0)