Skip to content

fix: remove structuredContent from MCP tool results#13

Open
MaxwellCalkin wants to merge 1 commit intoagentmail-to:mainfrom
MaxwellCalkin:fix/remove-structured-content
Open

fix: remove structuredContent from MCP tool results#13
MaxwellCalkin wants to merge 1 commit intoagentmail-to:mainfrom
MaxwellCalkin:fix/remove-structured-content

Conversation

@MaxwellCalkin
Copy link

@MaxwellCalkin MaxwellCalkin commented Mar 7, 2026

Summary

  • Removes the structuredContent field from MCP tool callback results in node/src/mcp.ts
  • Fixes agentmail-to/agentmail-mcp#5 — Claude Code and other spec-compliant MCP clients reject tool results with MCP error -32602

Root Cause

The structuredContent field in the MCP spec requires tools to declare an outputSchema. Since these tools don't declare one, the SDK validates structuredContent against no schema and fails. Additionally, when the API result is a string (e.g. from deleteInbox), validation fails with "expected record, received string".

The content field already returns the full result as pretty-printed JSON text, so no information is lost.

Test plan

  • Install the patched agentmail-toolkit in agentmail-mcp
  • Run claude mcp list to verify server connects
  • Call list_inboxes from Claude Code — should return results without -32602 error
  • Call delete_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.

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>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

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.

MCP responses use structuredContent instead of content, breaking Claude Code compatibility

1 participant