mcpField
M
Mcp_tool_chainer

Mcp_tool_chainer

ローカル
github.com/thirdstrandstudioAI・エージェント5764 週間前に更新

Mcp_tool_chainer について

MCP Tool Chainer は、複数の MCP ツール呼び出しを順番に実行し、各ステップの結果を次のステップへ渡す MCP サーバーです。LLM とのやり取りや トークン使用量を減らしながらツールを組み合わせたい利用者を想定し、JsonPath による入力・出力の絞り込みに対応します。

主な機能

  1. 01複数の MCP ツール呼び出しを順番に連結
  2. 02CHAIN_RESULT プレースホルダーによる前段結果の受け渡し
  3. 03入力と出力への JsonPath の適用
  4. 04設定済みサーバーからのツール自動検出

活用シーン

  1. 01取得した Web コンテンツを XPath ツールへ直接渡す処理
  2. 02次のステップの前にツール出力の一部を抽出する処理
  3. 03複数ツールを組み合わせた単一呼び出しのデータ処理

MCP 対応

MCP Tool Chainer は MCP サーバーとして mcp_chain、chainable_tools、discover_tools を公開し、設定済みの他の MCP サーバーに接続してそのツールを検出・呼び出します。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

mcp.json · 共通設定
{
"mcpServers": {
"tool-chainer": {
"command": "npx",
"args": [
"-y",
"@thirdstrandstudio/mcp-tool-chainer"
]
}
}
}
起動コマンドnpx -y @thirdstrandstudio/mcp-tool-chainer

ローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。

パッケージ
npm@thirdstrandstudio/mcp-tool-chainer

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

MCP Tool Chainer

Third Strand Studio を見る

他の MCP ツールへの呼び出しをチェーン化する MCP(Model Context Protocol)サーバーです。結果を引き渡しながらツールを順次実行できるため、トークン使用量を削減できます。 https://github.com/modelcontextprotocol/specification/issues/215 の課題を解決するために設計されています。

画像

ステップ関数のような JSON パス:

画像

機能

  • 複数の MCP ツールを順番にチェーン化
  • CHAIN_RESULT プレースホルダーを使用して、あるツールの結果を別のツールへの入力として渡す
  • inputPath および outputPath パラメーターで JsonPath を使用して特定のデータをフィルタリング、抽出
  • 設定済みの MCP サーバーからツールを自動検出
  • 個別にツールを呼び出す場合と比べて、トークン使用量を最小限に抑制

ツール

このサーバーは次の MCP ツールを実装しています。

  1. mcp_chain - 複数の MCP サーバーをチェーン化
  2. chainable_tools - すべての MCP サーバーからツールを検出し、mcp_chain ツールを利用可能にする
  3. discover_tools - すべての MCP サーバーからツールを再検出

インストール

前提条件
  • Node.js(v16 以降)
  • npm
npm からインストール
# Install
npm install @thirdstrandstudio/mcp-tool-chainer

# Or use with npx directly
npx -y @thirdstrandstudio/mcp-tool-chainer
ソースからインストール
# Clone the repository
git clone https://github.com/thirdstrandstudio/mcp-tool-chainer.git
cd mcp-tool-chainer

# Install dependencies
npm install

# Build the package
npm run build

Claude Desktop、Cursor などでの使用

最後に実行する MCP にしてください。そうしないと、再度検出を実行する必要があります。

claude_desktop_config.json または mcp.json に以下を追加してください。

npm グローバルインストールの場合
{
  "mcpServers": {
    "mcp_tool_chainer": {
      "command": "npx",
      "args": ["-y", "@thirdstrandstudio/mcp-tool-chainer", "`claude_desktop_config.json` or `mcp.json`"],
      "env": {}
    }
  }
}
ソースからインストールした場合
{
  "mcpServers": {
    "mcp_tool_chainer": {
      "command": "node",
      "args": ["/path/to/mcp-tool-chainer/dist/index.js", "`claude_desktop_config.json` or `mcp.json`"],
      "env": {}
    }
  }
}

/path/to/mcp-tool-chainer をリポジトリへの実際のパスに置き換えてください。

画像

使用例

Browser ツールと XPath ツールのチェーン化
// Fetch a webpage and then extract specific content with XPath
const result = await callTool("mcp_chain", { 
  "mcpPath": [
    {
      "toolName": "mcp_browser_mcp_fetch_url",
      "toolArgs": "{\"url\": \"https://example.com\"}"
    },
    {
      "toolName": "mcp_xpath_xpath",
      "toolArgs": "{\"xml\": CHAIN_RESULT, \"query\": \"//h1\"}"
    }
  ]
});
InputPath および OutputPath での JsonPath の使用
// Fetch a webpage, extract specific content with XPath, then extract part of the result
const result = await callTool("mcp_chain", { 
  "mcpPath": [
    {
      "toolName": "mcp_fetch_fetch",
      "toolArgs": "{\"url\": \"https://api.example.com/data\"}"
    },
    {
      "toolName": "web_search",
      "toolArgs": "{\"search_term\": CHAIN_RESULT}",
      "inputPath": "$.results[0].title",     // Extract only the first result's title from previous output
      "outputPath": "$.snippets[*].text"     // Extract only the text snippets from the search results
    },
    {
      "toolName": "another_tool",
      "toolArgs": "{\"content\": CHAIN_RESULT}"
    }
  ]
});

JsonPath のサポート

MCP Tool Chainer は、AWS Step Functions 形式の InputPath および OutputPath 機能をサポートするようになりました。

  • inputPath:ツールに渡す前に入力の特定の部分を抽出する JsonPath 式
  • outputPath:次のツールに渡す前に出力の特定の部分を抽出する JsonPath 式

これらの機能は、入出力が有効な JSON の場合にのみ動作します。JsonPath による抽出に失敗した場合は、元の入出力が使用されます。

JsonPath の構文については、JsonPath 構文を参照してください。

利点

  • トークン使用量の削減:ツールをチェーン化することで、大きな中間結果を LLM に送り返す必要がなくなります。
  • ワークフローの簡素化:1 回のツール呼び出しで複雑なデータ処理パイプラインを作成できます。
  • パフォーマンスの向上:LLM とツール間の往復を最小限に抑え、レイテンシを低減します。
  • データフローのきめ細かな制御:JsonPath 式を使用して、必要なデータだけを抽出できます。

開発

# Install dependencies
npm install

# Start the server
node dist/index.js config.json

# List available tools
node dist/index.js config.json discover_tools

ライセンス

この MCP サーバーは MIT License の下でライセンスされています。


Third Strand Studio が作成しました。

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。