MCP File Reader
MCP 文件阅读器
一个完全本地、免费的 AI 文件阅读器,使用 MCP (Model Context Protocol) 将 Python 工具服务器与本地 LLM (Ollama + Mistral) 连接起来。无需 API 密钥,无需云端,无需费用——完全在您的机器上运行。
🧾 功能
带有自定义工具 (
list_files,read_file) 的 MCP 服务器通过 Ollama (Mistral / Llama3.2) 集成本地 LLM
自动文件发现和内容读取
基于 AI 的文件内容摘要
路径遍历保护(内置安全性)
零成本——无需 API 密钥或订阅
🛠️ 技术栈
技术 | 描述 |
Python | 服务器和客户端的核心语言 |
MCP | 模型上下文协议(工具服务器) |
Ollama | 本地 LLM 运行时(免费、离线) |
Mistral | 用于摘要的本地 AI 模型 |
asyncio | 客户端/服务器之间的异步通信 |
requests | 对 Ollama API 的 HTTP 调用 |
📦 安装
git clone https://github.com/JaneKarunyaJ/MCP-File-Reader.git
cd MCP-File-Reader
pip install mcp requests从 https://ollama.com 安装 Ollama,然后拉取模型:
ollama pull mistral🚀 使用方法
确保 Ollama 正在运行(安装后会自动启动),然后:
python client.py客户端将:
将 MCP 服务器作为子进程启动
调用
list_files以发现my_files/中的文件为找到的每个文件调用
read_file将实际内容发送给 Mistral 进行摘要
📁 项目结构
MCP-File-Reader/
│
├── server.py # MCP server — exposes list_files and read_file tools
├── client.py # MCP client — calls tools and queries Ollama
├── requirements.txt # Python dependencies
└── my_files/ # Folder the AI is allowed to read
├── project_ideas.txt
└── wishlist.txt🔐 安全性
MCP 服务器仅允许从
my_files/目录读取路径遍历攻击(例如
../../etc/passwd)会被自动拦截没有数据离开您的机器——设置后完全离线
🧠 工作原理
client.py
│
├── Step 1: Calls MCP tool → list_files()
│ ↓
│ Returns filenames from my_files/
│
├── Step 2: Calls MCP tool → read_file(filename)
│ ↓
│ Returns actual file contents
│
└── Step 3: Sends real content to Ollama (Mistral)
↓
Returns AI summary➕ 扩展项目
添加您自己的文件:将任何
.txt文件放入my_files/并再次运行添加新工具:在
server.py中添加新的工具处理程序(例如search_in_file,write_file)更改问题:编辑
client.py中的user_question以询问有关文件的任何内容更换模型:将
client.py中的MODEL = "mistral"更改为您在 Ollama 中拉取的任何模型
📋 要求
Python 3.9+
已安装 Ollama (ollama.com)
已拉取 Mistral 模型 (
ollama pull mistral)mcp和requestsPython 包
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/JaneKarunyaJ/MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server