MCP Filesystem Server
# ๐ค MCP Filesystem Server + LangGraph Agent




> **A Model Context Protocol (MCP) filesystem server + LangGraph agent for agentic resume matching.**
## ๐ Overview
This project converts a traditional filesystem toolbox into a **standardized MCP server** that any MCP-compatible client (VSCode, Claude Desktop, Cursor) can connect to. It then demonstrates a real-world use case: a **LangGraph resume matching agent** that uses only MCP resources for filesystem access.
### Key Features
- ๐ **Full MCP Server** โ JSON-RPC 2.0 compliant, stdio transport
- ๐ ๏ธ **6 Filesystem Tools** โ read, list, write, search, watch, batch
- ๐ **Metrics Tracking** โ request counts, latencies, error codes
- ๐งช **30+ Tests** โ unit + integration scenarios
- ๐ค **LangGraph Agent** โ no direct filesystem access, all via MCP
- ๐ **Resource Discovery** โ `tools/list`, `resources/list`
- ๐ **Security** โ allowed roots, size limits, format allowlist
## ๐๏ธ Architecture
See [docs/state_machine.md](docs/state_machine.md) for the full state machine diagram.
```
โโโโโโโโโโโโโโโโโโ stdio โโโโโโโโโโโโโโโโโโโโโ
โ LangGraph โโโโโโโโโโโโโบโ MCP Server โ
โ Agent โ JSON-RPC โ (filesystem) โ
โ + MCP Client โ 2.0 โ 6 tools โ
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Filesystem โ
โ (allowed roots)โ
โโโโโโโโโโโโโโโโโโโ
```
## ๐ Quick Start
### 1. Install
```bash
git clone https://github.com/PatrickSekey/mcp-filesystem-server.git
cd mcp-filesystem-server
python -m venv venv
venv\Scripts\activate # Windows
pip install -e .
```
### 2. Configure
```bash
copy .env.example .env
# Edit .env and set OPENROUTER_API_KEY
```
### 3. Run the MCP server standalone
```bash
python -m mcp_filesystem_server
```
### 4. Run the LangGraph agent
```bash
python test_agent.py
```
### 5. Run the test suite
```bash
pytest tests/ -v
```
## ๐ Connecting VSCode / Claude Desktop / Cursor
See [docs/vscode_setup.md](docs/vscode_setup.md) for full instructions.
Quick config:
```json
{
"mcpServers": {
"filesystem": {
"command": "C:\\mcp-filesystem-server\\venv\\Scripts\\python.exe",
"args": ["-m", "mcp_filesystem_server"],
"cwd": "C:\\mcp-filesystem-server",
"env": { "PYTHONPATH": "C:\\mcp-filesystem-server\\src" }
}
}
}
```
## ๐ ๏ธ Tools Reference
| Tool | Description |
|------|-------------|
| **read_file** | Read PDF/TXT/DOCX/MD/JSON with metadata |
| **list_files** | List directory with extension filter |
| **write_file** | Write with auto-create + overwrite control |
| **search_in_file** | Case-sensitive/insensitive search with context |
| **watch_directory** โญ | Bounded directory watcher |
| **batch_process** โญ | Efficient multi-file processing |
## ๐งช Test Scenarios
8 scenarios in `tests/test_scenarios.py`:
1. Handshake and tool discovery
2. Read all resumes via MCP
3. Search for a skill inside a resume
4. Batch summary of resumes
5. Write + read round-trip
6. Bounded directory watch
7. Error handling (-32001 for missing file)
8. Full agent workflow via MCP
## ๐ Error Codes
| Code | Meaning |
|------|---------|
| -32700 | PARSE_ERROR |
| -32600 | INVALID_REQUEST |
| -32601 | METHOD_NOT_FOUND |
| -32602 | INVALID_PARAMS |
| -32603 | INTERNAL_ERROR |
| -32001 | FILE_NOT_FOUND |
| -32002 | FILE_ACCESS_DENIED |
| -32003 | UNSUPPORTED_FORMAT |
| -32004 | FILE_TOO_LARGE |
| -32005 | READ_ERROR |
| -32006 | WRITE_ERROR |
| -32007 | WATCH_ERROR |
| -32008 | BATCH_ERROR |
## ๐ Project Structure
```
mcp-filesystem-server/
โโโ src/mcp_filesystem_server/
โ โโโ server.py # Main MCP server
โ โโโ json_rpc.py # JSON-RPC 2.0 handler
โ โโโ resources.py # Tool discovery
โ โโโ errors.py # Error codes
โ โโโ metrics.py # Performance tracking
โ โโโ tools/ # 6 filesystem tools
โ โโโ mcp_client/ # Client wrapper
โ โโโ agent/ # LangGraph agent
โโโ tests/ # 30+ tests
โโโ examples/ # Sample resumes
โโโ docs/ # Diagrams + VSCode guide
โโโ README.md
```
## ๐ Assignment Deliverables
| Requirement | Status |
|-------------|--------|
| `filesystem_mcp_server.py` (converted to package) | โ
`src/mcp_filesystem_server/` |
| JSON-RPC 2.0 compliant | โ
`json_rpc.py` |
| Resource discovery endpoints | โ
`resources.py` |
| `watch_directory()` | โ
`tools/watch_directory.py` |
| `batch_process()` | โ
`tools/batch_process.py` |
| Refactored agent using MCP | โ
`agent/matching_agent.py` |
| State machine diagram | โ
`docs/state_machine.md` |
| Test scenarios | โ
`tests/test_scenarios.py` |
| Configuration management | โ
`config.py` + `.env` |
## ๐ License
Educational โ MCP Integration assignment.
## ๐ Acknowledgments
- [Anthropic MCP](https://modelcontextprotocol.io/) for the protocol
- [LangGraph](https://github.com/langchain-ai/langgraph) for the agent frameworkTDQS
Scored across 6 tools
Most tools target distinct actions (read, list, write, search, watch), but batch_process overlaps with read_file and list_files by performing multi-file reads and summaries, creating minor ambiguity about when to use it versus the single-file tools.
All names use snake_case and mostly follow a verb_noun pattern (read_file, list_files, write_file, search_in_file, watch_directory). batch_process deviates slightly from verb_noun order, but the convention remains readable.
Six tools is well-scoped for a filesystem server, with each tool covering a distinct operation (read, list, write, search, watch, batch) and no redundant endpoints.
Core read/write/search/list/watch workflows are present, but the filesystem surface lacks common operations like delete, move/rename, and copy. These are notable gaps for a general filesystem server.