Description
Per the MCP spec:
For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block.
Currently content and structuredContent are built by separate code paths in execToolDefinition.ts. This leads to divergence (e.g. ANSI stripping only applied to content, not structuredContent).
Proposed approach
Build one canonical result object, derive both outputs from it:
const canonical = buildResult(result); // single path, fully processed
return {
content: [{ type: 'text', text: JSON.stringify(canonical) }],
structuredContent: canonical,
};
Benefits
- Eliminates divergence bugs by construction
- Matches MCP spec intent (
content = serialised structuredContent)
- Single place for all output transformations (ANSI stripping, formatting, etc.)
- Less code to maintain
🤖 Generated with Claude Code
Description
Per the MCP spec:
Currently
contentandstructuredContentare built by separate code paths inexecToolDefinition.ts. This leads to divergence (e.g. ANSI stripping only applied tocontent, notstructuredContent).Proposed approach
Build one canonical result object, derive both outputs from it:
Benefits
content= serialisedstructuredContent)🤖 Generated with Claude Code