modelcontextprotocol / modelcontextprotocol/servers
filesystem: malformed JSON-RPC message on stdio causes crash or zombie state
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 90.5k
- Forks
- 11.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 5
Description
Describe the bug
The secure-filesystem-server MCP server does not survive a single malformed JSON-RPC line on stdio. After receiving an incomplete JSON object (truncated initialize-style frame with an unclosed params field), the server either exits or enters a zombie state where it no longer responds to follow-up requests.
A robust MCP server should treat parse errors as recoverable: return a JSON-RPC error (or skip the bad line per spec) and continue serving subsequent messages. Crashing or hanging breaks the host connector, and here the trigger is protocol fuzzing rather than a missing allowed_directories path.
Environment
OS: Linux
Platform: Cursor Desktop
MCP server: @modelcontextprotocol/server-filesystem via npx -y
Reported serverInfo: {"name":"secure-filesystem-server","version":"0.2.0"}
To Reproduce
- Start the server:
npx -y @modelcontextprotocol/server-filesystem /tmp
- Write the following single line to the server’s stdin (note: invalid JSON — no closing
}orparamsvalue):
{"jsonrpc":"2.0", "method": "test", "params":
(newline-terminated, as MCP stdio transport expects one JSON-RPC message per line.)
- Wait briefly, then send a valid JSON-RPC request (e.g.
pingortools/list).
Expected behavior
For a parse error on one stdin line:
- Do not terminate the Node process.
- Do not block the event loop indefinitely on a half-read line.
- Return a JSON-RPC error for that message (e.g. parse error / invalid request), or discard the bad line per documented transport rules.
- Continue processing subsequent well-formed messages on the same stdio session.
Optional: emit a one-line diagnostic on stderr (host MCP logs often capture this), e.g.
[filesystem] JSON parse error on stdin line N: Unexpected end of JSON input
Actual behaviour
The MCP server crashed or became unresponsive (zombie state).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the documented npx command and tracing the server's stdio JSON-RPC entry point for the newline-terminated malformed line. Verify behavior with the supplied malformed initialize-style input followed by ping or tools/list; done means the process remains responsive and the later valid request is handled, with an error or documented discard for the bad line.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100