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

MCP

Squid は external MCP server または customized Squid MCP Server に接続し、AI agent 用の tool と action を定義できます。​

MCP とは?​

MCP(Model Context Protocol)は、AI agent と external service 間の communication を容易にする open protocol です。Squid AI agent は、定義済み tool を通じてさまざまな functionality を公開する MCP server に接続することで、tool に access し action を実行できます。

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

Connector のセットアップ​

Squid で MCP connector を setup するには、以下の step を完了します。

  1. Squid Console に移動し、使用する Squid application を選択します。
  2. Connectors tab をクリックします。
  3. Available Connectors をクリックし、MCP connector を探します。次に Add Connector をクリックします。
  4. 以下の detail を入力します。
  • Connector ID: 任意の unique ID。簡潔で意味のあるものにすることをおすすめします

  • MCP URL: external MCP server または customized Squid MCP server により提供される MCP endpoint URL。Squid MCP server URL の確認方法は development environment によって異なります。

    • local development の場合、MCP URL は terminal の MCP Servers に log 出力されます。
    • backend を deploy済みの場合、console の Backend tab に移動し、MCP Servers から MCP URL を確認します。
  • Authorization(Optional): 有効にすると、すべての MCP request に authorization key-value pair を自動的に inject します。MCP server が必要とする auth credential を含める場合に役立ちます。Authorization Header Value は Squid secret として安全に保存され、console では mask されます。connector configuration に保存されるのはその name のみです。

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

Agent で MCP Connector を使用する​

connector を追加した後、Agent Studio で agent の abilities に追加して agent に attach するか、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 の tool を discover し、conversation 中に必要に応じて call します。

Agent が使用できる Tool を制限する​

default では、agent は MCP server が公開するすべての tool に access できます。specific tool に制限するには、toolsToUse option に name を list 化します。

  • Agent Studio の場合: MCP connector ability の追加または編集時に、Tools to use field に comma-separated list で tool name を入力します。すべての tool を許可するには空白のままにします。
  • SDK の場合: connected integration の options に toolsToUse を渡します。
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 を省略するか空にするとすべての tool を許可します。empty ではない list の場合、その中に含まれる exact tool name のみを許可します。

API Connector を MCP Server として公開する​

API connector は、MCP server code を記述せずに、MCP 経由で agent に公開することもできます。Squid は connector schema から MCP server を生成します。各 endpoint は endpoint ID にちなんだ MCP tool になり、tool の description と input parameter は endpoint definition から導出されます。

API connector を MCP server として公開するには、次のようにします。

  1. Squid Console で API connector の configuration を開き、Expose as MCP Server を有効にします。
  2. Squid は https://YOUR_APP_URL/mcp/CONNECTOR_ID で connector 用 MCP server を提供します。server とその tool は console の Backend tab の MCP Servers にも list 化されます。
  3. server を agent に接続します。Agent Studio では connector が MCP ability の中に表示されるため、他の 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 name は connector の endpoint ID と一致するため、specific endpoint への access を制限するには、agent が call できる endpoint ID を entry の options に渡します。

agent が tool を call すると、Squid は直接的な squid.api().request() call と同じ方法で対応する API endpoint を実行します。connector の injection が適用され、endpoint の security rule が enforce されます。Squid は calling user の authorization(bearer token または API key)をすべての tool call とともに forward するため、各 call は shared credential ではなく元の caller identity で実行されます。user が endpoint を直接 call する authorization を持たない場合、agent を通じても access できません。