使用说明
工具搜索工具MCP
英语| 俄语
用于搜索和使用MCP工具的工具。此项目实现了一个MCP服务器,该服务器充当以下内容的聚合器和代理 其他服务器。
这个项目解决了什么问题?
现代法学硕士(如克劳德)有上下文限制。当您直接连接多个MCP服务器时:
- 上下文溢出:每次请求时,所有工具描述都会在系统提示中传递。如果有几十个 或者数百个工具,它们“吃掉”了有用的上下文量,增加了每条消息的成本。
- 响应质量降低:由于可用功能丰富,在选择模型时可能会感到困惑 使用合适的工具或忽略重要指示。
- 客户端限制:许多客户端(例如Claude Desktop)对同时活动的工具数量有限制。
工具搜索工具MCP 通过充当“工具换工具”来解决这些问题:
- 它将所有真正的工具隐藏在两个通用工具后面:
search_tools和call_tool. - 该模型只看到这两个工具,使上下文保持干净。
- 当模型需要某些东西时,它首先通过关键字搜索合适的工具,获取其模式,然后调用它 通过代理。
主要特点
- 聚合:通过单个服务器从不同的MCP服务器(例如文件系统、git、sqlite)访问工具。
- 智能搜索:专注
search_tools用于过滤可用功能的工具。使用模糊搜索并考虑 工具名称、描述和参数。 - 技能(宏):通过YAML定义自定义复合工具(技能),将多个工具调用链接到一个操作中。
- 关键字生成:从工具定义中自动提取关键字,以提高搜索准确性。
- 混合搜索:支持模糊搜索(
fuse.js)语义向量搜索(transformers.js)为了更好 理解用户意图。 - 上下文保存:该模型只看到两个工具,而不是数百个工具,这对长对话至关重要。
- 多语言支持:改进了文本处理,支持西里尔字母和其他字符。
- 嵌入缓存:用于工具嵌入的持久存储,以确保快速启动并最大限度地减少CPU使用。
- 动态通话:The
call_tool用于从已找到的服务器执行命令的工具。 - 改进日志记录:支持文件输出、基于范围的日志记录和详细的日志级别配置。
- 安全:使用Zod验证连接服务器的响应。
安装
-
克隆存储库:
git clone https://github.com/fussraider/tool-search-tools-mcp.git cd tool-search-tools-mcp或 下载 最新版本.
-
安装依赖项:
pnpm install # or npm install, yarn
用法
运行服务器
对于开发(自动重新加载):
pnpm dev # or npm run dev, yarn dev
对于生产(构建和运行):
pnpm build # or npm run build, yarn build
pnpm start # or npm start, yarn start
CLI测试实用程序
您可以直接从命令行测试工具搜索:
pnpm search_tools "list directory contents"
这将连接到您的数据库中定义的所有服务器 mcp-config.json,加载他们的工具,并在您的终端中显示搜索结果。
连接到Claude Desktop或其他客户端
将此服务器添加到MCP客户端配置中。例如,对于Claude Desktop:
方法1:使用Node.js(推荐)
{
"mcpServers": {
"tool-search-tools-mcp": {
"command": "node",
"args": [
"/path/to/tool-search-tools-mcp/dist/server.js"
],
"env": {
"MCP_CONFIG_PATH": "/path/to/your/mcp-config.json",
"MCP_SKILLS_PATH": "/path/to/your/skills.yaml",
"MCP_SEARCH_MODE": "vector"
}
}
}
}
方法2:使用tsx(用于开发)
{
"mcpServers": {
"tool-search-tools-mcp": {
"command": "npx",
"args": [
"tsx",
"/path/to/tool-search-tools-mcp/src/server.ts"
],
"env": {
"MCP_CONFIG_PATH": "/path/to/your/mcp-config.json",
"MCP_SEARCH_MODE": "vector"
}
}
}
}
光标/反重力/LM工作室/其他客户
大多数通过以下方式支持MCP的客户端 stdio 遵循相同的模式。您需要提供:
- 命令:
node - 参数:
["/path/to/tool-search-tools-mcp/dist/server.js"] - 环境变量:
MCP_CONFIG_PATH(如果不在默认位置,则为必填项),MCP_SEARCH_MODE(可选)。
配置
连接的服务器列表在中配置 mcp-config.json 文件位于项目根目录或指定路径
在 MCP_CONFIG_PATH 环境变量。
示例 mcp-config.json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"@modelcontextprotocol/server-filesystem",
"/your/path"
],
"env": {
"SOME_VAR": "value"
}
}
}
}
技能配置(宏)
您可以定义自定义“技能”,将多个工具调用组合到一个操作中。创建 skills.yaml 文件(项目根目录中的默认位置,或设置 MCP_SKILLS_PATH).
示例 skills.yaml:
skills:
- name: "research_topic"
description: "Searches for a topic and saves the summary to a file"
parameters:
topic: string
steps:
- tool: "search_google" # Tool from another connected server
args:
query: "{{topic}}"
result_var: "search_result"
- tool: "write_file"
args:
path: "./research/{{topic}}.txt"
content: "{{search_result}}"
这些技能将作为常规工具出现在搜索结果中,并可由LLM调用。
环境变量
MCP_CONFIG_PATH:配置文件的路径(默认值:mcp-config.json在项目目录中)。MCP_SKILLS_PATH:技能定义文件的路径(默认值:skills.yaml在项目目录中)。LOG_LEVEL:日志记录级别(DEBUG,INFO,WARN,ERROR).违约:INFO.LOG_FILE_PATH:用于写入日志的文件的路径。如果未设置,日志将输出到stderr.LOG_SHOW_TIMESTAMP:允许在日志中显示日期和时间。违约:false支持的值用于启用:true,1,yes不区分大小写MCP_SEARCH_MODE:搜索模式。选项:fuse(默认)或vector(语义搜索)。MCP_EMBEDDING_MODEL:用于生成嵌入的模型。违约:Xenova/all-MiniLM-L6-v2.MCP_CACHE_DIR:用于存储缓存嵌入的目录。违约:.cache/embeddings.
故障排除
安装问题 sharp
该项目使用 transformers.js,这取决于 sharp 图书馆。在某些系统上(尤其是macOS Apple)
硅), pnpm 出于安全原因,可能会阻止安装本机依赖项。如果您看到与以下内容相关的错误
sharp,确保您使用的是最新版本 package.json 随着 pnpm.onlyBuiltDependencies 部分或运行:
pnpm install
如果问题仍然存在,您可能需要明确允许构建依赖关系或重新安装它们:
rm -rf node_modules pnpm-lock.yaml
pnpm install
常见问题解答
Does this tool support all MCP servers?
Yes, it acts as a proxy and can connect to any server that follows the Model Context Protocol (stdio-based).Why use "vector" search mode?
Vector (semantic) search understands the meaning of your query, not just exact keyword matches. This is helpful when you don't know the exact name of a tool but know what it should do.Is my data safe when using vector search?
Yes, by default, the project uses `transformers.js` with the `Xenova/all-MiniLM-L6-v2` model, which runs **locally** on your machine. No data is sent to external APIs for embedding generation.Can I use this with Claude Desktop?
Absolutely! See the [Usage](#connecting-to-claude-desktop-or-other-clients) section for configuration examples.How do I switch between "fuse" and "vector" search modes?
You can set the `MCP_SEARCH_MODE` environment variable to either `fuse` (fuzzy text search) or `vector` (semantic search). For Claude Desktop, add it to the `env` section of your server configuration.Where are the embeddings stored and how can I clear them?
By default, embeddings are cached in the `.cache/embeddings` directory within the project folder. You can change this path using the `MCP_CACHE_DIR` environment variable.缓存仅在以下情况下创建和使用 向量 搜索模式。当工具定义更改时,它会自动更新,任何过时或未使用的条目都会被删除。要强制完全重新索引,只需删除此目录即可。
How can I add more MCP servers for this tool to aggregate?
Edit your `mcp-config.json` file and add new servers to the `mcpServers` object. The format is identical to the Claude Desktop configuration.Can I use a different embedding model?
Yes, you can specify a different model from [Hugging Face](https://huggingface.co/models?library=transformers.js) using the `MCP_EMBEDDING_MODEL` environment variable. Make sure the model is compatible with `transformers.js`.项目结构
src/server.ts--主MCP服务器文件。初始化服务器和已注册工具的入口点。src/cli.ts--CLI实用程序,用于直接从终端搜索测试工具。src/mcp/--MCP逻辑:registry.ts--其他服务器的连接管理、工具提取和搜索关键字生成。skills.ts--技能(宏)加载和执行引擎。search.ts--模糊搜索算法fuse.js以及语义向量搜索。executor.ts--用于调用连接服务器上的工具的代理逻辑。
src/utils/--公用设施:logger.ts--具有文件支持和日志级别的自定义记录器。embeddings.ts--用于生成和缓存向量嵌入的服务。text.ts--文本处理和规范化实用程序。
mcp-config.json--连接的MCP服务器的配置文件。skills.yaml--用于定义自定义技能的配置文件。
许可证
麻省理工学院
