MCP File System Agent
MCP 文件系统代理
一个基于 LangChain、Ollama、FastMCP 和 MCP 构建的本地 智能文件系统助手。
该项目演示了 LLM 如何自主选择并使用 MCP 服务器暴露的工具来执行文件相关操作,例如读取、列出、写入和搜索文件。
架构
User
│
▼
┌─────────────────┐
│ LangChain │
│ Agent │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Ollama LLM │
│ Qwen3 1.7B │
└────────┬────────┘
│
Tool selection
│
▼
┌──────────────────────┐
│ LangChain MCP Adapter│
└──────────┬───────────┘
│
MCP / HTTP
│
▼
┌──────────────────────┐
│ FastMCP Server │
│ localhost:8000/mcp │
└──────────┬───────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
read_file list_files write_file
│
▼
Local File SystemRelated MCP server: local-mcp
功能特性
基于 MCP 的工具架构
使用 HTTP 传输的本地 FastMCP 服务器
支持工具调用的 LangChain 代理
通过 Ollama 进行本地 LLM 推理
PDF 文件读取
DOCX 文件读写
带扩展名过滤的文件列表
在 PDF 和 DOCX 文件内搜索
使用 LangGraph 检查点机制实现对话状态管理
LLM 自动选择工具
技术栈
Python
LangChain
LangGraph
Ollama
Qwen3 1.7B
FastMCP
模型上下文协议(MCP)
langchain-mcp-adaptersPyPDF
python-docx
项目结构
MCP/
│
├── tests/
│ └── sample.docx
│
├── fs_mcp.py
├── main.py
├── requirements.txt
└── README.md安装
1. 克隆仓库
git clone https://github.com/jibixn/File-System-Tools-MCP
cd MCP2. 安装 Python 依赖
pip install -r requirements.txt3. 安装 Ollama
从官方网站安装 Ollama,并确保它在本地运行。
然后拉取模型:
ollama pull qwen3:1.7b您可以通过以下命令验证模型是否可用:
ollama list运行项目
该项目使用两个进程,因为 MCP 服务器通过 HTTP 与客户端通信。
终端 1 — 启动 MCP 服务器
在项目根目录下运行此命令:
python fs_mcp.py服务器应可在以下地址访问:
http://127.0.0.1:8000/mcp终端 2 — 启动代理
在项目根目录下打开另一个终端:
python main.py然后您可以输入如下请求:
Read the file in tests folder named sample.docx and provide me the summary.或:
List all PDF files in the tests folder.或:
Write "Hello, World!" to tests/output.docx.代理工作流程示例
对于如下请求:
Read the file in tests folder named sample.docx and provide me the summary.代理将执行以下操作:
User request
│
▼
LLM analyzes request
│
▼
LLM selects read_file
│
▼
LangChain MCP Adapter
│
▼
MCP HTTP request
│
▼
FastMCP read_file()
│
▼
python-docx reads file
│
▼
Tool result returned to agent
│
▼
LLM summarizes content
│
▼
Final response环境要求
建议使用 Python 3.11 或更高版本。
必须安装 Ollama 并在本地运行。
必须提供 Qwen 模型:
ollama pull qwen3:1.7b您也可以使用推理提供商提供的模型。
依赖项
项目的直接依赖项如下:
fastmcp==3.4.7
langchain==1.3.14
langchain-mcp-adapters==0.3.2
langchain-ollama==1.1.0
langgraph-checkpoint==4.2.0
pypdf==6.14.2
python-docx==1.2.0未来改进
支持更多文件格式
添加文件删除和目录创建工具
添加更强的路径验证和沙箱机制
为远程 MCP 服务器添加身份验证
添加流式响应
添加更丰富的文档解析
添加持久化对话存储
为数据库、GitHub 或网络搜索添加额外的 MCP 服务器
使用更大的本地模型提高工具选择的可靠性
学习目标
该项目演示了以下组件之间的交互:
LLM
↓
LangChain Agent
↓
Tool Calling
↓
MCP Client
↓
MCP Protocol
↓
FastMCP Server
↓
Python Functions它旨在作为使用模型上下文协议(MCP)和本地托管的 LLM 构建智能应用程序的实践示例。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceAutomates file system operations through natural language commands using a combination of LLM (Ollama), MCP tools, and a Python bridge agent.
- Alicense-qualityBmaintenanceA lightweight, stdio-based MCP server enabling AI assistants to perform local file system operations like reading, writing, searching, and executing commands.5,309MIT
- Alicense-qualityCmaintenanceA containerized MCP bridge that lets local or cloud LLMs access your filesystem and perform web searches via Ollama and FastMCP.MIT
- Alicense-qualityCmaintenanceExperimental MCP server for local LLM orchestration with filesystem tools (read, write, list, delete files) and a CLI agent that communicates via Ollama.9ISC
Related MCP Connectors
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jibixn/File-System-Tools-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server