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
Copy file name to clipboardExpand all lines: docs/specification/draft/server/tools.mdx
+32-98Lines changed: 32 additions & 98 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,11 +189,9 @@ tool annotations to be untrusted unless they come from trusted servers.</Warning
189
189
190
190
### Tool Result
191
191
192
-
Tool results may be **structured** or **unstructured**, depending on whether the tool definition specifies an [output schema](#output-schema).
192
+
Tool results may contain [**structured**](#structured-content) or **unstructured** content.
193
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:
194
+
**Unstructured** content is returned in the `content` field of a result, and can contain multiple content items of different types:
197
195
198
196
#### Text Content
199
197
@@ -240,95 +238,53 @@ or data, behind a URI that can be subscribed to or fetched again by the client l
240
238
}
241
239
```
242
240
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.
241
+
#### Structured Content
246
242
247
-
When a tool specifies an `outputSchema`:
243
+
**Structured** content is returned as a JSON object in the `structuredContent` field of a result.
248
244
249
-
1. Clients **MUST** validate that results from that tool contain a `structuredContent` field whose contents validate against the declared `outputSchema`.
245
+
For backwards compatibility, a tool that returns structured content SHOULD also return functionally equivalent unstructured content.
246
+
(For example, serialized JSON can be returned in a `TextContent` block.)
250
247
251
-
2. Servers **MUST** provide structured results in `structuredContent` that conform to the declared `outputSchema` of the tool.
248
+
#### Output Schema
252
249
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>
250
+
Tools may also provide an output schema for validation of structured results.
251
+
If an output schema provided:
252
+
* Servers **MUST** provide structured results that conform to this schema.
253
+
* Clients **SHOULD** validate structured results against this schema.
258
254
259
255
Example tool with output schema:
260
256
261
257
```json
262
258
{
263
259
"name": "get_weather_data",
264
-
"description": "Get current weather conditions and forecast data for a location",
260
+
"description": "Get current weather data for a location",
"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.",
104
+
"description": "The server's response to a tool call.",
116
105
"properties": {
117
106
"_meta": {
118
107
"additionalProperties": {},
119
108
"description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
120
109
"type": "object"
121
110
},
122
111
"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.",
112
+
"description": "A list of content objects that represent the unstructured result of the tool call.",
124
113
"items": {
125
114
"anyOf": [
126
115
{
@@ -140,51 +129,13 @@
140
129
"type": "array"
141
130
},
142
131
"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).",
132
+
"description": "Whether the tool call ended in an error.\n\nIf not set, this is assumed to be false (the call was successful).\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.",
144
133
"type": "boolean"
145
134
},
146
135
"structuredContent": {
147
136
"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.",
159
-
"properties": {
160
-
"_meta": {
161
-
"additionalProperties": {},
162
-
"description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
137
+
"description": "An optional JSON object that represents the structured result of the tool call.",
163
138
"type": "object"
164
-
},
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.",
167
-
"items": {
168
-
"anyOf": [
169
-
{
170
-
"$ref": "#/definitions/TextContent"
171
-
},
172
-
{
173
-
"$ref": "#/definitions/ImageContent"
174
-
},
175
-
{
176
-
"$ref": "#/definitions/AudioContent"
177
-
},
178
-
{
179
-
"$ref": "#/definitions/EmbeddedResource"
180
-
}
181
-
]
182
-
},
183
-
"type": "array"
184
-
},
185
-
"isError": {
186
-
"description": "Whether the tool call ended in an error.\n\nIf not set, this is assumed to be false (the call was successful).",
187
-
"type": "boolean"
188
139
}
189
140
},
190
141
"required": [
@@ -413,25 +364,6 @@
413
364
],
414
365
"type": "object"
415
366
},
416
-
"ContentList": {
417
-
"items": {
418
-
"anyOf": [
419
-
{
420
-
"$ref": "#/definitions/TextContent"
421
-
},
422
-
{
423
-
"$ref": "#/definitions/ImageContent"
424
-
},
425
-
{
426
-
"$ref": "#/definitions/AudioContent"
427
-
},
428
-
{
429
-
"$ref": "#/definitions/EmbeddedResource"
430
-
}
431
-
]
432
-
},
433
-
"type": "array"
434
-
},
435
367
"CreateMessageRequest": {
436
368
"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.",
2060
+
"description": "An optional JSON Schema object defining the structure of the tool's output returned in \nthe structuredContent field of a CallToolResult.",
0 commit comments