From 67c2e2c176cf87f630448e8d5f7da895c811ba0d Mon Sep 17 00:00:00 2001 From: TopangaLudwitt Date: Thu, 19 Feb 2026 18:58:13 -0800 Subject: [PATCH] fix: prevent server crash on malformed input in fetch and git servers Change raise_exceptions from True to False in mcp-server-fetch and mcp-server-git to handle malformed JSON-RPC messages gracefully instead of crashing the server process. With raise_exceptions=True, any invalid byte on stdin causes an unhandled ExceptionGroup that terminates the server. This is inconsistent with other reference servers that use the default (False) and survive malformed input. Fuzz testing showed mcp-server-fetch crashed on 61/65 test cases while servers using raise_exceptions=False survived all 65. Fixes #3359 --- src/fetch/src/mcp_server_fetch/server.py | 2 +- src/git/src/mcp_server_git/server.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fetch/src/mcp_server_fetch/server.py b/src/fetch/src/mcp_server_fetch/server.py index 2df9d3b604..1409ee6438 100644 --- a/src/fetch/src/mcp_server_fetch/server.py +++ b/src/fetch/src/mcp_server_fetch/server.py @@ -285,4 +285,4 @@ async def get_prompt(name: str, arguments: dict | None) -> GetPromptResult: options = server.create_initialization_options() async with stdio_server() as (read_stream, write_stream): - await server.run(read_stream, write_stream, options, raise_exceptions=True) + await server.run(read_stream, write_stream, options, raise_exceptions=False) diff --git a/src/git/src/mcp_server_git/server.py b/src/git/src/mcp_server_git/server.py index 1d0298b465..5120a7b629 100644 --- a/src/git/src/mcp_server_git/server.py +++ b/src/git/src/mcp_server_git/server.py @@ -493,4 +493,4 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]: options = server.create_initialization_options() async with stdio_server() as (read_stream, write_stream): - await server.run(read_stream, write_stream, options, raise_exceptions=True) + await server.run(read_stream, write_stream, options, raise_exceptions=False)