Back to MCP directory
publicPublicdnsLocal runtime

BatchIt

MCP BatchIt是一个MCP工具调用批处理服务器,通过聚合多个MCP工具调用到一个请求中,显著减少AI代理的通信开销和token消耗。

article

README

🚀 MCP BatchIt 工具指南

MCP BatchIt 是一款强大的工具,它能够通过单个请求执行多个操作,极大地提升操作效率,为用户提供便捷的使用体验。

🚀 快速开始

使用 MCP BatchIt 工具,您可以按照以下步骤进行操作:

指定目标服务器

{
  "targetServer": {
    "name": "filesystem",
    "serverType": {
      "type": "filesystem",
      "config": {
        "rootDirectory": "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit"
      }
    },
    "transport": {
      "type": "stdio",
      "command": "cmd.exe",
      "args": [
        "/c",
        "npx",
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit"
      ]
    }
  }
}

定义操作

{
  "operations": [
    {
      "tool": "create_directory",
      "arguments": {
        "path": "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit/memory-bank"
      }
    },
    {
      "tool": "write_file",
      "arguments": {
        "path": "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit/memory-bank/productContext.md",
        "content": "# MCP BatchIt Product Context\\n\\n## Purpose\\n..."
      }
    },
    // 其他操作类似
  ]
}

配置选项

{
  "options": {
    "maxConcurrent": 1,
    "stopOnError": true,
    "timeoutMs": 30000
  }
}

✨ 主要特性

  • 并行处理:允许同时运行多个子操作,大大提高处理效率。
  • 错误停止:如果某个子操作失败,可以选择停止后续的操作,避免不必要的资源浪费。
  • 连接缓存:为了提高效率,BatchIt 会缓存目标服务器的连接,直到出现空闲超时。

💻 使用示例

基础用法

以下是一个完整的使用示例,包含指定目标服务器、定义操作和配置选项:

{
  "targetServer": {
    "name": "filesystem",
    "serverType": {
      "type": "filesystem",
      "config": {
        "rootDirectory": "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit"
      }
    },
    "transport": {
      "type": "stdio",
      "command": "cmd.exe",
      "args": [
        "/c",
        "npx",
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit"
      ]
    }
  },
  "operations": [
    {
      "tool": "create_directory",
      "arguments": {
        "path": "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit/memory-bank"
      }
    },
    {
      "tool": "write_file",
      "arguments": {
        "path": "C:/Users/Chewy/Documents/GitHub/ryanjoachim/mcp-batchit/memory-bank/productContext.md",
        "content": "# MCP BatchIt Product Context\\n\\n## Purpose\\n..."
      }
    }
  ],
  "options": {
    "maxConcurrent": 1,
    "stopOnError": true,
    "timeoutMs": 30000
  }
}

📚 详细文档

常见问题解答

Q1: 如果子操作 #2 依赖于子操作 #1 的结果,是否需要多次调用 BatchIt?

是的。BatchIt 不会在同一个请求中传递数据。建议采用多阶段调用(如上文示例所示)。

Q2: 为什么有时会看到“Tool create_directory not found”错误?

这是因为你的 transport 可能指向了聚合器脚本本身,而不是真正的 MCP 服务器。请确保引用类似 @modelcontextprotocol/server-filesystem 的真实 MCP 服务器。

Q3: 是否可以同时实现并行处理和错误停止?

当然可以。如果某个子操作失败,已启动的其他子操作会继续运行,但尚未启动的操作将被跳过。

Q4: BatchIt 是否会重新启动目标服务器每次调用?

不一定。默认情况下,BatchIt 会缓存连接,直到出现空闲超时。你也可以通过设置 keepAlive 配置选项来控制此行为。

Q5: 如果在中间发生错误,是否可以返回部分结果?

是的。最终响应将包含所有在错误发生前完成的子操作状态,以及失败的子操作。如果启用了 stopOnError,后续操作将被跳过。

📄 许可证

MIT

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