Skip to content

Commit 67c2e2c

Browse files
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 modelcontextprotocol#3359
1 parent a83b145 commit 67c2e2c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/fetch/src/mcp_server_fetch/server.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,4 @@ async def get_prompt(name: str, arguments: dict | None) -> GetPromptResult:
285285

286286
options = server.create_initialization_options()
287287
async with stdio_server() as (read_stream, write_stream):
288-
await server.run(read_stream, write_stream, options, raise_exceptions=True)
288+
await server.run(read_stream, write_stream, options, raise_exceptions=False)

‎src/git/src/mcp_server_git/server.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,4 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
493493

494494
options = server.create_initialization_options()
495495
async with stdio_server() as (read_stream, write_stream):
496-
await server.run(read_stream, write_stream, options, raise_exceptions=True)
496+
await server.run(read_stream, write_stream, options, raise_exceptions=False)

0 commit comments

Comments
 (0)