Token导航 LogoToken导航TokenDH.com
Tool Hub MCP logo
搜索检索stdio官方级别未说明来源级核验

Tool Hub MCP

MCP Server

@khanglvm/tool-hub-mcp

tool-hub-mcp是一个服务器无感知的MCP聚合器,通过提供两个元工具(hub_search和hub_execute)来减少AI上下文令牌消耗,适用于需要管理多个MCP服务器的场景。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
GoClaude令牌优化ClaudeCursorWindsurf

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

khanglvm

提供方

khanglvm

最后核验

2026/5/17 20:19

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx @khanglvm/tool-hub-mcp setup

详细介绍

工具中心mcp

无服务器MCP聚合器 -减少AI上下文令牌消耗

问题

当将多个MCP服务器与AI客户端(Claude Code、OpenCode等)一起使用时,每个服务器都会将其所有工具暴露给AI上下文窗口。更多的服务器=在您开始工作之前消耗的令牌更多。

解决方案

tool-hub-mcp 充当仅公开的单个MCP网关 2元工具:

工具说明
hub_search跨服务器语义搜索工具(BM25+强盗排名)
hub_execute从服务器执行工具(带学习系统)

人工智能调用这些元工具来按需发现和执行工具,而不是预先加载所有工具定义。

基准

使用Claude Code v2.1.6进行测量 --output-format json 为了准确 input_tokens 计数。

测试:6台MCP服务器 (jira,剧作家,mcp大纲,shadcn,chrome开发工具,Figma)

配置输入令牌
6个单独的MCP48,371
仅限工具中心29,758
令牌已保存18,613
减少38.48%

更大的测试:7台MCP服务器 (共98个工具)

配置输入令牌
7个单独的MCP15,150
仅限工具中心461
令牌已保存14,689
减少96.9%

令牌优化(v1.2.0):

  • 紧凑型JSON(无缩进):减少约35%
  • 删除冗余字段:每个搜索结果约40%
  • 结果:2个结果节省43.7%,10个结果节省约70%

安装

# Zero-install (recommended) - works with npx, bunx, pnpm dlx, yarn dlx
npx @khanglvm/tool-hub-mcp setup

# Alternative: Go install
go install github.com/khanglvm/tool-hub-mcp/cmd/tool-hub-mcp@latest

快速开始

# 1. Import your existing MCP configs
tool-hub-mcp setup

# 2. Add to your AI client
# Claude Code:
claude mcp add -s user tool-hub -- npx -y @khanglvm/tool-hub-mcp serve

用法

从AI工具导入配置

# Auto-detect and import from Claude Code, OpenCode, etc.
tool-hub-mcp setup

手动添加MCP服务器

# Paste any MCP config format (auto-detected)
tool-hub-mcp add --json '{
  "mcpServers": {
    "jira": {"command": "npx", "args": ["-y", "@lvmk/jira-mcp"]},
    "outline": {"command": "uvx", "args": ["mcp-outline"]}
  }
}'

# Or use flags
tool-hub-mcp add jira --command npx --arg -y --arg @lvmk/jira-mcp

管理服务器

# List all servers
tool-hub-mcp list

# Remove a server
tool-hub-mcp remove jira

# Verify configuration
tool-hub-mcp verify

运行MCP服务器

# Start server (stdio transport)
tool-hub-mcp serve

# Via AI client (already configured)
claude mcp add tool-hub -- tool-hub-mcp serve

Bash/Grep导出工具索引

生成用于离线工具搜索的本地索引文件,而无需MCP开销:

# Export to default location (~/.tool-hub-mcp-index.jsonl)
tool-hub-mcp export-index

# Custom output path
tool-hub-mcp export-index --output ./my-tools.jsonl

# JSON array format (instead of JSONL)
tool-hub-mcp export-index --format json

自动再生:运行时索引会自动更新 setup, add,或 remove 命令。

Bash/Grep使用示例:

# Find tools by server
grep '"jira"' ~/.tool-hub-mcp-index.jsonl

# Search tool descriptions
grep -i "search" ~/.tool-hub-mcp-index.jsonl | jq -r '.tool'

# List all tools
cat ~/.tool-hub-mcp-index.jsonl | jq -r '.tool'

# Count tools per server
cat ~/.tool-hub-mcp-index.jsonl | jq -r '.server' | sort | uniq -c

# Complex query: Find Jira tools with "issue" in description
grep '"jira"' ~/.tool-hub-mcp-index.jsonl | grep -i "issue" | jq .

为什么要使用bash/grep?

  • 零MCP开销(无进程生成)
  • 脱机工作(本地文件)
  • 标准Unix工具(无依赖关系)
  • 可编写脚本和可组合

基准性能

# Compare token consumption
tool-hub-mcp benchmark

# Measure latency
tool-hub-mcp benchmark speed

命令

命令描述
setup从AI CLI工具导入MCP配置
add添加MCP服务器-粘贴JSON或使用标志
remove删除MCP服务器
list列出已注册的服务器
verify验证配置
serve运行MCP服务器(stdio)
export-index导出bash/grep搜索工具索引(离线)
benchmark比较代币消费
benchmark speed测量每台服务器的延迟
learning管理学习系统(状态、导出、清除、启用、禁用)

支持的配置源

  • 克劳德代码(~/.claude.json, .mcp.json)
  • OpenCode(~/.opencode.json)
  • 谷歌反重力(~/.gemini/antigravity/mcp_config.json)
  • Gemini CLI(~/.gemini/settings.json)
  • 光标(~/.cursor/mcp.json)
  • 风帆冲浪(~/.codeium/windsurf/mcp_config.json)

运作原理

┌─────────────────────────────────────────────────────────┐
│                     AI Client                           │
│              (Claude Code, OpenCode, etc.)              │
└───────────────────────┬─────────────────────────────────┘
                        │ 2 meta-tools
                        ▼
┌─────────────────────────────────────────────────────────┐
│                   tool-hub-mcp                          │
│           hub_search │ hub_execute                      │
└───────────────────────┬─────────────────────────────────┘
                        │ On-demand spawning
        ┌───────────────┼───────────────┐
        ▼               ▼               ▼
   ┌─────────┐    ┌─────────┐    ┌─────────┐
   │  Jira   │    │ Outline │    │  Figma  │
   │  MCP    │    │   MCP   │    │   MCP   │
   └─────────┘    └─────────┘    └─────────┘

AI工作流程:

  1. 呼叫 hub_search("what I need") 查找具有排名结果的工具
  2. 呼叫 hub_execute(server, tool, args, searchId) 执行(学习跟踪使用情况)

结果: 按需加载工具定义,智能排名会随着时间的推移而提高。

建筑

技术栈:

  • 语言: 转到1.22+(0.88ms启动)
  • 分布: 零安装npm+Go二进制
  • 运输: 基于stdio的JSON-RPC 2.0
  • 协议: MCP 2024-11-05

关键设计决策:

  • 懒惰产卵: 进程仅在访问工具时启动
  • 进程池: 重用生成的进程(默认值:3)
  • 安全请求ID: 原子计数器(非UnixNano)与JS兼容
  • 标准排水: 防止管道缓冲区死锁

演出

令牌效率:

  • 与传统方法相比减少38-97%
  • v1.2.0:每次搜索可额外节省43-70%
  • 使用更多服务器可以更好地扩展
  • Bash/grep替代方案:零令牌(离线)

速度:

  • 冷启动:约845ms(第一次工具调用)
  • 热启动:~50ms(过程重复使用)
  • 平均:5台服务器上307毫秒

内存:

  • 配置:每台服务器约1KB
  • 进程:每台活动服务器~5-10MB
  • 池:~15-30MB(3个进程)

配置

配置位置: ~/.tool-hub-mcp.json

格式:

{
  "servers": {
    "serverName": {
      "command": "npx",
      "args": ["-y", "@package/name"],
      "env": {"KEY": "value"},
      "source": "claude-code"
    }
  },
  "settings": {
    "cacheToolMetadata": true,
    "processPoolSize": 3,
    "timeoutSeconds": 30
  }
}

开发工作流程

设置

安装git挂钩进行自动测试:

make setup-hooks

测试

# Run all tests
make test

# Run tests with race detector
make test-race

# Run fast tests (pre-commit)
make test-fast

# Run full suite with coverage check (pre-push)
make test-coverage

Git挂钩

  • 预承诺: 对更改的包运行快速测试(约10秒)
  • 预推: 运行全套保险检查(~60s,需要80%的保险)
  • 旁路: 使用 git commit --no-verifygit push --no-verify 紧急情况

钩子可以防止失败的代码到达远程存储库。覆盖率阈值强制为80%。

文档

全面的文档可在 /docs/:

  • 项目概述和初步设计评审: /docs/project-overview-pdr.md
  • 规范标准: /docs/code-standards.md
  • 代码库摘要: /docs/codebase-summary.md
  • 系统架构: /docs/system-architecture.md
  • 设计指南: /docs/design-guidelines.md
  • 部署指南: /docs/deployment-guide.md
  • 项目路线图: /docs/project-roadmap.md

贡献

欢迎投稿!请参阅:

  • /docs/ 架构和设计指南
  • /CLAUDE.md 用于开发工作流
  • GitHub错误报告和功能请求问题

许可证

麻省理工学院

链接

  • npm: https://www.npmjs.com/package/@khanglvm/工具中心mcp
  • github: https://github.com/khanglvm/tool-hub-mcp
  • MCP协议: https://modelcontextprotocol.io/

目录标签

目录标签

GoClaude令牌优化MCP聚合本地部署AI工具管理服务器无感知工具搜索

支持客户端

ClaudeCursorWindsurf

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

@khanglvm/tool-hub-mcp

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP