Add Claude Code Filesystem MCP server#49
Add Claude Code Filesystem MCP server#49matteo8p wants to merge 1 commit intoMercor-Intelligence:mainfrom
Conversation
| "headers": null, | ||
| "transport": "stdio" | ||
| }, | ||
| "claude_code_filesystem": { |
There was a problem hiding this comment.
This ensures that our cc filesystem MCP server is spun up during testing.
| from loguru import logger | ||
|
|
||
|
|
||
| class LoggingMiddleware(Middleware): |
There was a problem hiding this comment.
Copied over from other MCP servers.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Reviewed by Cursor Bugbot for commit 77919eb. Configure here.
| elif recursive: | ||
| for dirpath, _dirs, files in os.walk(root, followlinks=False): | ||
| real_dir = os.path.realpath(dirpath) | ||
| if not real_dir.startswith(real_fs_root): |
There was a problem hiding this comment.
Missing os.sep in sandbox path traversal check
High Severity
The sandbox boundary check real_dir.startswith(real_fs_root) is missing + os.sep, unlike the correct checks in glob.py (real_fs_root + os.sep) and path_utils.py (root + os.sep). This means a path like /filesystemx/... would incorrectly pass the check when real_fs_root is /filesystem, because Python's startswith matches the prefix without requiring a path separator boundary.
Reviewed by Cursor Bugbot for commit 77919eb. Configure here.
|
|
||
| try: | ||
| await asyncio.wait_for(_read_lines(), timeout=timeout) | ||
| await proc.wait() |
There was a problem hiding this comment.
proc.wait() can hang indefinitely without timeout
High Severity
The await proc.wait() on line 63 is outside the asyncio.wait_for scope, so it has no timeout protection. If a process closes stdout (ending _read_lines) but continues running, proc.wait() blocks forever. This is especially likely for the long-running processes this tool is designed for (servers, build watchers).
Reviewed by Cursor Bugbot for commit 77919eb. Configure here.
| include: Annotated[ | ||
| str, | ||
| Field( | ||
| description="Glob pattern to filter which files are searched. Default: '*' (all files). Example: '*.py', '*.{js,ts}'." |
There was a problem hiding this comment.
Grep include example uses unsupported brace expansion
Medium Severity
The include parameter description gives '*.{js,ts}' as an example, but fnmatch.fnmatch does not support brace expansion — curly braces are treated as literal characters. Using this documented example would silently match zero files, causing the grep to return no results even when matching files exist. The existing search_files tool in filesystem_server correctly avoids brace expansion examples in its description.
Reviewed by Cursor Bugbot for commit 77919eb. Configure here.
|
TODO: I was able to ask Claude what it's tool schemas are for all of the default tools. Bash: Edit Glob Grep Read Write Monitor |
|
Looks great! Cursor comments are minor, do you think you could create a claude code agent that connects to it now? |




Overview
In this PR, we add the MCP server that exposes Claude Code's bash/read/write tools from the sandbox environment. Tools that this MCP server exposes:
bash,read,write,edit,monitor,glob,grep.Keep in mind that Claude Code's filesystem tools are not public, and these MCP servers are approximations as to how they would work in a production environment. Read design doc below to learn more about tradeoffs.
Read the design doc for more context.
In the next PR, we will create the Claude Code agent that connects to this sandbox MCP server.
Testing
I did a manual and E2E test using MCPJam. I ensured that the MCP server properly exposes these MCP server tools, and that a test agent can properly use these tools to manipulate the test environment's filesystem.