Filesystem MCP Server

Filesystem MCP Server

Enables AI agents to interact with a sandboxed filesystem via MCP tools for reading, writing, searching, and monitoring files, including batch processing and resource discovery for resume management.

Category
访问服务器

README

mcp-integration

MCP integration

This repository implements the assignment described below. For build, run, and design details of the implementation, jump to the Implementation & Usage Guide further down this file — all documentation lives in docs/ (start at docs/README.md): docs/design/ARCHITECTURE.md, docs/design/HLD.md, docs/design/LLD.md, docs/project/PROJECT_STRUCTURE.md, docs/guides/DEMO_SCRIPT.md.

Brief

Learning Objectives

  • Understand Model Context Protocol
  • Replace custom tools with MCP servers
  • Implement standardized tool interfaces
  • Deploy production-ready systems

Assignment Requirements

Part A: MCP Server Implementation (50%)

Create filesystem_mcp_server.py:

  • Convert File System Tools to MCP
  • Implement MCP protocol specification
  • Expose all Milestone 1 tools as MCP resources
  • Add new MCP-specific capabilities:
    • watch_directory() - Monitor for new resumes
    • batch_process() - Handle multiple files efficiently

MCP Server Features

  • JSON-RPC 2.0 compliant interface
  • Proper error handling and status codes
  • Resource discovery endpoints
  • Configuration management

Part B: Agent Refactoring (30%)

Update matching_agent.py:

  • Replace Custom Tools
    • Remove direct file system tools
    • Connect to MCP server via client
    • Maintain same functionality with cleaner architecture

Multi-MCP Integration (Bonus)

  • Connect to additional MCP servers (e.g., web search, database)
  • Demonstrate agent using multiple MCP resources

Submission Guidelines

Deliverables

  • MCP-based filesystem server implementation (filesystem_mcp_server.py)
  • Refactored LangGraph agent with MCP client integration (matching_agent.py)
  • JSON-RPC 2.0 compliant MCP server with resource discovery
  • Implementation of watch_directory() and batch_process() capabilities
  • State machine/workflow diagram of agent ↔ MCP interaction
  • Test scenarios demonstrating MCP resource usage and agent workflow
  • Demo video (5–6 minutes) showing MCP server, agent integration, and end-to-end execution


Implementation & Usage Guide

Everything below documents how this repository fulfils the assignment above — architecture, how to install/run, the MCP surface, configuration, testing, and how prior feedback was incorporated.

An enterprise, production-oriented implementation of an MCP-based resume/profile matching system, delivered in two parts:

  • Part A — MCP Server (filesystem_mcp_server.py): a JSON-RPC 2.0 Model Context Protocol server that exposes the Milestone-1 filesystem tools as MCP tools, adds the MCP-specific watch_directory and batch_process capabilities, and publishes resume documents as discoverable MCP resources.
  • Part B — Matching Agent (matching_agent.py): a LangGraph agent that connects to the MCP server(s) as a client (no direct filesystem access), retrieves candidate evidence through a RAG pipeline, and produces a ranked, justified shortlist using Claude — with durable state, retries, and full observability.

Domain. This continues the resume/profile-matching line from the prior milestones (File System Tools → RAG Profile Matching → Agentic Profile Matching). Resumes land in a directory; the agent matches candidates to a job description.


Architecture at a glance

                         ┌──────────────────────────────────────────────┐
                         │                Matching Agent (Part B)         │
   Job description ─────▶ │  LangGraph state machine                       │
   Resumes dir           │   load_job → discover → ingest → retrieve →     │
                         │   rank(Claude) → report                         │
                         │                                                │
                         │   RAG pipeline   ┌──────────────┐              │
                         │   (extract →     │  Vector store │ (external,   │
                         │    chunk →       │  Chroma/disk  │  on-disk)    │
                         │    embed) ──────▶└──────────────┘              │
                         │        ▲                                        │
                         │        │ MCP client (langchain-mcp-adapters)    │
                         └────────┼───────────────────────────────────────┘
                                  │ JSON-RPC 2.0 over stdio / HTTP
                         ┌────────┴───────────────────────────────────────┐
                         │              MCP Server (Part A)               │
                         │  FastMCP · tools + resources · sandboxed FS    │
                         │  read_file · write_file · list_directory ·     │
                         │  file_exists · get_file_metadata · search_files│
                         │  watch_directory · batch_process · metrics     │
                         └────────────────────────────────────────────────┘
                                  │
                         ┌────────┴────────┐
                         │  Sandbox (data/) │  resumes/  jobs/  reports/
                         └─────────────────┘

Full detail: docs/design/ARCHITECTURE.md · docs/design/HLD.md · docs/design/LLD.md · docs/project/PROJECT_STRUCTURE.md · workflow state machine: docs/diagrams/workflow.md.


Quickstart

1. Install

Always install into a project virtualenv (keeps the global environment clean and avoids unrelated global pytest-plugin clashes):

python -m venv .venv
. .venv/Scripts/activate          # Windows PowerShell: .venv\Scripts\Activate.ps1
python -m pip install -U pip

pip install -e ".[dev]"           # base + dev tools — light, no torch; offline path works
cp .env.example .env              # then edit as needed

The base install is deliberately small (no torch/chromadb). For the recommended production configuration — local sentence-transformers embeddings and a persistent Chroma store — add the extras:

pip install -e ".[full]"          # sentence-transformers + chromadb
# or individually: pip install -e ".[local]"   /   pip install -e ".[chroma]"

Without the extras the system runs on the offline path (hash embedder + disk store) and logs a one-line hint pointing at .[local].

Installing from a private index (e.g. AWS CodeArtifact): pip uses whatever index-url your pip config / environment defines — no special flags needed. Just ensure your CodeArtifact auth token is current (aws codeartifact login --tool pip …) before installing. To pin the public index instead: pip install -e ".[dev]" --index-url https://pypi.org/simple/.

2. Seed sample data (optional — samples are committed)

python scripts/seed_data.py --root ./data

3a. Run the agent (recommended — it launches the MCP server for you)

The agent, in mcp gateway mode, spawns the Part A server as a subprocess and talks to it over MCP. This is the full Part A + Part B path:

python matching_agent.py --job jobs/backend_engineer.md --resumes-dir resumes --top-n 3

Set ANTHROPIC_API_KEY for Claude-grade reasoning. Without a key it runs fully offline (deterministic stub reasoner + local/hash embeddings), so the whole system is demonstrable with zero external dependencies.

3b. Run the MCP server standalone

python filesystem_mcp_server.py                        # stdio (for MCP clients)
PM_MCP__TRANSPORT=streamable-http python filesystem_mcp_server.py   # networked

Fully-offline run (no API key, no model downloads, no network)

PM_EMBEDDING__PROVIDER=hash PM_VECTOR_STORE__PROVIDER=disk PM_LLM__FORCE_STUB=true \
python matching_agent.py --job jobs/backend_engineer.md --resumes-dir resumes --top-n 3

MCP surface (Part A)

Tools

Tool Purpose New?
read_file Read a text file from the sandbox Milestone 1
write_file Write a file (creates parents) Milestone 1
list_directory List entries + metadata Milestone 1
file_exists Presence check (never raises on escape) Milestone 1
get_file_metadata size / type / mtime Milestone 1
search_files Glob search (*.pdf, …) Milestone 1
watch_directory Monitor for new resumes (blocks until added / timeout) New (MCP-specific)
batch_process Process many files (read / metadata / exists / extract_text) with per-item error capture New (MCP-specific)
server_metrics In-process metrics snapshot Ops

Every tool returns a stable contract: {"ok": true, "result": …} or {"ok": false, "error": {"code", "message", "kind"}} — JSON-RPC error codes mapped in errors.py, so the client branches programmatically instead of parsing prose.

Resources (discovery)

URI Description
resumes://index JSON index of all resume documents in the sandbox
resume://{path} Text content of one resume
config://server Non-sensitive server config for capability discovery

Configuration

All configuration is typed (src/profile_matcher/config.py, pydantic-settings) and driven by PM_-prefixed env vars with __ nesting. See .env.example for the full list. Highlights:

Variable Default Meaning
PM_LLM__MODEL claude-opus-4-8 Claude model for ranking
PM_EMBEDDING__PROVIDER local local / voyage / openai / hash
PM_VECTOR_STORE__PROVIDER chroma chroma (persistent) / disk
PM_MCP__SANDBOX_ROOT ./data Filesystem sandbox root
PM_MCP__TRANSPORT stdio stdio / streamable-http / sse
PM_CHECKPOINT__BACKEND sqlite Durable agent state backend

Testing

pip install -e ".[dev]"
pytest                       # unit + agent tests (offline)
pytest -m integration        # real MCP subprocess end-to-end

Note (shared machines): if an unrelated global pytest plugin breaks collection, isolate the run: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -p pytest_asyncio.plugin.

The suite is fully offline (hash embedder + disk store + stub reasoner). Current status: 38 passing.

Run the embedding ablation study (feedback A):

python scripts/ablation.py --providers hash            # offline
python scripts/ablation.py --providers hash local      # add sentence-transformers

Assignment mapping

Requirement Where
Part Afilesystem_mcp_server.py repo root → src/profile_matcher/mcp_server/
Convert FS tools to MCP; JSON-RPC 2.0 mcp_server/server.py (FastMCP), errors.py (JSON-RPC codes)
Expose Milestone-1 tools as MCP resources/tools server.py tools + resources
watch_directory() server.py::watch_directory (+ _await_new_files)
batch_process() server.py::batch_process (+ _run_single)
Error handling / status codes errors.py, {ok,error} tool contract
Resource discovery endpoints resumes://index, resume://{path}, config://server
Configuration management config.py (pydantic-settings), .env.example
Part Bmatching_agent.py repo root → src/profile_matcher/agent/
Remove direct FS tools; connect via MCP client agent/gateway.py::McpClientGateway
Same functionality, cleaner architecture agent/graph.py state machine + dependency inversion
Bonus — Multi-MCP integration gateway.py extra_servers (see ARCHITECTURE.md)
Deliverables — JSON-RPC 2.0 server w/ discovery Part A
State machine / workflow diagram docs/diagrams/workflow.md
Test scenarios tests/ (unit + integration)
Docs (ARCHITECTURE/HLD/LLD/PLAN/STRUCTURE) see Documentation
Demo video (5–6 min) see docs/guides/DEMO_SCRIPT.md for the walkthrough script

How prior feedback was addressed

  • RAG (extractor & embedding validation + provider trade-offs). Extractors and embedders are pluggable behind protocols; scripts/ablation.py measures ranking quality (top-1, MRR, separation, cost) across providers, written up in docs/guides/ABLATION.md.
  • Agentic (state persistence, error handling, observability). Durable SQLite checkpointing; per-node structured error capture with graceful degradation; structured logging, tracing spans, metrics, and scoped retries with backoff — see docs/guides/OBSERVABILITY.md.

Documentation

All documentation lives under docs/; docs/README.md is the hub.

Doc Contents
docs/README.md Documentation index / hub (audience + reading order)
docs/design/ARCHITECTURE.md System architecture, components, data flow, decisions
docs/design/HLD.md High-level design: context, containers, sequences
docs/design/LLD.md Low-level design: modules, classes, contracts
docs/project/IMPLEMENTATION_PLAN.md Phased build plan & milestones
docs/project/PROJECT_STRUCTURE.md Full package/file hierarchy
docs/guides/ABLATION.md Extractor/embedding ablation & trade-offs
docs/guides/OBSERVABILITY.md Logging, tracing, metrics, retries
docs/diagrams/workflow.md Agent ↔ MCP workflow state machine
docs/guides/DEMO_SCRIPT.md 5–6 min demo walkthrough

License

Proprietary — coursework deliverable.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选