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
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -555,6 +555,38 @@ MCP spec for the [Output Schema](https://modelcontextprotocol.io/specification/2
555
555
556
556
The output schema follows standard JSON Schema format and helps ensure consistent data exchange between MCP servers and clients.
557
557
558
+
### Tool Responses with Structured Content
559
+
560
+
Tools can return structured data alongside text content using the `structured_content` parameter.
561
+
562
+
The structured content will be included in the JSON-RPC response as the `structuredContent` field.
563
+
564
+
```ruby
565
+
classAPITool < MCP::Tool
566
+
description "Get current weather and return structured data"
567
+
568
+
defself.call(endpoint:, server_context:)
569
+
# Call weather API and structure the response
570
+
api_response =WeatherAPI.fetch(location, units)
571
+
weather_data = {
572
+
temperature: api_response.temp,
573
+
condition: api_response.description,
574
+
humidity: api_response.humidity_percent
575
+
}
576
+
577
+
output_schema.validate_result(weather_data)
578
+
579
+
MCP::Tool::Response.new(
580
+
[{
581
+
type:"text",
582
+
text: weather_data.to_json
583
+
}],
584
+
structured_content: weather_data
585
+
)
586
+
end
587
+
end
588
+
```
589
+
558
590
### Prompts
559
591
560
592
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.
warn("Passing `error` with the 2nd argument of `Response.new` is deprecated. Use keyword argument like `Response.new(content, error: error)` instead.",uplevel: 1)
0 commit comments