@qelos/better-mcp
A stdio MCP proxy that connects to one or more upstream MCP servers and exposes their tools, resources, and prompts through a single endpoint with a configurable middleware pipeline.
README
@qelos/better-mcp
A stdio MCP proxy that connects to one or more upstream MCP servers and exposes
their tools, resources, and prompts through a single endpoint — with a
configurable middleware pipeline (logging, redaction, oversize-response
offloading, and your own before / after hooks) wrapping every call.
┌──────────┐ stdio ┌────────────┐ stdio ┌──────────────────┐
│ Client │ ───────▶ │ better-mcp │ ───────▶ │ fs MCP server │
│ (Claude, │ │ middleware │ ├──────────────────┤
│ Cursor, │ │ pipeline │ ───────▶ │ github MCP server│
│ etc.) │ └────────────┘ ├──────────────────┤
└──────────┘ │ …more upstreams │
└──────────────────┘
Install
You can run better-mcp two ways. Pick whichever fits your host config.
Option A — npm
# One-shot, no install
npx -y @qelos/better-mcp
# Or install globally
npm install -g @qelos/better-mcp
better-mcp
Wire it into Claude Desktop / Cursor:
{
"mcpServers": {
"proxy": {
"command": "npx",
"args": ["-y", "@qelos/better-mcp", "-c", "/abs/path/to/mcp.json"]
}
}
}
Option B — Docker (GHCR)
The image is published to GitHub Container Registry as a public package:
docker pull ghcr.io/qelos/better-mcp:latest
Run it, mounting your mcp.json so the proxy can find it at /app/mcp.json
(the default discovery path inside the container). If you use offload, also
mount a writable directory and point middleware.offload.dir at it.
docker run --rm -i \
-v "$PWD/mcp.json:/app/mcp.json:ro" \
-v "$PWD/exports:/exports" \
ghcr.io/qelos/better-mcp:latest
Wire it into a host:
{
"mcpServers": {
"proxy": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "/abs/path/to/mcp.json:/app/mcp.json:ro",
"-v", "/abs/path/to/exports:/exports",
"ghcr.io/qelos/better-mcp:latest"
]
}
}
}
Notes for Docker:
- Use
-i(no-t) — the proxy speaks MCP over stdio. - Any upstream MCP servers listed in
mcp.jsonneed to be runnable inside the container. The image hasnodeandnpx, sonpx -y @modelcontextprotocol/server-*works out of the box. If an upstream needs Python, Docker-in-Docker, or other toolchains, build a derived image. - For per-server secrets, pass them through with
-e GITHUB_PERSONAL_ACCESS_TOKEN=….
Option C — Build from source
git clone https://github.com/qelos/better-mcp.git
cd better-mcp
npm install
npm run build
node dist/index.js
Run
The proxy uses the same mcp.json shape as Cursor and Claude Desktop. By
default it looks for one automatically; you only need -c to override.
# Auto-discover mcp.json (see "Config location" below)
better-mcp
# Or point at a specific file
better-mcp -c ./examples/mcp.json
better-mcp --config /abs/path/to/mcp.json
# Or pass via env (inline JSON or a path)
MCP_PROXY_CONFIG=./examples/mcp.json better-mcp
MCP_PROXY_CONFIG='{"mcpServers":{"fs":{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","/tmp"]}}}' better-mcp
Config location
Resolved in this order — the first hit wins:
-c <path>/--config <path>CLI flagMCP_PROXY_CONFIGenv var (inline JSON, or a path)mcp.jsonnext to the entry script (e.g.dist/mcp.json, or/app/dist/mcp.jsoninside Docker)mcp.jsonone level up from the entry script (e.g. project root, or/app/mcp.jsoninside Docker)mcp.jsonin the current working directory
In practice: drop your mcp.json next to package.json (or mount it at
/app/mcp.json in Docker) and it just works.
Config
{
"mcpServers": {
"<name>": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"env": { "FOO": "bar" }, // optional
"cwd": "./somewhere", // optional
"enabled": true // optional, default true
}
},
// Prefix every tool/prompt with "<serverName>__". Default true.
// Resources keep their original URIs (they're already namespaced by scheme).
"namespace": true,
"middleware": {
// true = log to stderr, or pass { level, file } for control.
// level "info" logs name + duration; "debug" also logs params + result.
"log": { "level": "info" },
// Field-name substrings (case-insensitive) whose values get replaced with
// "[REDACTED]" in responses — useful for masking secrets in tool output.
"redact": ["token", "password", "api_key", "authorization"],
// Offload oversize responses to a file and return a short pointer.
// `true` enables defaults; pass an object to tune.
"offload": {
"thresholdBytes": 16384, // default 16 KB
"dir": "./exports", // default <os.tmpdir()>/better-mcp
"includeResources": false, // default false (tools only)
"inferArrayShape": true // default true
},
// Path to a JS/MJS module exporting `{ before, after }` hooks.
// Relative paths resolve against the config file's directory.
"hooks": "./middleware.js"
}
}
CLI flags:
-c <path>/--config <path>— path tomcp.json(overrides discovery + env).--no-namespace— disable the<server>__<tool>prefix at runtime.--offload-resources— also offloadresources/readresponses (same as settingmiddleware.offload.includeResources: true, orMCP_PROXY_OFFLOAD_RESOURCES=1).
Middleware
Every upstream call passes through a small stack. Registration order is
logger → offloader → redactor → user, so the after-chain runs from inside
out:
client ─▶ logger.before ─▶ user.before ─▶ upstream
│
▼
client ◀─ logger.after ◀─ offloader.after ◀─ redactor.after ◀─ user.after
User hooks see the raw request and the raw upstream response. Redaction cleans that data, the offloader decides whether to write it to disk and replace the response with a pointer, and the logger records what the client will ultimately see.
Offloading oversize responses
When a tool response's JSON-serialized size exceeds thresholdBytes
(default 16 KB), the offloader:
-
Writes the full response to
<dir>/<server>__<tool>__<timestamp>.json. If the response is the typical{ content: [{ type: "text", text: "<JSON>" }] }shape, the parsed inner JSON is saved instead of the wrapper. -
Replaces the response with a short text message like:
response exported to: /tmp/better-mcp/github__list_issues__2026-05-17T12-34-56-789Z.json size: 142.3 KB (145708 bytes) length: 1024 interface: Array<{ id: number; number: number; title: string; state: string; labels: Array<{ name: string; color: string }>; assignee: { login: string } | null }>lengthandinterfaceonly appear when the saved data is an array. The interface is inferred from a sample of up to 200 elements and depth-capped at 4 to keep it lean.
Tool responses are always considered. Resource reads are skipped by default;
flip includeResources: true (or pass --offload-resources) to include them.
Prompts are never offloaded.
User hooks
// middleware.js
export default {
async before(req) {
// req: { server, kind: "tool"|"resource"|"prompt", name, params, meta? }
if (req.kind === "tool" && req.name === "write_file") {
if (req.params?.path?.includes("/etc/")) {
throw new Error("writes under /etc are blocked");
}
}
return req; // or void to leave unchanged
},
async after(req, res) {
// res: { result, durationMs, error? }
if (res.durationMs > 2000) {
process.stderr.write(`slow: ${req.server}/${req.name}\n`);
}
return res;
},
};
Both hooks may be sync or async. Return the modified request/response, or
nothing to leave it as-is. Throwing inside before cancels the call; throwing
inside after surfaces as an MCP error to the client.
What's proxied
- tools/list — aggregated from every connected server. Names are namespaced
as
<server>__<tool>unlessnamespace: false. - tools/call — routed to the right upstream based on the namespaced name.
- resources/list / resources/read — aggregated; URIs are kept as-is.
- prompts/list / prompts/get — aggregated; names are namespaced.
If two upstreams expose the same name (or resource URI), the proxy logs a
collision warning and the later one wins. Use namespace: true (the default)
to avoid this.
Notes
- Logs go to stderr — stdout is reserved for the MCP protocol.
- A server that fails to start is logged and skipped; the rest still come up.
SIGINT/SIGTERMcloses every upstream cleanly before exit.
Publishing
npm (manual)
npm version <patch|minor|major> # bumps + tags + commits
npm publish --access public # public scoped package
git push --follow-tags
publishConfig.access: "public" is set in package.json, so the
--access public flag is just belt-and-suspenders.
Docker (automated)
Every push to main and every v*.*.* tag triggers
.github/workflows/docker-publish.yml, which builds a multi-arch image
(linux/amd64 + linux/arm64) and pushes to ghcr.io/qelos/better-mcp.
Tags pushed:
- branch pushes →
:main,:sha-<short> - semver tags →
:latest,:vX.Y.Z,:X.Y,:X
The workflow also flips the package to public on first push (no-op afterwards).
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。