Feature Request: Improve MCP Tool Response Handling
Summary
The run_mcp tool returns raw MCP protocol responses as unparsed strings, and persists large responses to temp files. This forces the AI agent to manually read, strip prefixes, and double-parse JSON — adding unnecessary round-trips and friction for every MCP call.
Current Behavior
- Agent calls
run_mcp with server name, tool name, and args
- For small responses: raw string is returned inline (still unparsed)
- For large responses (~20KB+): output is saved to a temp file, agent must
Read the file manually
- The MCP protocol wraps content in
[{type: "text", text: "JSON_STRING"}] — the text field is itself a JSON string, requiring double parsing
- Agent must: read file → strip
"The MCP server responded with: " prefix → parse outer JSON → parse inner text field as JSON
Expected Behavior
run_mcp should auto-parse the MCP content array ([{type, text}])
- Extract the
text content and parse it as JSON
- Return structured JSON directly to the agent's context
- Do not persist responses to temp files unless they truly exceed context limits (25KB is well within limits)
Impact
- Every MCP call is affected, not just specific servers
- Adds 2-4 extra tool calls per MCP interaction (Read file, parse, verify)
- Increases latency and token usage for no functional benefit
- Makes MCP integration feel sluggish compared to other IDEs/tools
Example: Banani MCP
Current flow (4 steps):
run_mcp → output persisted to /var/folders/.../output.txt (25.6KB)
Read file → get raw string with prefix
RunCommand (python) → parse double-encoded JSON
Read parsed output → finally get structured data
Expected flow (1 step):
run_mcp → returns structured JSON directly
{
"flow": { "name": "...", "id": "..." },
"designs": [
{
"screenName": "Final - Product",
"source": "...",
"screenSize": "desktop"
}
]
}
Comparison
Other tools (e.g., OpenCode, Claude Desktop, Cursor) handle MCP responses as structured data natively. The MCP protocol defines typed content blocks — the client should parse them, not pass raw strings to the agent.
Suggested Implementation
- Parse
[{type: "text", text: "..."}] content arrays automatically
- If
text is valid JSON, deserialize it before returning
- Only persist to file if the deserialized response exceeds a reasonable threshold (e.g., 100KB+)
- Remove the
"The MCP server responded with: " prefix from inline responses
- Return a consistent structured object with
server_name, tool_name, and result (parsed)
Feature Request: Improve MCP Tool Response Handling
Summary
The
run_mcptool returns raw MCP protocol responses as unparsed strings, and persists large responses to temp files. This forces the AI agent to manually read, strip prefixes, and double-parse JSON — adding unnecessary round-trips and friction for every MCP call.Current Behavior
run_mcpwith server name, tool name, and argsReadthe file manually[{type: "text", text: "JSON_STRING"}]— thetextfield is itself a JSON string, requiring double parsing"The MCP server responded with: "prefix → parse outer JSON → parse innertextfield as JSONExpected Behavior
run_mcpshould auto-parse the MCP content array ([{type, text}])textcontent and parse it as JSONImpact
Example: Banani MCP
Current flow (4 steps):
Expected flow (1 step):
Comparison
Other tools (e.g., OpenCode, Claude Desktop, Cursor) handle MCP responses as structured data natively. The MCP protocol defines typed content blocks — the client should parse them, not pass raw strings to the agent.
Suggested Implementation
[{type: "text", text: "..."}]content arrays automaticallytextis valid JSON, deserialize it before returning"The MCP server responded with: "prefix from inline responsesserver_name,tool_name, andresult(parsed)