fix: prevent server crash on malformed input in fetch and git servers#3360
fix: prevent server crash on malformed input in fetch and git servers#3360TopangaLudwitt wants to merge 1 commit into
Conversation
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
|
@claude review |
|
Claude finished @cliffhall's task in 1m 23s —— View job Code Review
Summary: This is a small, well-targeted fix that aligns What the change doesBoth servers previously called: await server.run(read_stream, write_stream, options, raise_exceptions=True)With The change sets AssessmentCorrectness ✅ Consistency ✅ Minimal scope ✅ Tests Prior use of Minor notes
Verdict: Approve. The change is correct, safe, and well-motivated. Consider adding a resilience test in a follow-up. |
Summary
Change
raise_exceptionsfromTruetoFalseinmcp-server-fetchandmcp-server-gitto handle malformed JSON-RPC messages gracefully.Problem
With
raise_exceptions=True, any invalid byte on stdin causes an unhandledExceptionGroupthat terminates the server process. As reported in #3359, fuzz testing showedmcp-server-fetchcrashed on 61 out of 65 test cases, while servers using the defaultraise_exceptions=Falsesurvived all 65.Fix
Set
raise_exceptions=False(the SDK default) in both affected servers, consistent with other reference server implementations.Files Changed
src/fetch/src/mcp_server_fetch/server.py— line 288src/git/src/mcp_server_git/server.py— line 496Fixes #3359