MCP 本地文件阅读器是一个基于 Model Context Protocol (MCP) 的本地文件读取服务器,它能让 AI 模型安全地访问本地文件系统,为 AI 与本地文件交互提供了便利。
read_file
- 读取指定文件的内容:
list_files
- 列出指定目录中的所有文件:
get_file_info
- 获取指定文件的详细信息:
npm install mcp-local-file-reader
安装后,可直接在命令行中运行:
npx mcp-local-file-reader
此时会启动一个 MCP 节点服务器,监听 LLM 对话。
在 Windsurf 中,无需手动启动 mcp-local-file-reader
,只需进行配置,Windsurf 会自动启动它(在 Windsurf 的 mcp_config.json
中配置,点击 refresh 刷新服务器)。
mcp_config.json
配置文件中添加以下配置(暂时不需要 FILE_TOOLS_API_KEY
):
{
"servers": {
"file-tools": {
"command": "cmd",
"args": [
"/c",
"node",
"path/to/mcp-local-file-reader/build/index.js"
],
"env": {
"FILE_TOOLS_API_KEY": ""
}
}
}
}
- **使用 npm 部署**
{
"servers": {
"file-tools": {
"command": "cmd",
"args": [
"/c",
"npx",
"mcp-local-file-reader"
],
"env": {
"FILE_TOOLS_API_KEY": ""
}
}
}
}
点击 Windsurf 对话框中的锤子图标,然后点击 refresh 刷新服务器。 官方配置说明:https://docs.codeium.com/windsurf/mcp 2. 重启 Windsurf 以加载新的 MCP 配置。
按照特定应用的 MCP 集成指南,添加此服务器作为工具提供者。在 cursor 的配置与 Windsurf 中的配置类似,在 VSCode 中可能会稍微复杂一些。但本质上都是配置 mcp.json
,可以参考类似的配置。
npm install
npm run build
npm run watch
npm run inspector
本项目采用 MIT 许可证。
⚠️ 重要提示
此服务器允许 AI 模型访问本地文件系统,请谨慎使用并确保: