servers icon indicating copy to clipboard operation
servers copied to clipboard

mcp-server-fetch: Server crashes on any malformed input due to raise_exceptions=True

Open manthanghasadiya opened this issue 9 months ago • 2 comments

Describe the bug

mcp-server-fetch terminates on any malformed JSON-RPC message. A single invalid byte on stdin kills the server process. This happens because server.py passes raise_exceptions=True to server.run(), which causes parse errors to propagate as unhandled ExceptionGroups.

Other reference servers (like mcp-server-sqlite) use the default raise_exceptions=False and handle malformed input gracefully.

fuzz_fetch_report.json

To Reproduce

pip install mcp-server-fetch  # v2025.4.7, MCP SDK v1.26.0
echo "NOT VALID JSON" | mcp-server-fetch

Server exits with ExceptionGroup traceback.

Fuzz test comparison Protocol fuzzer sent 65 identical test cases to three servers:

Server MCP SDK Crashes Survives
mcp-server-fetch 1.26.0 61 4
mcp-server-sqlite 1.26.0 0 65
test server 1.26.0 0 65

Root cause mcp_server_fetch/server.py line 287-288:

await server.run(read_stream, write_stream, options, raise_exceptions=True)

Suggested fix Change to raise_exceptions=False (consistent with other reference servers), or add exception handling around the serve() call.

Environment

  • mcp-server-fetch: 2025.4.7
  • mcp SDK: 1.26.0
  • Python: 3.12.2
  • OS: Windows 11

manthanghasadiya avatar Feb 19 '26 22:02 manthanghasadiya

Hey, saw your issue about mcp-server-fetch crashing on malformed input was that something you hit in normal use, or while testing edge cases?

anythingoah avatar Aug 18 '26 08:08 anythingoah

@anythingoah I got it while testing edge cases.

manthanghasadiya avatar Aug 18 '26 15:08 manthanghasadiya