Back to MCP directory
publicPublicdnsLocal runtime

mcp_tool_chainer

MCP工具链服务器,实现多个MCP工具的顺序调用和结果传递

article

README

🚀 MCP 工具链器

一个 MCP(模型上下文协议)服务器,通过按顺序链接调用其他 MCP 工具来减少代币使用量。该工具链器旨在解决 https://github.com/modelcontextprotocol/specification/issues/215 中提出的问题。

访问 Third Strand Studio

image

✨ 主要特性

  • 将多个 MCP 工具按顺序链接在一起。
  • 使用 CHAIN_RESULT 占位符将一个工具的结果传递给另一个工具作为输入。
  • 通过 inputPathoutputPath 参数使用 JsonPath 过滤和提取特定数据。
  • 从配置的 MCP 服务器中自动发现工具。
  • 比单独调用工具更节省代币。

📦 安装指南

先决条件

  • Node.js (v16 或更高版本)
  • npm

使用 npm 安装

# 安装
npm install

# 启动服务器
node dist/index.js config.json

# 列出可用工具
node dist/index.js config.json discover_tools

💻 使用示例

配置示例

# 安装依赖项
npm install

# 启动服务器
node dist/index.js config.json

# 列出可用工具
node dist/index.js config.json discover_tools

开发示例

# 安装依赖项
npm install

# 启动服务器
node dist/index.js config.json

# 列出可用工具
node dist/index.js config.json discover_tools

📚 详细文档

工具

此服务器实现了以下 MCP 工具:

  1. mcp_chain - 将多个 MCP 服务器按顺序链接在一起。
  2. chainable_tools - 从所有 MCP 服务器中发现工具,以便 mcp_chain 工具可以使用。
  3. discover_tools - 重新发现所有 MCP 服务器中的工具。

JsonPath 支持

MCP 工具链器现在支持 AWS Step Functions 式的 InputPath 和 OutputPath 功能:

  • inputPath:JsonPath 表达式,用于在传递给工具之前提取输入的特定部分。
  • outputPath:JsonPath 表达式,用于在传递给下一个工具之前提取输出的特定部分。

这些功能仅在输入/输出为有效 JSON 时才起作用。如果 JsonPath 提取失败,则使用原始输入/输出。

有关 JsonPath 语法参考,请参见 JsonPath Syntax

优势

  • 减少代币使用:通过按顺序链接工具,避免将大型中间结果发送回 LLM。
  • 简化工作流程:通过单个工具调用创建复杂的数据处理管道。
  • 提高性能:通过最小化 LLM 和工具之间的往返次数来降低延迟。
  • 精确数据流控制:使用 JsonPath 表达式提取所需数据。

📄 许可证

此 MCP 服务器根据 MIT 许可证发布。


Third Strand Studio 创建

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client