Skip to main content
Glama
PatrickSekey

MCP Filesystem Server

by PatrickSekey

🤖 MCP Filesystem Server + LangGraph Agent

Python MCP LangGraph Tests

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 Discoverytools/list, resources/list

  • 🔐 Security — allowed roots, size limits, format allowlist

Related MCP server: fsext-mcp-server-python

🏗️ Architecture

See 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

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

copy .env.example .env
# Edit .env and set OPENROUTER_API_KEY

3. Run the MCP server standalone

python -m mcp_filesystem_server

4. Run the LangGraph agent

python test_agent.py

5. Run the test suite

pytest tests/ -v

🔌 Connecting VSCode / Claude Desktop / Cursor

See docs/vscode_setup.md for full instructions.

Quick config:

{
  "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

Available Tools

6 tools
batch_processC

Process multiple files in a single call (read/stat/summary)

ParametersJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory containing files
max_filesNoMaximum files to process
operationNoOperation to performsummary
recursiveNoRecurse into subdirectories
extensionsNoFilter by extensions

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It never states that all three operations are read-only (which the enum implies but is not asserted), nor what happens when max_files truncates the set, how errors on individual files are reported, or whether recursion depth is bounded. Significant gaps for a batch tool touching a whole directory.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One short, front-loaded sentence with no padding. It is efficient, though the terseness contributes to the missing behavioral and usage detail rather than reflecting genuine completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a five-parameter batch tool with no annotations and no output schema, the description says almost nothing about how batching behaves, what the return shape is, or how truncation and per-file failures are surfaced. The schema covers parameter mechanics but the description leaves the operational picture incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so every parameter is already documented in the schema, and the description adds only the operation list that the enum already provides. Baseline 3 is appropriate – no extra semantics such as extension filter syntax or max_files interaction are supplied.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear verb-plus-resource ('Process multiple files') and the parenthetical enumerates the three operations, which distinguishes it from the single-file siblings read_file and list_files. 'Process' itself is somewhat generic, but the batching scope is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use guidance and no mention of the alternatives (read_file for one file, list_files for enumeration). The batch framing implies the use case, but the agent must infer it rather than being routed to this tool over its siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_filesC

List files in a directory with optional extension filtering

ParametersJSON Schema
NameRequiredDescriptionDefault
directoryNoDirectory to list.
recursiveNoRecurse into subdirectories
extensionsNoFilter by extensions e.g. ['.pdf', '.txt']
max_resultsNoMaximum results to return

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure and falls short: it doesn't say what happens on a nonexistent directory, whether hidden files are included, what ordering is used, or whether results are truncated at max_results. Neither the default directory ('.') nor the recursive traversal caveat is surfaced in the description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler. It is efficient, though the brevity is partly the source of the specification gaps noted elsewhere.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter tool with no annotations and no output schema, the description omits the return shape (paths vs. objects), behavior when max_results truncates, and error/edge-case handling. An agent could invoke it, but not predict its output or limits.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so directory, recursive, extensions, and max_results are already documented in the schema, including the extension-format example. The description adds no semantics beyond what the schema provides, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ('List files in a directory') and adds the scoping qualifier 'with optional extension filtering'. It is clear on its own, but does not distinguish itself from siblings such as search_in_file or watch_directory, so an agent must infer the boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus search_in_file (content search), read_file, or watch_directory. No prerequisites, exclusions, or conditions are stated; usage is only implied by the name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_fileC

Read PDF, TXT, DOCX, MD, JSON files with rich metadata

ParametersJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the file to read

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden, yet it only hints at 'rich metadata' without describing the return shape. It says nothing about encoding, file-size limits, binary handling, error behavior for unsupported formats, or permission requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, front-loaded sentence with no wasted words; the verb and supported formats appear immediately. It is efficient, though the trailing 'with rich metadata' phrase is somewhat vague rather than informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-parameter read tool with no output schema and low complexity, this is roughly adequate. Missing behavioral detail (error handling, size limits, metadata contents) is somewhat excused by the tool's simplicity but leaves gaps an agent would benefit from.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% for the single file_path parameter, so the schema already documents it. The description adds no path format or relative/absolute semantics beyond what the schema provides, making the baseline 3 appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Read') and resource ('files') and enumerates supported formats (PDF, TXT, DOCX, MD, JSON). It implicitly distinguishes itself from write_file, list_files, and search_in_file by being the content-retrieval tool, though it never names those siblings explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this versus search_in_file (reading to search vs reading to view) or how it relates to batch_process. No exclusions, no prerequisites, no context for choosing this over alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_in_fileA

Search for a query inside a file, returning matches with context

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
file_pathYesFile to search
max_resultsNoMaximum matches to return
context_linesNoLines of context around each match
case_sensitiveNoCase-sensitive search

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that matches are returned with context, which is behavioral value, but says nothing about read-only nature, behavior on no matches, large/binary file handling, or whether the query is literal versus a regex/pattern.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler: verb, resource, and output shape. Every clause earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no annotations and no output schema, the description covers the essentials but leaves gaps an agent would want: matching semantics (literal vs regex), what happens when nothing matches, and how very large files are handled. Adequate, not complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and all five parameters (query, file_path, max_results, context_lines, case_sensitive) carry their own descriptions with defaults. The description adds no syntax, matching-mode, or default information beyond the schema, so the baseline of 3 is correct.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (search), resource (a file), and the key input (a query), plus the shape of the result. An agent can tell it apart from read_file and list_files by the search semantics, though no sibling is named explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the name and description — find text within one file — but there is no explicit when-to-use guidance, no mention of when read_file (fetch the whole file) or batch_process (multi-file scanning) would be preferable, and no preconditions such as the file needing to exist.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

watch_directoryC

Watch a directory for changes over a fixed duration (MCP-bound watcher)

ParametersJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory to watch
extensionsNoFilter by extensions e.g. ['.pdf']
poll_intervalNoPolling interval in seconds
duration_secondsNoHow long to watch

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden and largely fails: it does not say whether the call blocks for the whole duration, what it returns (no output schema exists), how it behaves on timeout, or whether it reports a change count or event list. The parenthetical '(MCP-bound watcher)' is jargon that adds little operational meaning.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence with the key constraint (fixed duration) front-loaded and no wasted clauses. The trailing '(MCP-bound watcher)' parenthetical is the one element that does not clearly earn its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a blocking, no-annotations, no-output-schema tool, the description is too thin: an agent cannot tell what it receives back, whether the call hangs for the duration, or how changes are surfaced. The schema covers inputs, but the behavioral contract of a watcher is left unspecified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so directory, extensions, poll_interval, and duration_seconds are all documented in the schema itself. The description adds no syntax, units, or default details beyond what the schema already provides, making the baseline 3 appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Watch') and resource ('directory') and adds scope ('over a fixed duration'), so an agent can distinguish it from read_file/list_files/write_file. It does not explicitly name a sibling or contrast itself with them, but the watcher semantics are unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No when-to-use guidance, no prerequisites, and no alternatives are named among the five siblings. The phrase 'over a fixed duration' implies the tool is bounded rather than long-lived, but the agent must infer when polling a directory is preferable to list_files or search_in_file.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

write_fileC

Write content to a file with automatic directory creation

ParametersJSON Schema
NameRequiredDescriptionDefault
contentYesContent to write
file_pathYesTarget file path
overwriteNoAllow overwriting existing files
create_dirsNoAuto-create parent directories

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are supplied, so the description carries the full behavioral burden. It states automatic directory creation (which the schema's create_dirs default already implies) but says nothing about what happens when the target file already exists, whether writes are atomic/truncating, or what errors to expect.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler. It is terse to the point of under-specification, but nothing is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter write tool with no annotations and no output schema, the description omits critical context: the overwrite/error behavior, return value, and any destructive implications of overwriting existing content. An agent cannot tell from the description alone how to write safely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all four parameters are already documented, including the defaults for overwrite and create_dirs. The description adds no parameter-level meaning beyond the schema, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb+resource ('Write content to a file') and adds a scope note about directory creation. It does not distinguish itself from siblings like batch_process, though the read-oriented siblings make the write role fairly evident.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use write_file versus alternatives such as batch_process or when not to use it. There is no mention of prerequisites, permissions, or the fact that an existing file will fail unless overwrite is set.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updatesv0.1.0
    • First observedbatch_process
    • First observedlist_files
    • First observedread_file
    • First observedsearch_in_file
    • First observedwatch_directory
    • First observedwrite_file

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

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A lightweight, stdio-based MCP server enabling AI assistants to perform local file system operations like reading, writing, searching, and executing commands.
    2,994 npm
    MIT
  • A
    license
    C
    quality
    B
    maintenance
    A full-featured secure MCP server for local file system operations, with built-in image processing, OCR and media tools. Fully compliant with the official Model Context Protocol specification, offering standardized request/response schemas, large-file streaming I/O, multi-transport remote deployment, and comprehensive text search & replace functionality for LLM agent integration.
    22
    Apache 2.0
  • A
    license
    Not graded
    quality
    A
    maintenance
    The fastest, most capable filesystem MCP server built in Rust, giving AI agents superpowers to read, search, edit, and manage files and directories.
    11
    Apache 2.0