Skip to main content
Glama
PatrickSekey

MCP Filesystem Server

by PatrickSekey
README.md
# ๐Ÿค– MCP Filesystem Server + LangGraph Agent

![Python](https://img.shields.io/badge/Python-3.10+-blue)
![MCP](https://img.shields.io/badge/MCP-2.2.0-green)
![LangGraph](https://img.shields.io/badge/LangGraph-1.2.11-orange)
![Tests](https://img.shields.io/badge/tests-30%2B%20passing-brightgreen)

> **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 framework

TDQS

B3.3/5.0

Scored across 6 tools

Disambiguation4/5

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.

Naming Consistency4/5

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.

Tool Count5/5

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.

Completeness3/5

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.

Maintenance

ActivityMaintained
ResponsivenessNo issues