mcpfs
将任何MCP服务器作为文件系统安装。通过阅读 cat,通过CLI写入。
运作原理
mcpfs连接到任何MCP服务器(stdio或HTTP),将其工具分为读取和写入,并将读取作为文件公开:
Agent / Shell mcpfs (FUSE) Any MCP Server
┌─────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ ls /mnt/... │─── readdir ─▶│ tools/list → │ │ PostHog, Stripe, │
│ cat file.json│─── read() ──▶│ classify → tree │── RPC ─▶│ GitHub, Linear, │
│ jq '.name' │◀── bytes ───│ tools/call │◀─ JSON ─│ or anything │
└─────────────┘ └──────────────────┘ └──────────────────┘
Agent / Shell mcpfs tool CLI
┌─────────────┐ ┌──────────────────┐
│ mcpfs tool │── flags ──▶│ parse CLI flags │── RPC ─▶ MCP Server
│ posthog │ │ tools/call │
│ create-flag │◀── JSON ───│ │◀─ JSON ─
└─────────────┘ └──────────────────┘分类规则:
list_*,get_all_*,没有必需的参数→ 文件 (dashboards.json)get_*,retrieve_*,需要参数→ 目录 (按ID查找)create_*,update_*,delete_*→ 仅限CLI (mcpfs tool)search_*,query_*→ 仅限CLI (mcpfs tool)
资源(如果服务器有)也作为文件挂载。
快速开始
# Build and install
go install github.com/airshelf/mcpfs/cmd/mcpfs@latest
# Auto-discover Claude Code plugins and mount in project dir
cd ~/src/myproject
mcpfs auto # mounts to .mcpfs/ in cwd
mcpfs auto --mount /mnt/mcpfs # or specify a custom mount dir
# Mount a single server
mcpfs .mcpfs/posthog --http https://mcp.posthog.com/mcp --auth "Bearer $POSTHOG_API_KEY"
mcpfs .mcpfs/stripe -- npx -y @stripe/mcp
# Read
ls .mcpfs/posthog/
cat .mcpfs/posthog/dashboards.json
cat .mcpfs/stripe/balance.json
# Write (CLI)
mcpfs tool posthog create-feature-flag --key my-flag --name "My Flag"
mcpfs tool stripe create_customer --name "Acme Corp" --email acme@example.com
# List all tools for a server
mcpfs tool posthog
mcpfs tool stripe
# Unmount
fusermount -u .mcpfs/posthog配置文件
从单个配置装载多个服务器(~/.config/mcpfs/servers.json):
{
"posthog": {
"type": "http",
"url": "https://mcp.posthog.com/mcp",
"headers": {"Authorization": "Bearer ${POSTHOG_API_KEY}"}
},
"stripe": {
"command": "npx",
"args": ["-y", "@stripe/mcp"],
"env": {"STRIPE_SECRET_KEY": "${STRIPE_API_KEY}"}
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"}
}
}环境变量(${VAR})从过程环境或 ~/.config/mcpfs/env.
# Mount all to .mcpfs/ in cwd
mcpfs --config ~/.config/mcpfs/servers.json
# Mount to custom dir
mcpfs --config ~/.config/mcpfs/servers.json --mount /mnt/mcpfs自动发现Claude代码插件
如果你使用克劳德代码, mcpfs auto 发现所有已安装的MCP插件并将其挂载到您的项目中:
cd ~/src/myproject
mcpfs auto # discover + mount to .mcpfs/
mcpfs auto --json # print discovered config (dry run)安装到 .mcpfs/ 在当前目录中。读取 .env.local 和 .env 从cwd获取项目特定的证书(例如,不同的Vercel团队,每个仓库的PostHog项目)。
它从所有Claude Code配置源中读取:
~/.claude.json→mcpServers--全局用户配置服务器~/.claude/plugins/--已安装的插件及其.mcp.json~/.claude/settings.json→enabledPlugins--还扫描缓存以查找这些~/.claude/.credentials.json--OAuth令牌(Notion等)~/.config/mcpfs/servers.json--其他用户定义的服务器~/.config/mcpfs/env-回退环境变量(API密钥)gh auth token--GitHub令牌回退
非数据插件(剧作家、serena、context7)会自动跳过。
跨服务组合
# Business dashboard
printf "%-20s %s\n" "Stripe balance" "$(cat .mcpfs/stripe/balance.json | jq -r '.available[] | "\(.currency) \(.amount / 100)"')"
printf "%-20s %s\n" "Active subs" "$(cat .mcpfs/stripe/subscriptions.json | jq '[.[] | select(.status=="active")] | length')"
printf "%-20s %s\n" "PH dashboards" "$(cat .mcpfs/posthog/dashboards.json | jq length)"
# Find paying customers with no analytics activity
comm -23 \
` 列出写入/查询工具 `--help`
- `mcpfs tool --flag value` 为写作
- 所有工具输出都会进入stdout(JSON),提示会进入stderr
- 退出代码:0成功,1错误
## 许可证
麻省理工学院