Skip to content

[Server] Allow tools to return structured content without text content - #604

Open
andreybolonin wants to merge 1 commit into
modelcontextprotocol:mainfrom
andreybolonin:feature-521v2
Open

andreybolonin wants to merge 1 commit into
modelcontextprotocol:mainfrom
andreybolonin:feature-521v2

Conversation

@andreybolonin

@andreybolonin andreybolonin commented Oct 17, 2026 •

Copy link
Copy Markdown

Tools returning structured data currently duplicate it as JSON text in content. Add a per-tool structuredContentOnly option through #[McpTool] and Builder::addTool() so opted-in tools return content: [] when structured content is available.

Default behavior is preserved. Values without a structured representation retain their regular content, and explicit content items and manually constructed CallToolResult instances retain their existing behavior. The option is carried through discovery and manual registration, with documentation and regression coverage.

Fixes #521.

Validation: all 2,673 unit tests pass (8,713 assertions); integration and interop suites pass (283 tests, 1,030 assertions, 8 skipped). PHPStan reports no errors, and PHP CS Fixer reports no changes required.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Server] Allow tools to return structured content without text content

1 participant