{"record":{"id":"ea306774297e4bd5","repo":"modelcontextprotocol/servers","slug":"error-processing-mcp-server-time-query-str-e","errorCode":null,"errorMessage":"Error processing mcp-server-time query: {str(e)}","messagePattern":"Error processing mcp-server-time query: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/time/src/mcp_server_time/server.py","lineNumber":216,"sourceCode":"                        k in arguments\n                        for k in [\"source_timezone\", \"time\", \"target_timezone\"]\n                    ):\n                        raise ValueError(\"Missing required arguments\")\n\n                    result = time_server.convert_time(\n                        arguments[\"source_timezone\"],\n                        arguments[\"time\"],\n                        arguments[\"target_timezone\"],\n                    )\n                case _:\n                    raise ValueError(f\"Unknown tool: {name}\")\n\n            return [\n                TextContent(type=\"text\", text=json.dumps(result.model_dump(), indent=2))\n            ]\n\n        except Exception as e:\n            raise ValueError(f\"Error processing mcp-server-time query: {str(e)}\")\n\n    options = server.create_initialization_options()\n    async with stdio_server() as (read_stream, write_stream):\n        await server.run(read_stream, write_stream, options)\n","sourceCodeStart":198,"sourceCodeEnd":221,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/time/src/mcp_server_time/server.py#L198-L221","documentation":"The time server's call_tool wraps its entire body in try/except Exception (server.py:187, 215-216) and re-raises every failure as ValueError('Error processing mcp-server-time query: {e}'). This is the error the MCP client actually sees for ANY internal failure, including errors 44-48. It is a code smell: it downgrades the structured McpError(INVALID_PARAMS) from get_zoneinfo (error 44) into a plain ValueError, destroying the error code and nesting the message twice. The git server, by contrast, uses raise_exceptions=True with no catch-all.","triggerScenarios":"Any exception inside get_current_time or convert_time dispatch: invalid timezone (44), bad time format (45), missing args (46/47), unknown tool (48), or any unexpected runtime error.","commonSituations":"Operators see only the generic wrapper and must read server logs to find the cause. Clients that branch on INVALID_PARAMS never see it because the McpError was converted to ValueError. Every distinct internal failure looks the same to the caller.","solutions":["Read the full message: the original error text is appended after 'query: ' and identifies the real cause (44/45/46/47/48).","Pre-validate tz/time/args client-side (see 44-48) so this path is never reached.","If you maintain the server: re-raise McpError unchanged and only wrap truly unexpected exceptions, mirroring the git server's no-catch-all approach.","Until fixed, do not rely on the error code; parse the message tail or inspect server logs."],"exampleFix":"# before\nexcept Exception as e:\n    raise ValueError(f\"Error processing mcp-server-time query: {str(e)}\")\n\n# after\nfrom mcp.shared.exceptions import McpError\nexcept McpError:\n    raise  # preserve INVALID_PARAMS code and message\nexcept Exception as e:\n    raise ValueError(f\"Error processing mcp-server-time query: {str(e)}\")","handlingStrategy":"try-catch","validationCode":"# This error IS the catch; there is no pre-call code for it.\n# Prevention = pre-validate inputs for errors 44-48 so this path is never hit.\n# See validationCode for errorIndex 44, 45, 46, 47, 48.","typeGuard":null,"tryCatchPattern":"try:\n    result = await session.call_tool(name, arguments)\nexcept Exception as e:\n    msg = str(e)\n    # The real cause is appended after 'query: ' — log it; do not branch on a code.\n    if msg.startswith(\"Error processing mcp-server-time query:\"):\n        cause = msg.split(\"query:\", 1)[-1].strip()\n        log.error(\"time server failure, underlying cause: %s\", cause)\n    raise","preventionTips":["Pre-validate timezone, time format, and required args (44-48) so the call never throws.","If you maintain the server, narrow the except: re-raise McpError unchanged and only wrap unexpected errors.","Do not branch on an error code here — the wrapper converts everything to a plain ValueError.","Log and inspect the message tail to recover the real cause until the server is fixed."],"tags":["time","error-handling","catch-all","python","code-smell"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}