LearnNewsExamplesServices
Frontmatter
id7647
titleFix: MCP Server Misinterprets Tool Error Responses
stateClosed
labels
bugai
assigneestobiu
createdAtOct 25, 2025, 4:19 PM
updatedAtOct 25, 2025, 4:20 PM
githubUrlhttps://github.com/neomjs/neo/issues/7647
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtOct 25, 2025, 4:20 PM

Fix: MCP Server Misinterprets Tool Error Responses

Closed v11.0.0 bugai
tobiu
tobiu commented on Oct 25, 2025, 4:19 PM

This ticket reports and resolves a bug in the MCP server's tool handling logic that caused it to misinterpret structured error responses from underlying services as schema validation failures.

Problem: When a tool's underlying service (e.g., IssueService.createIssue) returned a structured error object (e.g., {"error": "...", "message": "...", "code": "..."}), the MCP server's CallToolRequestSchema handler incorrectly set the isError flag to false in its response. This led the client (e.g., the Python SDK) to attempt to validate the error object against the tool's success output schema, resulting in a misleading "Structured content does not match the tool's output schema: data should NOT have additional properties" error.

Root Cause: The mcp-stdio.mjs file's CallToolRequestSchema handler unconditionally set isError: false when processing the result from callTool, even if result itself was a structured error object.

Solution: The CallToolRequestSchema handler in mcp-stdio.mjs has been adjusted to correctly identify if the result from callTool is an error object (by checking for the presence of an error property). The isError flag in the MCP server's response is now conditionally set to true if the tool's result is an error, ensuring proper error propagation to the client.

Changes Implemented: The CallToolRequestSchema handler in mcp-stdio.mjs was modified as follows:

        let contentBlock;
        let isServiceError    = false;
        let structuredContent = null;

        if (typeof result === 'object' && result !== null) {
            isServiceError = 'error' in result; // Check for 'error' property to identify service errors

            contentBlock = {
                type: 'text',
                text: JSON.stringify(result, null, 2)
            };
            structuredContent = result;
        } else {
            contentBlock = {
                type: 'text',
                text: String(result)
            };
        }

        const response = {
            content: [contentBlock],
            isError: isServiceError // Set isError based on whether the service result was an error
        };

This ensures that error responses from tools are correctly identified and propagated.

tobiu added the bug label on Oct 25, 2025, 4:19 PM
tobiu added the ai label on Oct 25, 2025, 4:19 PM
tobiu assigned to @tobiu on Oct 25, 2025, 4:19 PM
tobiu referenced in commit 6f3b9ed - "Fix: MCP Server Misinterprets Tool Error Responses #7647" on Oct 25, 2025, 4:20 PM
tobiu closed this issue on Oct 25, 2025, 4:20 PM