Repository navigation
Description
Which server?
filesystem (@modelcontextprotocol/server-filesystem)
Server version
2.4.1 (npm; also verified unchanged on v2/main 002bcceed159)
How did you run the server?
npx (npm package)
Transport
stdio
Protocol era
Legacy (2025-11-25 or earlier)
MCP client and version
Custom Python JSON-RPC stdio client (mcpfuse test harness)
Operating system and runtime
Linux x64 (Ubuntu 22.04), Node.js v22
Server configuration
npx -y @modelcontextprotocol/server-filesystem@2.4.1 /tmp/fs-encoding-reproSteps to reproduce
- Create non-UTF-8 text files inside
/tmp/fs-encoding-repro:python3 -c ' open("/tmp/fs-encoding-repro/utf16_bom.txt", "wb").write("Hello\nSecond line\n".encode("utf-16")) open("/tmp/fs-encoding-repro/gbk.txt", "wb").write("你好世界\n".encode("gbk")) '
- Call
read_text_fileon both files (with and withouthead/tail):{"path": "/tmp/fs-encoding-repro/utf16_bom.txt"} {"path": "/tmp/fs-encoding-repro/utf16_bom.txt", "tail": 1} {"path": "/tmp/fs-encoding-repro/gbk.txt", "head": 1}
Expected behavior
Either read_text_file actually handles non-UTF-8 text encodings (e.g., UTF-16 with BOM) or reports an error as claimed, or its tools/list description accurately states that it decodes files as UTF-8 (matching src/filesystem/README.md:159).
Actual behavior
src/filesystem/server.ts:418-420 advertises in tools/list:
Read the complete contents of a file from the file system as text. Handles various text encodings and provides detailed error messages if the file cannot be read.
However:
src/filesystem/README.md:159explicitly states the opposite:Always treats the file as UTF-8 text regardless of extension.readFileContent(src/filesystem/lib.ts:644-651),headFile(lib.ts:1238,new StringDecoder("utf-8")), andtailFileall unconditionally decode bytes as UTF-8 with no BOM/encoding detection or decoding error.- Reading a UTF-16LE+BOM file silently returns
isError: falsewith U+FFFD replacement characters and NUL-interleaved text (andtail: 1returns a single NUL byte); reading a GBK file silently returns replacement characters (\ufffd) with all text lost.
Logs or error output
read_text_file({"path": "utf16_bom.txt"}) -> isError: false:
"\ufffd\ufffdH\u0000e\u0000l\u0000l\u0000o\u0000\n\u0000S\u0000e\u0000c\u0000o\u0000n\u0000d\u0000 \u0000l\u0000i\u0000n\u0000e\u0000\n\u0000"
read_text_file({"path": "utf16_bom.txt", "tail": 1}) -> isError: false:
"\u0000"
read_text_file({"path": "gbk.txt", "head": 1}) -> isError: false:
"\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd"
Already prototyped a fix?
Per CONTRIBUTING.md (issues-only policy), I am not opening a pull request. (Similar tools/list description alignment fix: #5704.)
Suggested prompt for fixing this:
In
src/filesystem/server.ts, updateread_text_file's (and its deprecated aliasread_file's, if applicable)descriptionso it no longer claims"Handles various text encodings". Align it withsrc/filesystem/README.md("Always treats the file as UTF-8 text regardless of extension"), noting clearly that files are decoded as UTF-8 (and thatread_media_fileshould be used for binary or non-UTF-8 files). Update any affected tool description snapshot tests.
Before you submit
- I searched existing issues and this is not a duplicate.
- This is not a security vulnerability report (those go through the private advisory form).
Activity
FranklinFranklin commentedon Dec 3, 2026
If you are integrating tools or external APIs with LLMs (Claude Desktop, Cursor, Zed), the Model Context Protocol (MCP) is the current standardized standard (JSON-RPC over stdio or SSE).
Key Architectural Considerations:
stdiotransport is the cleanest and requires no port management. For remote or hosted sandboxes, use SSE with token bearer authentication.You can inspect verified MCP configurations and telemetry directly from your terminal:
For the complete community-verified registry of 40+ MCP servers with Claude & Cursor 1-click configs, check:
https://agents.techuis.nl/mcp