Tool Filter MCP
tool-filter-mcp
一个 MCP 代理服务器,通过基于正则表达式的拒绝列表过滤来自上游 MCP 服务器的工具。
维护状态:✅ 是 (26 年春/夏季)
为什么要使用它?
为了实现有效的上下文工程,我们需要尽量减少无用 token。目前大多数主流代理(例如 Claude Code) 并不会从上下文中移除工具描述。 即使该工具被完全拒绝且未使用,模型仍然会获取其完整的描述,并仍然 尝试调用该工具(并收到错误消息)。对于大型 MCP(如 github、supabase、jetbrains IDE、atlassian), 这对上下文来说是灾难性的,会导致 40-60k 的无用 token 污染上下文。 你希望你的代理能够查看 jira 工单描述? 请同时附带这 44 个用于编辑 confluence 页面指派人的无用工具。
此 MCP 在不引入任何开销的情况下完全解决了这个问题。欢迎贡献!
Related MCP server: mcp-schema-bloat-fixer
安装
# For HTTP/SSE MCP servers
npx @respawn-app/tool-filter-mcp --upstream <url> --deny <patterns>
# For stdio MCP servers
npx @respawn-app/tool-filter-mcp --upstream-stdio --deny <patterns> -- <command> [args...]使用方法
基本示例 (HTTP/SSE)
从 HTTP MCP 服务器过滤匹配 .*_file$ 模式的工具:
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--deny ".*_file$"基本示例 (stdio)
从本地 stdio MCP 服务器过滤工具:
npx @respawn-app/tool-filter-mcp \
--upstream-stdio \
--deny "dangerous_.*" \
-- npx my-mcp-server使用环境变量 (stdio)
将环境变量传递给上游 stdio 服务器:
npx @respawn-app/tool-filter-mcp \
--upstream-stdio \
--env "API_KEY=secret123" \
--env "DEBUG=true" \
--deny "admin_.*" \
-- npx my-mcp-server多种模式
使用逗号分隔的模式:
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--deny "get_file_text,create_new_file,replace_text"使用身份验证标头
添加自定义标头以进行身份验证:
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--header "Authorization: Bearer your-token-here" \
--header "X-API-Key: your-api-key"标头支持环境变量扩展(如果尚未被你的应用程序扩展):
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--header "Authorization: Bearer $AUTH_TOKEN"列出可用工具
在设置过滤器之前查看有哪些可用工具:
# Default table format
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--list-tools
# Get comma-separated names for copy-paste
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--list-tools --format=names
# Get full JSON with schemas
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--list-tools --format=json
# Preview filtered results
npx @respawn-app/tool-filter-mcp \
--upstream http://localhost:3000/sse \
--deny ".*_file$" \
--list-tools --format=names与 Claude Code 配合使用
HTTP/SSE 上游服务器
添加到你的 .mcp.json 中:
{
"mcpServers": {
"filtered-http-server": {
"command": "npx",
"args": [
"@respawn-app/tool-filter-mcp",
"--upstream",
"http://localhost:3000/sse",
"--deny",
"dangerous_tool_1,dangerous_tool_2"
],
"type": "stdio"
}
}
}使用身份验证标头(支持环境变量扩展):
{
"mcpServers": {
"filtered-http-server": {
"command": "npx",
"args": [
"@respawn-app/tool-filter-mcp",
"--upstream",
"http://localhost:3000/sse",
"--header",
"Authorization: Bearer ${API_TOKEN}",
"--header",
"X-Custom-Header: $CUSTOM_VALUE",
"--deny",
"sensitive_.*"
],
"type": "stdio"
}
}
}Stdio 上游服务器
{
"mcpServers": {
"filtered-zen": {
"command": "npx",
"args": [
"@respawn-app/tool-filter-mcp",
"--upstream-stdio",
"--deny",
"dangerous_.*,sensitive_.*",
"--",
"npx",
"my-mcp-server"
],
"type": "stdio"
}
}
}向上传输服务器传递多个参数:
{
"mcpServers": {
"filtered-stdio-server": {
"command": "npx",
"args": [
"@respawn-app/tool-filter-mcp",
"--upstream-stdio",
"--deny",
"admin_.*",
"--",
"node",
"my-mcp-server.js",
"--config=config.json",
"--verbose"
],
"type": "stdio"
}
}
}使用以短横线开头的参数(如 uvx):
{
"mcpServers": {
"filtered-uvx-server": {
"command": "npx",
"args": [
"@respawn-app/tool-filter-mcp",
"--upstream-stdio",
"--deny",
"test_.*",
"--",
"uvx",
"--from",
"git+https://github.com/BeehiveInnovations/zen-mcp-server.git",
"zen-mcp-server"
],
"type": "stdio"
}
}
}为上游 stdio 服务器设置环境变量:
{
"mcpServers": {
"filtered-server-with-env": {
"command": "npx",
"args": [
"@respawn-app/tool-filter-mcp",
"--upstream-stdio",
"--env",
"API_KEY=${MY_API_KEY}",
"--env",
"DEBUG=true",
"--deny",
"admin_.*",
"--",
"npx",
"my-mcp-server"
],
"type": "stdio"
}
}
}CLI 选项
工具列表
打印可用工具列表而不启动代理服务器
--list-tools: 列出上游可用工具并退出--format <type>:--list-tools的输出格式(默认:table)table: 人类可读的表格,包含描述(截断为 100 个字符)json: 包含完整模式的完整 JSON 输出names: 以逗号分隔的工具名称,方便复制粘贴
连接模式(互斥)
要启动代理服务器,必须精确指定以下其中之一:
--upstream <url>: 连接到上游 HTTP/SSE MCP 服务器--upstream-stdio: 启动并连接到上游 stdio MCP 服务器需要在
--分隔符后提供命令和参数示例:
--upstream-stdio -- npx zen-mcp-server
通用选项
--deny <patterns>: 以逗号分隔的正则表达式模式,用于过滤工具
HTTP/SSE 模式选项
仅适用于 --upstream:
--header <name:value>: 传递给上游服务器的自定义 HTTP 标头(可重复使用以设置多个标头)格式:
--header "Header-Name: value"支持环境变量扩展:
$VAR或${VAR}示例:
--header "Authorization: Bearer $TOKEN"
Stdio 模式选项
仅适用于 --upstream-stdio:
--env <KEY=value>: 传递给上游 stdio 服务器的环境变量(可重复使用以设置多个变量)格式:
--env "KEY=value"示例:
--env "API_KEY=secret" --env "DEBUG=true"
在
--分隔符之后,提供命令及其所有参数--之后的所有内容都会传递给上游服务器支持以短横线开头的参数(如
--from,--config等)示例:
--upstream-stdio -- uvx --from git+https://... package-name
要求
Node.js >= 20.0.0
上游 MCP 服务器需具备:
SSE 或可流式传输的 HTTP 传输(用于
--upstream),或者stdio 传输(用于
--upstream-stdio)
许可证
MIT
版权所有 (c) 2026 Respawn LLC
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Security & DLP proxy for MCP: tool-poisoning scans, PII redaction on tool args/results. Beta.
Find, vet, and run MCP tools through a secure audited gateway with prompt-injection risk scoring
Zero-LLM guardrail MCP to detect prompt injections, redact/HMAC PII, and validate tool args.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceA generic MCP proxy that filters which tools are exposed from a remote MCP server, reducing context window token usage by only loading the tools you actually need.9 npm1MIT
- AlicenseNot gradedqualityDmaintenanceReduces token costs from MCP tool schemas by analyzing bloat, compressing descriptions, and selecting only relevant tools for AI agents.MIT
- FlicenseNot gradedqualityDmaintenanceScopes MCP tool definitions and strips Markdown from outputs to minimize token usage, improving agent cost and accuracy.-
- FlicenseNot gradedqualityCmaintenanceEnables safe use of any MCP server by proxying and live-scanning all tool requests and responses, blocking or redacting poison descriptions, indirect prompt injection, malicious arguments, and unauthorized destinations.-