内容
# MCP Filesystem
一个模型上下文协议 (MCP) 服务器,它为工作目录中的每个文件公开资源并发送更改通知。
## Status
⚠️ Pre-beta Quality ⚠️
“它在我的机器上可以工作”。欢迎提出 Issues ❤️
## Features
- **Resources**: 为您的工作区中的每个文件创建一个 MCP 资源
- **Gitignore Support**: 遵循 `.gitignore` 规则
- **Change Notification**: 检测文件更改、添加和删除
- **MIME Type Detection and Encoding Handling**: 识别文件类型并处理各种文本编码
## Setup
安装 Go:按照 <https://golang.org/doc/install> 上的说明进行操作
获取或更新此服务器:
```bash
go install github.com/isaacphi/mcp-filesystem@latest
```
将以下内容添加到您的客户端配置中(对于 Claude Desktop,位于 `~/Library/Application Support/Claude/claude_desktop_config.json`):
```json
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem",
"args": ["--workspace", "/path/to/your/repository"]
}
}
}
```
将 `/path/to/your/repository` 替换为您项目目录的绝对路径。
## Usage
您的客户端将能够访问和引用您的存储库中所有未忽略的文件作为 MCP 资源。每个文件都注册为单独的资源,并具有适当的 MIME 类型检测。
### Client Requirements
您的客户端需要支持以下 MCP 功能:
- Resource Listing: 列出和访问服务器公开的资源的能力
- Change Notifications: 支持接收 `notifications/resources/list_changed` 事件
- Resource Content Access: 能够请求和呈现具有适当 MIME 类型的资源内容
## About
本项目使用:
- [mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) 用于 MCP 通信
- [fsnotify](https://github.com/fsnotify/fsnotify) 用于文件系统事件监控
- [go-gitignore](https://github.com/sabhiram/go-gitignore) 用于解析 `.gitignore` 文件
## Development
克隆存储库:
```bash
git clone https://github.com/isaacphi/mcp-filesystem.git
cd mcp-filesystem
```
安装依赖项:
```bash
go mod download
```
构建:
```bash
go build
```
配置您的客户端以使用您的本地构建:
```json
{
"mcpServers": {
"filesystem": {
"command": "/full/path/to/your/mcp-filesystem/mcp-filesystem",
"args": ["--workspace", "/path/to/repository"],
"env": {
"DEBUG": "1"
}
}
}
}
```
## Feedback
请提交包含尽可能多详细信息的 Issues。
设置 `DEBUG` 环境变量以启用详细日志记录:
```json
"env": {
"DEBUG": "1"
}
```
## Features on my radar
- [x] Resources for each file in workspace
- [x] .gitignore support
- [x] Change notifications
- [ ] Standardize MCP protocol use to work with more clients (Claude Desktop)
- [ ] Configurable support for line numbers
- [ ] Resource update subscriptions
- [ ] Additional ignore patterns (beyond `.gitignore`)
- [ ] Debounced notifications for high-volume file changes
- [ ] `info`, `create`, `edit`, and `delete` tools