You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<Warning>For trust & safety and security, clients **MUST** consider
187
188
tool annotations to be untrusted unless they come from trusted servers.</Warning>
188
189
189
190
### Tool Result
190
191
191
-
Tool results can contain multiple content items of different types:
192
+
Tool results may be **structured** or **unstructured**, depending on whether the tool definition specifies an [output schema](#output-schema).
193
+
194
+
**Structured** tool results are JSON objects that are valid with respect to the tool's output schema.
195
+
196
+
**Unstructured** tool results can contain multiple content items of different types:
192
197
193
198
#### Text Content
194
199
@@ -235,6 +240,150 @@ or data, behind a URI that can be subscribed to or fetched again by the client l
235
240
}
236
241
```
237
242
243
+
### Output Schema
244
+
245
+
Tools that produce structured results can use the `outputSchema` property to provide a JSON Schema describing the expected structure of their output.
246
+
247
+
When a tool specifies an `outputSchema`:
248
+
249
+
1. Clients **MUST** validate that results from that tool contain a `structuredContent` field whose contents validate against the declared `outputSchema`.
250
+
251
+
2. Servers **MUST** provide structured results in `structuredContent` that conform to the declared `outputSchema` of the tool.
252
+
253
+
<Info>
254
+
For backwards compatibility, a tool that declares an `outputSchema` may also return unstructured results in the `content` field.
255
+
* If present, the unstructured result should be functionally equivalent to the structured result. (For example, serialized JSON can be returned in a `TextContent` block.)
256
+
* Clients that support `structuredContent` should ignore the `content` field if present.
257
+
</Info>
258
+
259
+
Example tool with output schema:
260
+
261
+
```json
262
+
{
263
+
"name": "get_weather_data",
264
+
"description": "Get current weather conditions and forecast data for a location",
Copy file name to clipboardExpand all lines: schema/draft/schema.json
+85-2Lines changed: 85 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -101,14 +101,69 @@
101
101
"type": "object"
102
102
},
103
103
"CallToolResult": {
104
-
"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.",
"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."
113
+
},
114
+
"CallToolStructuredResult": {
115
+
"description": "Tool result for tools that do declare an outputSchema.",
116
+
"properties": {
117
+
"_meta": {
118
+
"additionalProperties": {},
119
+
"description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
120
+
"type": "object"
121
+
},
122
+
"content": {
123
+
"description": "If the Tool defines an outputSchema, this field MAY be present in the result.\nTools should use this field to provide compatibility with older clients that do not support structured content.\nClients that support structured content should ignore this field.",
124
+
"items": {
125
+
"anyOf": [
126
+
{
127
+
"$ref": "#/definitions/TextContent"
128
+
},
129
+
{
130
+
"$ref": "#/definitions/ImageContent"
131
+
},
132
+
{
133
+
"$ref": "#/definitions/AudioContent"
134
+
},
135
+
{
136
+
"$ref": "#/definitions/EmbeddedResource"
137
+
}
138
+
]
139
+
},
140
+
"type": "array"
141
+
},
142
+
"isError": {
143
+
"description": "Whether the tool call ended in an error.\n\nIf not set, this is assumed to be false (the call was successful).",
144
+
"type": "boolean"
145
+
},
146
+
"structuredContent": {
147
+
"additionalProperties": {},
148
+
"description": "An object containing structured tool output.\n\nIf the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.",
149
+
"type": "object"
150
+
}
151
+
},
152
+
"required": [
153
+
"structuredContent"
154
+
],
155
+
"type": "object"
156
+
},
157
+
"CallToolUnstructuredResult": {
158
+
"description": "Tool result for tools that do not declare an outputSchema.",
105
159
"properties": {
106
160
"_meta": {
107
161
"additionalProperties": {},
108
162
"description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
109
163
"type": "object"
110
164
},
111
165
"content": {
166
+
"description": "A list of content objects that represent the result of the tool call.\n\nIf the Tool does not define an outputSchema, this field MUST be present in the result.",
112
167
"items": {
113
168
"anyOf": [
114
169
{
@@ -367,6 +422,25 @@
367
422
],
368
423
"type": "object"
369
424
},
425
+
"ContentList": {
426
+
"items": {
427
+
"anyOf": [
428
+
{
429
+
"$ref": "#/definitions/TextContent"
430
+
},
431
+
{
432
+
"$ref": "#/definitions/ImageContent"
433
+
},
434
+
{
435
+
"$ref": "#/definitions/AudioContent"
436
+
},
437
+
{
438
+
"$ref": "#/definitions/EmbeddedResource"
439
+
}
440
+
]
441
+
},
442
+
"type": "array"
443
+
},
370
444
"CreateMessageRequest": {
371
445
"description": "A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.",
"description": "An optional JSON Schema object defining the structure of the tool's output.\n\nIf set, a CallToolResult for this Tool MUST contain a structuredContent field whose contents validate against this schema.\nIf not set, a CallToolResult for this Tool MUST contain a content field.",
0 commit comments