fs-mcp
fs-mcp
一个微型的 MCP 服务器,提供六个工具:
explore_filesystem(subpath?, glob?)— 列出根目录下的文件/文件夹,可选地按 glob 过滤(如**/*.js)。edit_file(path, edits[], createIfMissing?)— 对根目录下的文件应用 git 风格的行编辑(替换/插入/删除行范围)。create_file(path, content?, overwrite?)— 创建新文件,可选内容,必要时创建父目录。delete_file(path, recursive?)— 删除根目录下的文件或目录(对非空目录可选递归删除)。read_file(path, startLine?, endLine?)— 读取文件内容,可选地限定行范围,并带行号前缀。grep(pattern, glob?, useRegex?, caseInsensitive?)— 在文件中搜索文本模式,可选正则支持与 glob 过滤。
根目录 = 进程启动时的工作目录。
作为全局 CLI 安装
npm install
npm link # or: npm install -g .这会给你一个全局的 fs-mcp 命令(通过 package.json 中的 bin 字段配置)。
Related MCP server: LocalFS MCP Server
运行
fs-mcp # stdio mode (default) — for Claude Desktop/Code,
# which spawn the process themselves
fs-mcp --http # HTTP mode on http://localhost:4823/mcp — for
# curl, the MCP Inspector, or the on-demand
# Claude Desktop setup below
fs-mcp --http -p 5000 # custom port
fs-mcp --help你运行它时所在的文件夹即为暴露的根目录。
连接到 Claude Desktop
Claude Desktop 会自行启动 MCP 服务器并通过 stdio 通信——它不会继承你终端的当前目录。这给了你两种配置方式,取决于你的使用习惯:
方式 A — 从任意文件夹按需启动(如果你喜欢 CLI 的感觉,推荐此方式)
只需配置 Desktop 一次,指向一个固定的本地端口,而不是固定的文件夹。参见 claude_desktop_config.example.json——将其中的 "fs-mcp" 条目合并到你现有的 mcpServers 对象中,位置在:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
重启 Claude Desktop 一次。之后:
cd ~/whatever/project
fs-mcp --http那个文件夹就是 Claude 能看到的内容,只要服务器在运行。按 Ctrl+C 停止,然后在不同文件夹中重新启动即可切换上下文——无需再修改 Desktop 配置。
注意:需要 --allow-http,因为 mcp-remote(stdio↔HTTP 桥接)默认期望真实远程服务器使用 HTTPS + OAuth;此标志告诉它普通的未认证 localhost 流量也是可以的。
方式 B — 一个固定文件夹,始终可用
如果你希望 Desktop 始终暴露同一个项目,而不必手动启动任何东西:
{
"mcpServers": {
"fs-mcp": {
"command": "fs-mcp",
"cwd": "/absolute/path/to/the/folder/you/want/exposed"
}
}
}重启 Desktop。这直接使用 stdio 模式——无需代理,无需手动执行 fs-mcp --http 步骤——但更改暴露的文件夹需要编辑此配置并再次重启 Desktop。
安全说明
每个路径都会相对于根目录解析,如果试图越界(如
../../etc/passwd)则会被拒绝——已通过路径穿越测试验证。没有认证机制。任何能访问到服务器(在
--http模式下为任何本地进程)的东西都可以读写根目录下的任何文件。仅适用于可信的本地开发环境;不要在敏感环境中运行,也不要绑定到localhost之外。
编辑语义(edit_file)
编辑操作是 {startLine, endLine, newLines},从 1 开始计数,包含两端:
替换第 3–5 行:
{startLine: 3, endLine: 5, newLines: ["new content"]}删除第 3–5 行:
{startLine: 3, endLine: 5, newLines: []}在第 6 行之前插入(无删除):
{startLine: 6, endLine: 5, newLines: ["inserted"]}
一次调用中的多个编辑会从底部向上依次应用,因此编辑列表中的行号不会因先前的编辑而偏移。
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
- AlicenseNot gradedqualityAmaintenanceEnables reading, creating, and editing files on the local filesystem through operations like view, create, string replacement, and line insertion.1613MIT
- FlicenseNot gradedqualityDmaintenanceProvides sandboxed access to local filesystem operations including directory and file management, content search with glob and regex patterns, and binary file support with configurable safety limits.
- FlicenseNot gradedqualityDmaintenanceEnables file system operations such as listing, reading, and creating files within a scoped local project directory. It provides a secure way to manage local files through standardized MCP tools built with FastMCP.
- FlicenseAqualityDmaintenanceEnables listing, reading, and searching local files and directories through MCP tools.4
Related MCP Connectors
Securely search and manage workspace context files for AI agents and teams.
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
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/Polarts/fs-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server