fix: remove structuredContent from MCP tool results#13
Open
MaxwellCalkin wants to merge 1 commit intoagentmail-to:mainfrom
Open
fix: remove structuredContent from MCP tool results#13MaxwellCalkin wants to merge 1 commit intoagentmail-to:mainfrom
MaxwellCalkin wants to merge 1 commit intoagentmail-to:mainfrom
Conversation
structuredContent requires tools to declare an outputSchema (per the MCP
spec), which these tools don't. When the raw API result is a string
instead of a record, the MCP SDK raises:
MCP error -32602: Invalid tools/call result:
expected record, received string
Removing structuredContent fixes Claude Code and other spec-compliant
MCP clients. The content field already returns the full result as
JSON text, so no information is lost.
Fixes agentmail-to/agentmail-mcp#5
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
No issues found across 1 file
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
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.
Summary
structuredContentfield from MCP tool callback results innode/src/mcp.tsMCP error -32602Root Cause
The
structuredContentfield in the MCP spec requires tools to declare anoutputSchema. Since these tools don't declare one, the SDK validatesstructuredContentagainst no schema and fails. Additionally, when the API result is a string (e.g. fromdeleteInbox), validation fails with "expected record, received string".The
contentfield already returns the full result as pretty-printed JSON text, so no information is lost.Test plan
agentmail-toolkitinagentmail-mcpclaude mcp listto verify server connectslist_inboxesfrom Claude Code — should return results without-32602errordelete_inbox(string result) — should also work🤖 Generated with Claude Code
Summary by cubic
Removed structuredContent from MCP tool results to comply with the spec when no outputSchema is declared. Fixes MCP error -32602 in Claude Code and other spec-compliant clients while preserving full output via the content field as pretty-printed JSON (agentmail-to/agentmail-mcp#5).
Written for commit c29f407. Summary will update on new commits.