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: README.md
+105-1Lines changed: 105 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -385,6 +385,14 @@ class MyTool < MCP::Tool
385
385
},
386
386
required: ["message"]
387
387
)
388
+
output_schema(
389
+
properties: {
390
+
result: { type:"string" },
391
+
success: { type:"boolean" },
392
+
timestamp: { type:"string", format:"date-time" }
393
+
},
394
+
required: ["result", "success", "timestamp"]
395
+
)
388
396
annotations(
389
397
read_only_hint:true,
390
398
destructive_hint:false,
@@ -451,6 +459,102 @@ Annotations can be set either through the class definition using the `annotation
451
459
> [!NOTE]
452
460
> This **Tool Annotations** feature is supported starting from `protocol_version: '2025-03-26'`.
453
461
462
+
### Tool Output Schemas
463
+
464
+
Tools can optionally define an `output_schema` to specify the expected structure of their results. This works similarly to how `input_schema` is defined and can be used in three ways:
MCP spec for the [Output Schema](https://modelcontextprotocol.io/specification/2025-06-18/server/tools#output-schema) specifies that:
550
+
551
+
-**Server Validation**: Servers MUST provide structured results that conform to the output schema
552
+
-**Client Validation**: Clients SHOULD validate structured results against the output schema
553
+
-**Better Integration**: Enables strict schema validation, type information, and improved developer experience
554
+
-**Backward Compatibility**: Tools returning structured content SHOULD also include serialized JSON in a TextContent block
555
+
556
+
The output schema follows standard JSON Schema format and helps ensure consistent data exchange between MCP servers and clients.
557
+
454
558
### Prompts
455
559
456
560
MCP spec includes [Prompts](https://modelcontextprotocol.io/specification/2025-06-18/server/prompts), which enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs.
@@ -758,7 +862,7 @@ The client provides a wrapper class for tools returned by the server:
758
862
759
863
-`MCP::Client::Tool` - Represents a single tool with its metadata
760
864
761
-
This class provide easy access to tool properties like name, description, and input schema.
865
+
This class provides easy access to tool properties like name, description, input schema, and output schema.
0 commit comments