メインコンテンツまでスキップ

MCP

Squid は、外部 MCP server またはカスタマイズされた Squid MCP Server に接続して、AI agents の tools と actions の定義を支援できます。

MCP とは?

MCP (Model Context Protocol) は、AI agents と外部サービス間の通信を促進するためのオープンプロトコルです。MCP server に接続することで、Squid AI agents が tools にアクセスし、actions を実行できるようにします。MCP server は、定義された tools を通じてさまざまな機能を公開します。

Squid で MCP server を作成する方法について詳しくは、MCP Server documentation を参照してください。

connector の設定

Squid で MCP connector を設定するには、次のセットアップ手順を完了します。

  1. Squid Console に移動し、目的の Squid application を選択します。
  2. Connectors タブをクリックします。
  3. Available Connectors をクリックし、MCP connector を見つけます。次に Add Connector をクリックします。
  4. 次の詳細を入力します。
  • Connector ID: 任意の一意な ID。簡潔で意味のあるものにするのが最適です

  • MCP URL: 外部 MCP server またはカスタマイズされた Squid MCP server によって提供される MCP endpoint URL。Squid MCP server URL の確認方法は、開発環境によって異なります。

  • Authorization (任意): 有効にすると、すべての MCP requests に authorization の key-value pair が自動的に挿入されます。これは、MCP server で必要になる可能性のある auth credentials を含める場合に便利です。Authorization Header Value は Squid secret として安全に保存され、console ではマスクされます。connector configuration にはその名前のみが保持されます。

  1. Test Connection をクリックして、server への接続をテストします。接続に失敗した場合は、MCP URL の値と、追加している場合は authorization header を確認してください。
  2. 接続が成功したら、Add Connector をクリックします。

agent で MCP connector を使用する

connector を追加した後、Agent Studio で agent の abilities に追加して agent にアタッチするか、connectedIntegrations ask option を使って request ごとに渡します。

await squid.ai().agent('AGENT_ID').ask('Look up the weather in Tokyo', {
connectedIntegrations: [
{
integrationId: 'MCP_CONNECTOR_ID',
integrationType: 'mcp',
description: 'Call this server for weather tools',
},
],
});

agent は server の tools を検出し、会話中に必要に応じてそれらを呼び出します。

agent が使用できる tools を制限する

デフォルトでは、agent は MCP server が公開するすべての tool にアクセスできます。特定の tools に制限するには、toolsToUse option にそれらの名前を列挙します。

  • In the Agent Studio: MCP connector ability を追加または編集するときに、Tools to use field に tool names をカンマ区切りのリストで入力します。すべての tools を許可するには空白のままにします。
  • In the SDK: connected integration の optionstoolsToUse を渡します。
await squid.ai().agent('AGENT_ID').ask('Look up the weather in Tokyo', {
connectedIntegrations: [
{
integrationId: 'MCP_CONNECTOR_ID',
integrationType: 'mcp',
description: 'Call this server for weather tools',
options: { toolsToUse: ['getWeather', 'getForecast'] },
},
],
});

省略された、または空の toolsToUse list はすべての tools を許可します。空でない list は、その中に含まれる正確な tool names のみを許可します。

API connector を MCP server として公開する

API connector は、MCP server code を一切書かずに、MCP 経由で agent に公開することもできます。Squid は connector の schema から MCP server を生成します。すべての endpoint は、その endpoint ID にちなんだ名前の MCP tool になり、tool の description と input parameters は endpoint definition から派生します。

API connector を MCP server として公開するには:

  1. Squid Console で API connector の configuration を開き、Expose as MCP Server を有効にします。
  2. Squid は connector の MCP server を https://YOUR_APP_URL/mcp/CONNECTOR_ID で提供するようになります。server とその tools は、console の Backend タブの MCP Servers の下にも表示されます。
  3. server を agent に接続します。Agent Studio では、この connector が MCP abilities の中に表示されるようになるため、他の MCP connector と同様に agent の abilities に追加できます。SDK では、integrationType: 'api'connectedAsMcp: true を指定した connectedIntegrations entry を渡します。
await squid.ai().agent('AGENT_ID').ask('What is the current exchange rate?', {
connectedIntegrations: [
{
integrationId: 'API_CONNECTOR_ID',
integrationType: 'api',
connectedAsMcp: true,
description: 'Call this API for exchange rate data',
},
],
});

toolsToUse option はここでも機能します。tool names は connector の endpoint IDs と一致するため、特定の endpoints へのアクセスを制限するには、agent が呼び出せる endpoint IDs を entry の options に渡します。

agent が tool を呼び出すと、Squid は直接の squid.api().request() call と同じ方法で、対応する API endpoint を実行します。connector の injections が適用され、endpoint の security rules が適用されます。Squid は、各 tool call で呼び出し元 user の authorization(bearer token または API key)を転送します。そのため、各 call は共有 credential ではなく元の呼び出し元の identity で実行されます。endpoint を直接呼び出す権限のない user は、agent 経由でもその endpoint にアクセスできません。