feat(runtime): allow tools to return raw MCP content directly#3125
Merged
feat(runtime): allow tools to return raw MCP content directly#3125
Conversation
Tools can now return `{ content, structuredContent }` directly from
execute, bypassing the automatic JSON wrapping. This enables returning
images, embedded resources, and other MCP content types.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this contribution about?
Tools created with
createToolpreviously had their return values automatically wrapped into{ structuredContent, content: [{ type: "text", text: JSON.stringify(result) }] }. This change allows tools to return raw MCP content directly (e.g.,{ content: [{ type: "image", ... }] }) by detecting when the result already has a valid MCPcontentarray. This enables returning images, embedded resources, and other MCP content types without the forced JSON text wrapping.How to Test
{ content: [{ type: "text", text: "hello" }] }directly{ foo: "bar" }Review Checklist
Summary by cubic
Allow tools created with
createToolto return raw MCPcontentdirectly, bypassing JSON wrapping when a valid array is provided. Also bumps@decocms/runtimeto1.5.0.New Features
contentarray unchanged (including images and embedded resources).{ structuredContent, content: [{ type: "text", text: JSON.stringify(result) }] }.Bug Fixes
CallToolResultfor passthrough to ensure correct typing.Written for commit ae8bae9. Summary will update on new commits.