Skip to content

Commit fb6a4b0

Browse files
committed
Match tool results' structure to that of prompts
1 parent ed35f71 commit fb6a4b0

File tree

3 files changed

+61
-40
lines changed

3 files changed

+61
-40
lines changed

docs/spec/tools.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,20 @@ Example:
236236

237237
The server MUST respond with a `CallToolResult` containing:
238238

239-
- `toolResult`: The result of the tool invocation (any JSON-serializable value)
239+
- `content`: An array of content items that can be text, images, or embedded resources
240+
- `isError`: A boolean indicating whether this result represents an error state
240241

241242
Example:
242243
```json
243244
{
244245
"jsonrpc": "2.0",
245246
"id": 2,
246247
"result": {
247-
"toolResult": {
248-
"temperature": 72,
249-
"humidity": 65,
250-
"description": "Partly cloudy"
251-
}
248+
"content": [{
249+
"type": "text",
250+
"text": "Current weather in New York:\nTemperature: 72°F\nHumidity: 65%\nConditions: Partly cloudy"
251+
}],
252+
"isError": false
252253
}
253254
}
254255
```

schema/schema.json

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,36 @@
5454
"type": "object"
5555
},
5656
"CallToolResult": {
57-
"description": "The server's response to a tool call.\n\nAny errors that originate from the tool SHOULD be reported inside the result\nobject—i.e., as part of an MCP successful result, not as an MCP error\nresponse. Otherwise, the LLM would not be able to see that an error occurred\nand self-correct.\n\nHowever, any errors in _finding_ the tool, an error indicating that the\nserver does not support tool calls, or any other exceptional conditions,\nshould be reported as an MCP error response.",
57+
"description": "The server's response to a tool call.\n\nAny errors that originate from the tool SHOULD be reported inside the result\nobject, with `isError` set to true, _not_ as an MCP protocol-level error\nresponse. Otherwise, the LLM would not be able to see that an error occurred\nand self-correct.\n\nHowever, any errors in _finding_ the tool, an error indicating that the\nserver does not support tool calls, or any other exceptional conditions,\nshould be reported as an MCP error response.",
5858
"properties": {
5959
"_meta": {
6060
"additionalProperties": {},
6161
"description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
6262
"type": "object"
6363
},
64-
"toolResult": {}
64+
"content": {
65+
"items": {
66+
"anyOf": [
67+
{
68+
"$ref": "#/definitions/TextContent"
69+
},
70+
{
71+
"$ref": "#/definitions/ImageContent"
72+
},
73+
{
74+
"$ref": "#/definitions/EmbeddedResource"
75+
}
76+
]
77+
},
78+
"type": "array"
79+
},
80+
"isError": {
81+
"type": "boolean"
82+
}
6583
},
6684
"required": [
67-
"toolResult"
85+
"content",
86+
"isError"
6887
],
6988
"type": "object"
7089
},
@@ -366,6 +385,30 @@
366385
"description": "An opaque token used to represent a cursor for pagination.",
367386
"type": "string"
368387
},
388+
"EmbeddedResource": {
389+
"description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit\nof the LLM and/or the user.",
390+
"properties": {
391+
"resource": {
392+
"anyOf": [
393+
{
394+
"$ref": "#/definitions/TextResourceContents"
395+
},
396+
{
397+
"$ref": "#/definitions/BlobResourceContents"
398+
}
399+
]
400+
},
401+
"type": {
402+
"const": "resource",
403+
"type": "string"
404+
}
405+
},
406+
"required": [
407+
"resource",
408+
"type"
409+
],
410+
"type": "object"
411+
},
369412
"EmptyResult": {
370413
"$ref": "#/definitions/Result"
371414
},
@@ -1171,30 +1214,6 @@
11711214
],
11721215
"type": "object"
11731216
},
1174-
"PromptEmbeddedResource": {
1175-
"description": "The contents of a resource, embedded into a prompt.\n\nIt is up to the client how best to render embedded resources for the benefit\nof the LLM and/or the user.",
1176-
"properties": {
1177-
"resource": {
1178-
"anyOf": [
1179-
{
1180-
"$ref": "#/definitions/TextResourceContents"
1181-
},
1182-
{
1183-
"$ref": "#/definitions/BlobResourceContents"
1184-
}
1185-
]
1186-
},
1187-
"type": {
1188-
"const": "resource",
1189-
"type": "string"
1190-
}
1191-
},
1192-
"required": [
1193-
"resource",
1194-
"type"
1195-
],
1196-
"type": "object"
1197-
},
11981217
"PromptListChangedNotification": {
11991218
"description": "An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.",
12001219
"properties": {
@@ -1231,7 +1250,7 @@
12311250
"$ref": "#/definitions/ImageContent"
12321251
},
12331252
{
1234-
"$ref": "#/definitions/PromptEmbeddedResource"
1253+
"$ref": "#/definitions/EmbeddedResource"
12351254
}
12361255
]
12371256
},

schema/schema.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type JSONRPCMessage =
55
| JSONRPCResponse
66
| JSONRPCError;
77

8-
export const LATEST_PROTOCOL_VERSION = "2024-10-07";
8+
export const LATEST_PROTOCOL_VERSION = "2024-11-05";
99
export const JSONRPC_VERSION = "2.0";
1010

1111
/**
@@ -562,16 +562,16 @@ export interface PromptArgument {
562562
*/
563563
export interface PromptMessage {
564564
role: "user" | "assistant";
565-
content: TextContent | ImageContent | PromptEmbeddedResource;
565+
content: TextContent | ImageContent | EmbeddedResource;
566566
}
567567

568568
/**
569-
* The contents of a resource, embedded into a prompt.
569+
* The contents of a resource, embedded into a prompt or tool call result.
570570
*
571571
* It is up to the client how best to render embedded resources for the benefit
572572
* of the LLM and/or the user.
573573
*/
574-
export interface PromptEmbeddedResource {
574+
export interface EmbeddedResource {
575575
type: "resource";
576576
resource: TextResourceContents | BlobResourceContents;
577577
}
@@ -602,7 +602,7 @@ export interface ListToolsResult extends PaginatedResult {
602602
* The server's response to a tool call.
603603
*
604604
* Any errors that originate from the tool SHOULD be reported inside the result
605-
* object—i.e., as part of an MCP successful result, not as an MCP error
605+
* object, with `isError` set to true, _not_ as an MCP protocol-level error
606606
* response. Otherwise, the LLM would not be able to see that an error occurred
607607
* and self-correct.
608608
*
@@ -611,7 +611,8 @@ export interface ListToolsResult extends PaginatedResult {
611611
* should be reported as an MCP error response.
612612
*/
613613
export interface CallToolResult extends Result {
614-
toolResult: unknown;
614+
content: (TextContent | ImageContent | EmbeddedResource)[];
615+
isError: boolean;
615616
}
616617

617618
/**

0 commit comments

Comments
 (0)