Function Calling でモデルに提供するツールに加えて、 リモート MCP サーバー や セキュア MCP トンネル を使用して、モデルに新たな機能を追加できます。これらのツールにより、モデルはユーザーのプロンプトに応答するために必要な場合に、外部サービスに接続して操作できるようになります。これらのツール呼び出しは、自動的に許可することも、開発者による明示的な承認を必要とするよう制限することもできます。
このガイドでは、Responses API で MCP ツールを使用する方法を説明します。既存のモデルでは、組み込みコネクタのサポートが継続されます。非推奨化の方針と互換性を維持するための使用例については、レガシーコネクタ を参照してください。Agents API のセッションについては、マネージドサービスまたはサンドボックスからの接続を説明した MCP 接続 を参照してください。
MCP サーバーが非公開、オンプレミス、またはファイアウォールの内側にある場合は、セキュア MCP トンネル を使うと、サーバーをパブリックインターネットに公開せずに、対応する OpenAI 製品に接続できます。最新の公開リリースは openai/tunnel-client からダウンロードしてください。
Responses API で mcp ツールタイプを使用します。リモート MCP サーバーには server_url を設定し、セキュア MCP トンネル 経由でローカル MCP サーバーに接続するには tunnel_id を使用します。サーバーによっては、authorization パラメーターに OAuth アクセストークンを指定する必要もあります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-6-astra",
"tools": [
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "never"
}
],
"input": "Roll 2d4+1"
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "dmcp",
server_description:
"A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: "never",
},
],
input: "Roll 2d4+1",
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from openai import OpenAI
client = OpenAI()
resp = client.responses.create(
model="gpt-6-astra",
tools=[
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "never",
},
],
input="Roll 2d4+1",
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("dmcp")
tool.OfMcp.ServerDescription = openai.String("A Dungeons and Dragons MCP server to assist with dice rolling.")
tool.OfMcp.ServerURL = openai.String("https://dmcp-server.deno.dev/mcp")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{OfMcpToolApprovalSetting: openai.String("never")}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Roll 2d4+1")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.input("Roll 2d4+1")
.addTool(
Tool.Mcp.builder()
.serverLabel("dmcp")
.serverDescription(
"A Dungeons and Dragons MCP server to assist with dice rolling.")
.serverUrl("https://dmcp-server.deno.dev/mcp")
.requireApproval(Tool.Mcp.RequireApproval.McpToolApprovalSetting.NEVER)
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-6-astra" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "dmcp",
serverUri: new Uri("https://dmcp-server.deno.dev/mcp"),
toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.NeverRequireApproval
)
);
options.InputItems.Add(ResponseItem.CreateUserMessageItem("Roll 2d4+1"));
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "dmcp",
server_description: "A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: "never"
}
],
input: "Roll 2d4+1"
)
puts(response.output_text)
開発者にとって、Responses API で使用するすべてのリモート MCP サーバーが信頼できることは極めて重要です。
悪意のあるサーバーは、モデルのコンテキストに含まれるあらゆる情報から機密データを外部に流出させる可能性があります。
このツールを使用する前に、以下の
リスクと安全性 セクションをよく確認してください。
API は、モデルのレスポンスの output 配列に新しい項目を返します。モデルが MCP サーバーを使用すると判断した場合、まずサーバーで利用可能なツールの一覧を取得するリクエストを送信し、mcp_list_tools 出力項目が作成されます。上記のリモート MCP サーバーの例では、この項目に含まれるツール定義は 1 つだけです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 {
"id" : "mcpl_68a6102a4968819c8177b05584dd627b0679e572a900e618" ,
"type" : "mcp_list_tools" ,
"server_label" : "dmcp" ,
"tools" : [
{
"annotations" : null ,
"description" : "Given a string of text describing a dice roll..." ,
"input_schema" : {
"$schema" : "https://json-schema.org/draft/2020-12/schema" ,
"type" : "object" ,
"properties" : {
"diceRollExpression" : {
"type" : "string"
}
},
"required" : [ "diceRollExpression" ],
"additionalProperties" : false
},
"name" : "roll"
}
]
}
モデルが MCP サーバーで利用可能なツールのいずれかを呼び出すと判断した場合は、mcp_call 出力も含まれます。そこには、モデルが MCP ツールに送信した内容と、MCP ツールが出力として返した内容が示されます。
1 2 3 4 5 6 7 8 9 10 {
"id" : "mcp_68a6102d8948819c9b1490d36d5ffa4a0679e572a900e618" ,
"type" : "mcp_call" ,
"approval_request_id" : null ,
"arguments" : "{ \" diceRollExpression \" : \" 2d4 + 1 \" }" ,
"error" : null ,
"name" : "roll" ,
"output" : "4" ,
"server_label" : "dmcp"
}
以下では、MCP ツールの仕組み、利用可能なツールの絞り込み方法、ツール呼び出しの承認リクエストへの対応方法について詳しく説明します。
最近のほとんどのモデルでは、Responses API で MCP ツールを利用できます。使用するモデルが MCP ツールに対応しているかどうかは、こちら で確認してください。MCP ツールの使用時に課金されるのは、ツール定義のインポートやツール呼び出しで使用されるトークン のみです。ツール呼び出しごとの追加料金はかかりません。
以下では、API が MCP ツールを呼び出す際の処理を順に説明します。
tools パラメーターにリモート MCP サーバーを指定すると、API はそのサーバーからツールの一覧を取得しようとします。Responses API は、Streamable HTTP または HTTP/SSE のトランスポートプロトコルに対応するリモート MCP サーバーで動作します。
ツールの一覧を正常に取得すると、モデルのレスポンス出力に新しい mcp_list_tools 出力項目が含まれます。このオブジェクトの tools プロパティには、正常にインポートされたツールが示されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 {
"id" : "mcpl_68a6102a4968819c8177b05584dd627b0679e572a900e618" ,
"type" : "mcp_list_tools" ,
"server_label" : "dmcp" ,
"tools" : [
{
"annotations" : null ,
"description" : "Given a string of text describing a dice roll..." ,
"input_schema" : {
"$schema" : "https://json-schema.org/draft/2020-12/schema" ,
"type" : "object" ,
"properties" : {
"diceRollExpression" : {
"type" : "string"
}
},
"required" : [ "diceRollExpression" ],
"additionalProperties" : false
},
"name" : "roll"
}
]
}
API リクエストのコンテキストに mcp_list_tools 項目が含まれている限り、
API は会話 の各ターンで
MCP サーバーからツールの一覧を再取得しません。
レイテンシーを抑えるため、会話やワークフローを実行する際は常に、
この項目をモデルのコンテキストに保持することを推奨します。
MCP サーバーによっては数十個のツールを備えており、多数のツールをモデルに提供すると、コストやレイテンシーが増大する可能性があります。MCP サーバーが提供するツールの一部だけを使いたい場合は、allowed_tools パラメーターを使って、それらのツールのみをインポートできます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-6-astra",
"tools": [
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "never",
"allowed_tools": ["roll"]
}
],
"input": "Roll 2d4+1"
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "dmcp",
server_description:
"A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: "never",
allowed_tools: ["roll"],
},
],
input: "Roll 2d4+1",
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 from openai import OpenAI
client = OpenAI()
resp = client.responses.create(
model="gpt-6-astra",
tools=[
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "never",
"allowed_tools": ["roll"],
}
],
input="Roll 2d4+1",
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("dmcp")
tool.OfMcp.ServerDescription = openai.String("A Dungeons and Dragons MCP server to assist with dice rolling.")
tool.OfMcp.ServerURL = openai.String("https://dmcp-server.deno.dev/mcp")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{OfMcpToolApprovalSetting: openai.String("never")}
tool.OfMcp.AllowedTools = responses.ToolMcpAllowedToolsUnionParam{OfMcpAllowedTools: []string{"roll"}}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Roll 2d4+1")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
import java.util.List;
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.input("Roll 2d4+1")
.addTool(
Tool.Mcp.builder()
.serverLabel("dmcp")
.serverDescription(
"A Dungeons and Dragons MCP server to assist with dice rolling.")
.serverUrl("https://dmcp-server.deno.dev/mcp")
.requireApproval(Tool.Mcp.RequireApproval.McpToolApprovalSetting.NEVER)
.allowedToolsOfMcp(List.of("roll"))
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-6-astra" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "dmcp",
serverUri: new Uri("https://dmcp-server.deno.dev/mcp"),
allowedTools: new McpToolFilter() { ToolNames = { "roll" } },
toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.NeverRequireApproval
)
);
options.InputItems.Add(ResponseItem.CreateUserMessageItem("Roll 2d4+1"));
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-6-astra",
input: "Roll 2d4+1",
tools: [
{
type: :mcp,
server_label: "dmcp",
server_description: "A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: :never,
allowed_tools: ["roll"]
}
]
)
puts(response.output_text)
モデルがこれらのツール定義にアクセスできるようになると、コンテキストの内容に応じてツールの呼び出しを選択することがあります。モデルが MCP ツールを呼び出すと判断すると、API はリモート MCP サーバーにツール呼び出しをリクエストし、その出力をモデルのコンテキストに追加します。これにより、次のような mcp_call 項目が作成されます。
1 2 3 4 5 6 7 8 9 10 {
"id" : "mcp_68a6102d8948819c9b1490d36d5ffa4a0679e572a900e618" ,
"type" : "mcp_call" ,
"approval_request_id" : null ,
"arguments" : "{ \" diceRollExpression \" : \" 2d4 + 1 \" }" ,
"error" : null ,
"name" : "roll" ,
"output" : "4" ,
"server_label" : "dmcp"
}
この項目には、モデルがこのツール呼び出しで使用すると決めた引数と、リモート MCP サーバーが返した output の両方が含まれます。すべてのモデルは MCP ツールを複数回呼び出すことを選択できるため、1 回の API リクエストでこれらの項目が複数生成される場合があります。
ツール呼び出しが失敗した場合、この項目の error フィールドに MCP プロトコルエラー、MCP ツール実行エラー、または一般的な接続エラーが設定されます。MCP エラーについては、こちら の MCP 仕様に記載されています。
デフォルトでは、コネクタやリモート MCP サーバーとデータを共有する前に、OpenAI が承認を求めます。承認を通じて、MCP サーバーに送信されるデータを把握し、管理できます。リモート MCP サーバーと共有するすべてのデータを慎重にレビューし、必要に応じてログに記録することを強く推奨します。MCP ツール呼び出しの承認リクエストが行われると、Response の出力に次のような mcp_approval_request 項目が作成されます。
1 2 3 4 5 6 7 {
"id" : "mcpr_68a619e1d82c8190b50c1ccba7ad18ef0d2d23a86136d339" ,
"type" : "mcp_approval_request" ,
"arguments" : "{ \" diceRollExpression \" : \" 2d4 + 1 \" }" ,
"name" : "roll" ,
"server_label" : "dmcp"
}
これに応答するには、新しい Response オブジェクトを作成し、mcp_approval_response 項目を追加します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-6-astra",
"tools": [
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "always",
}
],
"previous_response_id": "resp_682d498bdefc81918b4a6aa477bfafd904ad1e533afccbfa",
"input": [{
"type": "mcp_approval_response",
"approve": true,
"approval_request_id": "mcpr_682d498e3bd4819196a0ce1664f8e77b04ad1e533afccbfa"
}]
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "dmcp",
server_description:
"A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: "always",
},
],
previous_response_id: "resp_682d498bdefc81918b4a6aa477bfafd904ad1e533afccbfa",
input: [
{
type: "mcp_approval_response",
approve: true,
approval_request_id:
"mcpr_682d498e3bd4819196a0ce1664f8e77b04ad1e533afccbfa",
},
],
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 from openai import OpenAI
client = OpenAI()
resp = client.responses.create(
model="gpt-6-astra",
tools=[
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "always",
}
],
previous_response_id="resp_682d498bdefc81918b4a6aa477bfafd904ad1e533afccbfa",
input=[
{
"type": "mcp_approval_response",
"approve": True,
"approval_request_id": "mcpr_682d498e3bd4819196a0ce1664f8e77b04ad1e533afccbfa",
}
],
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("dmcp")
tool.OfMcp.ServerDescription = openai.String("A Dungeons and Dragons MCP server to assist with dice rolling.")
tool.OfMcp.ServerURL = openai.String("https://dmcp-server.deno.dev/mcp")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{OfMcpToolApprovalSetting: openai.String("always")}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
PreviousResponseID: openai.String("resp_682d498bdefc81918b4a6aa477bfafd904ad1e533afccbfa"),
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMcpApprovalResponse("mcpr_682d498e3bd4819196a0ce1664f8e77b04ad1e533afccbfa", true),
}},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.ResponseInputItem;
import com.openai.models.responses.Tool;
import java.util.List;
String responseId = "resp_682d498bdefc81918b4a6aa477bfafd904ad1e533afccbfa";
String approvalRequestId = "mcpr_682d498e3bd4819196a0ce1664f8e77b04ad1e533afccbfa";
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.input(
ResponseCreateParams.Input.ofResponse(
List.of(
ResponseInputItem.ofMcpApprovalResponse(
ResponseInputItem.McpApprovalResponse.builder()
.approvalRequestId(approvalRequestId)
.approve(true)
.build()))))
.previousResponseId(responseId)
.addTool(
Tool.Mcp.builder()
.serverLabel("dmcp")
.serverDescription("A Dungeons and Dragons MCP server.")
.serverUrl("https://dmcp-server.deno.dev/mcp")
.requireApproval(Tool.Mcp.RequireApproval.McpToolApprovalSetting.ALWAYS)
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-6-astra" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "dmcp",
serverUri: new Uri("https://dmcp-server.deno.dev/mcp"),
toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.AlwaysRequireApproval
)
);
// Step 1: Create a response that requests tool-call approval.
options.InputItems.Add(ResponseItem.CreateUserMessageItem("Roll 2d4+1"));
ResponseResult response1 = await client.CreateResponseAsync(options);
McpToolCallApprovalRequestItem approvalRequest =
response1.OutputItems.OfType<McpToolCallApprovalRequestItem>().Single();
// Step 2: Approve the tool call and get the final response.
options.PreviousResponseId = response1.Id;
options.InputItems.Clear();
options.InputItems.Add(
ResponseItem.CreateMcpApprovalResponseItem(approvalRequest.Id, approved: true)
);
ResponseResult response2 = await client.CreateResponseAsync(options);
Console.WriteLine(response2.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-6-astra",
previous_response_id: "resp_682d498bdefc81918b4a6aa477bfafd904ad1e533afccbfa",
input: [
{
type: :mcp_approval_response,
approval_request_id: "mcpr_682d498e3bd4819196a0ce1664f8e77b04ad1e533afccbfa",
approve: true
}
],
tools: [
{
type: :mcp,
server_label: "dmcp",
server_url: "https://dmcp-server.deno.dev/mcp",
server_description: "A Dungeons and Dragons MCP server.",
require_approval: :always
}
]
)
puts(response.output_text)
ここでは、previous_response_id パラメーターを使用して、承認リクエストを生成した前のレスポンスに新しいレスポンスをつなげています。また、あるレスポンスの出力を別のレスポンスへの入力として渡す ことで、モデルのコンテキストに含める内容を細かく制御することもできます。
リモート MCP サーバーを十分に信頼できると判断した場合は、承認を省略してレイテンシーを抑えることができます。そのためには、以下の例のように、承認を省略したいツールだけを列挙したオブジェクトを MCP ツールの require_approval パラメーターに設定します。または、値を 'never' に設定すると、そのリモート MCP サーバーのすべてのツールで承認を省略できます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-6-astra",
"tools": [
{
"type": "mcp",
"server_label": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": {
"never": {
"tool_names": ["ask_question", "read_wiki_structure"]
}
}
}
],
"input": "What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?"
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "deepwiki",
server_url: "https://mcp.deepwiki.com/mcp",
require_approval: {
never: {
tool_names: ["ask_question", "read_wiki_structure"],
},
},
},
],
input:
"What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?",
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 from openai import OpenAI
client = OpenAI()
resp = client.responses.create(
model="gpt-6-astra",
tools=[
{
"type": "mcp",
"server_label": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": {
"never": {"tool_names": ["ask_question", "read_wiki_structure"]}
},
},
],
input="What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?",
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("deepwiki")
tool.OfMcp.ServerURL = openai.String("https://mcp.deepwiki.com/mcp")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{
OfMcpToolApprovalFilter: &responses.ToolMcpRequireApprovalMcpToolApprovalFilterParam{
Never: responses.ToolMcpRequireApprovalMcpToolApprovalFilterNeverParam{
ToolNames: []string{"ask_question", "read_wiki_structure"},
},
},
}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.input("What transport protocols does the 2025-03-26 version of the MCP spec support?")
.addTool(
Tool.Mcp.builder()
.serverLabel("deepwiki")
.serverUrl("https://mcp.deepwiki.com/mcp")
.requireApproval(
Tool.Mcp.RequireApproval.McpToolApprovalFilter.builder()
.never(
Tool.Mcp.RequireApproval.McpToolApprovalFilter.Never.builder()
.addToolName("ask_question")
.addToolName("read_wiki_structure")
.build())
.build())
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-6-astra" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "deepwiki",
serverUri: new Uri("https://mcp.deepwiki.com/mcp"),
toolCallApprovalPolicy: new CustomMcpToolCallApprovalPolicy
{
ToolsNeverRequiringApproval = new McpToolFilter
{
ToolNames = { "ask_question", "read_wiki_structure" },
},
}
)
);
options.InputItems.Add(
ResponseItem.CreateUserMessageItem(
"What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?"
)
);
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-6-astra",
input: "What transport protocols does the 2025-03-26 version of the MCP spec support?",
tools: [
{
type: :mcp,
server_label: "deepwiki",
server_url: "https://mcp.deepwiki.com/mcp",
require_approval: {
never: { tool_names: ["ask_question", "read_wiki_structure"] }
}
}
]
)
puts(response.output_text)
上記の例で使用した MCP サーバー とは異なり、ほとんどの MCP サーバーは認証を必要とします。最も一般的なのは、OAuth アクセストークンを使う方式です。このトークンは、MCP ツールの authorization フィールドで渡します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-6-astra",
"input": "Create a payment link for $20",
"tools": [
{
"type": "mcp",
"server_label": "stripe",
"server_url": "https://mcp.stripe.com",
"authorization": "$STRIPE_OAUTH_ACCESS_TOKEN"
}
]
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-6-astra",
input: "Create a payment link for $20",
tools: [
{
type: "mcp",
server_label: "stripe",
server_url: "https://mcp.stripe.com",
authorization: "$STRIPE_OAUTH_ACCESS_TOKEN",
},
],
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import os
from openai import OpenAI
client = OpenAI()
authorization = os.environ["STRIPE_OAUTH_ACCESS_TOKEN"]
resp = client.responses.create(
model="gpt-6-astra",
input="Create a payment link for $20",
tools=[
{
"type": "mcp",
"server_label": "stripe",
"server_url": "https://mcp.stripe.com",
"authorization": authorization,
}
],
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
authorization := os.Getenv("STRIPE_OAUTH_ACCESS_TOKEN")
if authorization == "" {
panic("STRIPE_OAUTH_ACCESS_TOKEN is required")
}
client := openai.NewClient()
tool := responses.ToolParamOfMcp("stripe")
tool.OfMcp.ServerURL = openai.String("https://mcp.stripe.com")
tool.OfMcp.Authorization = openai.String(authorization)
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Create a payment link for $20")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
String stripeAccessToken = System.getenv("STRIPE_OAUTH_ACCESS_TOKEN");
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.input("Create a payment link for $20.")
.addTool(
Tool.Mcp.builder()
.serverLabel("stripe")
.serverUrl("https://mcp.stripe.com")
.authorization(stripeAccessToken)
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 using OpenAI.Responses;
#pragma warning disable OPENAI001
string authToken =
Environment.GetEnvironmentVariable("STRIPE_OAUTH_ACCESS_TOKEN")!;
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-6-astra" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "stripe",
serverUri: new Uri("https://mcp.stripe.com"),
authorizationToken: authToken
)
);
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("Create a payment link for $20")
);
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-6-astra",
input: "Create a payment link for $20.",
tools: [
{
type: :mcp,
server_label: "stripe",
server_url: "https://mcp.stripe.com",
authorization: ENV.fetch("STRIPE_OAUTH_ACCESS_TOKEN")
}
]
)
puts(response.output_text)
機密性の高いトークンの漏えいを防ぐため、Responses API は authorization フィールドに指定された値を保存しません。この値は、作成された Response オブジェクトにも表示されません。そのため、Responses API の作成リクエストを行うたびに、authorization の値を送信する必要があります。
connector_id は、2026 年 9 月 1 日より後にリリースされたモデルでは非推奨です。
リモート MCP サーバーに接続するには server_url を使用します。また、
セキュア MCP トンネル を介してローカル MCP サーバーに接続するには tunnel_id を使用します。
既存のモデルではコネクタのサポートが継続されます。
このセクションの例では、この基準日より前にリリースされた
gpt-5.2 を使用します。
Responses API は、サードパーティーサービス向けの一部のコネクタに標準で対応しています。これらのコネクタを使うと、Dropbox や Gmail などの主要なアプリケーションからコンテキストを取り込み、モデルが主要サービスとやり取りできるようになります。
コネクタは、リモート MCP サーバーと同じように使用できます。どちらも、API リクエスト内で OpenAI モデルがサードパーティーの追加ツールにアクセスできるようにします。ただし、リモート MCP サーバーを呼び出す際に渡す server_url の代わりに、API で利用可能なコネクタを一意に識別する connector_id を渡します。
コネクタを使用するには、アプリケーションから authorization パラメーターに OAuth アクセストークンを指定する必要があります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-5.2",
"tools": [
{
"type": "mcp",
"server_label": "Dropbox",
"connector_id": "connector_dropbox",
"authorization": "<oauth access token>",
"require_approval": "never"
}
],
"input": "Summarize the Q2 earnings report."
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-5.2",
tools: [
{
type: "mcp",
server_label: "Dropbox",
connector_id: "connector_dropbox",
authorization: "<oauth access token>",
require_approval: "never",
},
],
input: "Summarize the Q2 earnings report.",
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import os
from openai import OpenAI
client = OpenAI()
connector_authorization = os.environ["OPENAI_CONNECTOR_AUTHORIZATION"]
resp = client.responses.create(
model="gpt-5.2",
tools=[
{
"type": "mcp",
"server_label": "Dropbox",
"connector_id": "connector_dropbox",
"authorization": connector_authorization,
"require_approval": "never",
},
],
input="Summarize the Q2 earnings report.",
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("Dropbox")
tool.OfMcp.ConnectorID = "connector_dropbox"
tool.OfMcp.Authorization = openai.String("<oauth access token>")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{OfMcpToolApprovalSetting: openai.String("never")}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.2",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Summarize the Q2 earnings report.")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
String oauthAccessToken = "<oauth access token>";
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-5.2")
.input("Summarize the Q2 earnings report.")
.addTool(
Tool.Mcp.builder()
.serverLabel("Dropbox")
.connectorId(Tool.Mcp.ConnectorId.of("connector_dropbox"))
.authorization(oauthAccessToken)
.requireApproval(Tool.Mcp.RequireApproval.McpToolApprovalSetting.NEVER)
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 using OpenAI.Responses;
#pragma warning disable OPENAI001
string dropboxToken =
Environment.GetEnvironmentVariable("DROPBOX_OAUTH_ACCESS_TOKEN")!;
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-5.2" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "Dropbox",
connectorId: McpToolConnectorId.Dropbox,
authorizationToken: dropboxToken,
toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.NeverRequireApproval
)
);
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("Summarize the Q2 earnings report.")
);
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-5.2",
input: "Summarize the Q2 earnings report.",
tools: [
{
type: :mcp,
server_label: "Dropbox",
connector_id: "connector_dropbox",
authorization: "<oauth access token>",
require_approval: :never
}
]
)
puts(response.output_text)
Dropbox: connector_dropbox
Gmail: connector_gmail
Google Calendar: connector_googlecalendar
Google Drive: connector_googledrive
Microsoft Teams: connector_microsoftteams
Outlook Calendar: connector_outlookcalendar
Outlook Email: connector_outlookemail
SharePoint: connector_sharepoint
公式のリモート MCP サーバーがないサービスを優先しました。たとえば GitHub には公式の MCP サーバーがあり、MCP ツールの server_url フィールドに https://api.githubcopilot.com/mcp/ を渡すことで接続できます。
authorization フィールドに OAuth アクセストークンを渡します。OAuth クライアントの登録と認可は、アプリケーション側で別途処理する必要があります。
テストには、Google の OAuth 2.0 Playground を使って、API リクエストで利用できる一時的なアクセストークンを生成できます。
Playground でコネクタの API 機能をテストするには、まず次の値を入力します。
https://www.googleapis.com/auth/calendar.events
この認可スコープにより、API が Google Calendar の予定を読み取れるようになります。UI の「ステップ 1: API の選択と認可」欄に入力します。
Google アカウントでアプリケーションを認可すると、 ステップ 2: 認可コードをトークンに交換 に進みます。ここで、Google Calendar コネクタを使う API リクエストで利用できるアクセストークンが生成されます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY " \
-d '{
"model": "gpt-5.2",
"tools": [
{
"type": "mcp",
"server_label": "google_calendar",
"connector_id": "connector_googlecalendar",
"authorization": "ya29.A0AS3H6...",
"require_approval": "never"
}
],
"input": "What is on my Google Calendar for today?"
}' 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-5.2",
tools: [
{
type: "mcp",
server_label: "google_calendar",
connector_id: "connector_googlecalendar",
authorization: "ya29.A0AS3H6...",
require_approval: "never",
},
],
input: "What's on my Google Calendar for today?",
});
console.log(resp.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import os
from openai import OpenAI
client = OpenAI()
authorization = os.environ["GOOGLE_CALENDAR_OAUTH_ACCESS_TOKEN"]
resp = client.responses.create(
model="gpt-5.2",
tools=[
{
"type": "mcp",
"server_label": "google_calendar",
"connector_id": "connector_googlecalendar",
"authorization": authorization,
"require_approval": "never",
},
],
input="What's on my Google Calendar for today?",
)
print(resp.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("google_calendar")
tool.OfMcp.ConnectorID = "connector_googlecalendar"
tool.OfMcp.Authorization = openai.String("<oauth access token>")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{OfMcpToolApprovalSetting: openai.String("never")}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.2",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("What's on my Google Calendar for today?")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
String oauthAccessToken = "<oauth access token>";
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-5.2")
.input("What's on my Google Calendar for today?")
.addTool(
Tool.Mcp.builder()
.serverLabel("google_calendar")
.connectorId(Tool.Mcp.ConnectorId.of("connector_googlecalendar"))
.authorization(oauthAccessToken)
.requireApproval(Tool.Mcp.RequireApproval.McpToolApprovalSetting.NEVER)
.build())
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 using OpenAI.Responses;
#pragma warning disable OPENAI001
string authToken =
Environment.GetEnvironmentVariable("GOOGLE_CALENDAR_OAUTH_ACCESS_TOKEN")!;
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-5.2" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "google_calendar",
connectorId: McpToolConnectorId.GoogleCalendar,
authorizationToken: authToken,
toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.NeverRequireApproval
)
);
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("What's on my Google Calendar for today?")
);
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-5.2",
input: "What's on my Google Calendar for today?",
tools: [
{
type: :mcp,
server_label: "google_calendar",
connector_id: "connector_googlecalendar",
authorization: "<oauth access token>",
require_approval: :never
}
]
)
puts(response.output_text)
コネクタの MCP ツール呼び出しは、リモート MCP サーバーの MCP ツール呼び出しと同じ形式で、出力項目の型には mcp_call を使用します。この例では、コネクタへの引数とコネクタからのレスポンスは、どちらも JSON 文字列です。
1 2 3 4 5 6 7 8 9 10 {
"id" : "mcp_68a62ae1c93c81a2b98c29340aa3ed8800e9b63986850588" ,
"type" : "mcp_call" ,
"approval_request_id" : null ,
"arguments" : "{ \" time_min \" : \" 2025-08-20T00:00:00 \" , \" time_max \" : \" 2025-08-21T00:00:00 \" , \" timezone_str \" :null, \" max_results \" :50, \" query \" :null, \" calendar_id \" :null, \" next_page_token \" :null}" ,
"error" : null ,
"name" : "search_events" ,
"output" : "{ \" events \" : [{ \" id \" : \" 2n8ni54ani58pc3ii6soelupcs_20250820 \" , \" summary \" : \" Home \" , \" location \" : null, \" start \" : \" 2025-08-20T00:00:00 \" , \" end \" : \" 2025-08-21T00:00:00 \" , \" url \" : \" https://www.google.com/calendar/event?eid=Mm44bmk1NGFuaTU4cGMzaWk2c29lbHVwY3NfMjAyNTA4MjAga3doaW5uZXJ5QG9wZW5haS5jb20&ctz=America/Los_Angeles \" , \" description \" : \"\\ n \\ n \" , \" transparency \" : \" transparent \" , \" display_url \" : \" https://www.google.com/calendar/event?eid=Mm44bmk1NGFuaTU4cGMzaWk2c29lbHVwY3NfMjAyNTA4MjAga3doaW5uZXJ5QG9wZW5haS5jb20&ctz=America/Los_Angeles \" , \" display_title \" : \" Home \" }], \" next_page_token \" : null}" ,
"server_label" : "Google_Calendar"
}
利用可能なツールは、OAuth トークンに付与されたスコープによって異なります。以下の表を展開すると、各アプリケーションへの接続時に利用できるツールを確認できます。
Dropbox ツール
説明
スコープ search
クエリに一致するファイルを Dropbox で検索します。
files.metadata.read, account_info.read fetch
パスを指定してファイルを取得します。オプションで元の形式のままダウンロードできます。
files.content.read search_files
Dropbox のファイルを検索し、結果を返します。
files.metadata.read, account_info.read fetch_file
ファイルのテキストまたは元の形式のコンテンツを取得します。
files.content.read, account_info.read list_recent_files
ユーザーがアクセスできるファイルのうち、直近に更新されたものを返します。
files.metadata.read, account_info.read get_profile
現在のユーザーの Dropbox プロファイルを取得します。
account_info.read
Gmail ツール
説明
スコープ get_profile
現在の Gmail ユーザーのプロファイルを返します。
userinfo.email, userinfo.profile search_emails
クエリまたはラベルに一致するメールを Gmail で検索します。
gmail.modify search_email_ids
検索条件に一致する Gmail メッセージの ID を取得します。
gmail.modify get_recent_emails
直近に受信した Gmail メッセージを返します。
gmail.modify read_email
Gmail メッセージを 1 件、本文を含めて取得します。
gmail.modify batch_read_email
1 回の呼び出しで複数の Gmail メッセージを読み取ります。
gmail.modify
Google Calendar ツール
説明
スコープ get_profile
現在の Calendar ユーザーのプロファイルを返します。
userinfo.email, userinfo.profile search
Calendar の予定を検索します。オプションで期間を指定できます。
calendar.events fetch
Calendar の予定 1 件の詳細を取得します。
calendar.events search_events
フィルターを使って Calendar の予定を検索します。
calendar.events read_event
ID を指定して Google Calendar の予定を読み取ります。
calendar.events
Google Drive ツール
説明
スコープ get_profile
現在の Drive ユーザーのプロファイルを返します。
userinfo.email, userinfo.profile list_drives
ユーザーがアクセスできる共有ドライブの一覧を取得します。
drive.readonly search
クエリを使って Drive のファイルを検索します。
drive.readonly recent_documents
直近に更新されたドキュメントを返します。
drive.readonly fetch
Drive ファイルのコンテンツをダウンロードします。
drive.readonly
Microsoft Teams ツール
説明
スコープ search
Microsoft Teams のチャットとチャネルのメッセージを検索します。
Chat.Read, ChannelMessage.Read.All fetch
パスを指定して Teams のメッセージを取得します。
Chat.Read, ChannelMessage.Read.All get_chat_members
Teams チャットのメンバーの一覧を取得します。
Chat.Read get_profile
認証済みの Teams ユーザーのプロファイルを返します。
User.Read
Outlook Calendar ツール
説明
スコープ search_events
日付フィルターを使って Outlook Calendar の予定を検索します。
Calendars.Read fetch_event
予定 1 件の詳細を取得します。
Calendars.Read fetch_events_batch
1 回の呼び出しで複数の予定を取得します。
Calendars.Read list_events
指定した日付範囲内のカレンダーの予定を一覧で取得します。
Calendars.Read get_profile
現在のユーザーのプロファイルを取得します。
User.Read
Outlook Email ツール
説明
スコープ get_profile
Outlook アカウントのプロファイル情報を返します。
User.Read list_messages
フォルダーから Outlook のメールを取得します。
Mail.Read search_messages
Outlook のメールを検索します。必要に応じてフィルターを指定できます。
Mail.Read get_recent_emails
直近に受信したメールを返します。
Mail.Read fetch_message
ID を指定してメールを 1 件取得します。
Mail.Read fetch_messages_batch
1 回のリクエストで複数のメールを取得します。
Mail.Read
Sharepoint ツール
説明
スコープ get_site
ホスト名とパスから SharePoint サイトを特定します。
Sites.Read.All search
キーワードで SharePoint/OneDrive のドキュメントを検索します。
Sites.Read.All, Files.Read.All list_recent_documents
最近アクセスしたドキュメントを返します。
Files.Read.All fetch
Graph のファイルダウンロード URL からコンテンツを取得します。
Files.Read.All get_profile
現在のユーザーのプロファイルを取得します。
User.Read
ツール検索 を使用する場合、MCP サーバーが公開する関数の読み込みを、モデルが必要と判断するまで遅らせることができます。これを行うには、MCP サーバーのツール定義に defer_loading: true を設定します。
MCP サーバーの読み込みを遅らせても、モデルはサーバーのラベルと説明を使って、いつそのサーバーを検索するか判断できます。ただし、個々の関数定義は必要になったときにのみ読み込まれます。これにより、全体のトークン使用量を削減できる可能性があります。特に、多数の関数を公開する MCP サーバーで効果的です。
1
2
3
4
5
6
7
8 {
"type" : "mcp" ,
"server_label" : "dmcp" ,
"server_description" : "A Dungeons and Dragons MCP server to assist with dice rolling." ,
"server_url" : "https://dmcp-server.deno.dev/mcp" ,
"defer_loading" : true ,
"require_approval" : "never"
}
MCP ツールを使うと、OpenAI のモデルを外部サービスに接続できます。これは強力な機能ですが、いくつかのリスクも伴います。
コネクタには、機密データを OpenAI に送信してしまうリスクや、接続先のサービスにある機密性の高い可能性があるデータへの読み取りアクセスをモデルに許可してしまうリスクがあります。
リモート MCP サーバーには同じリスクがあり、さらに OpenAI による検証も行われていません。これらのサーバーを通じて、モデルはサービス内のデータにアクセスし、データを送受信し、操作を実行できます。すべての MCP サーバーはサードパーティのサービスであり、それぞれの利用規約が適用されます。
悪意のある MCP サーバーを見つけた場合は、security@openai.com まで報告してください。
以下に、コネクタやリモート MCP サーバーを統合する際に検討すべきベストプラクティスを紹介します。
プロンプトインジェクション は、あらゆる LLM アプリケーションで考慮すべき重要なセキュリティ上の問題です。特に、機密データへのアクセスや操作の実行が可能な MCP サーバーやコネクタへのアクセスをモデルに許可する場合は、注意が必要です。モデルへのプロンプトにユーザーが提供したコンテンツが含まれる場合は、適切な注意を払い、保護措置を講じたうえでこれらのツールを使用してください。
require_approval パラメーターと allowed_tools パラメーターの設定を活用し、機密性の高い操作には必ず承認フローが必要になるようにしてください。
コネクタやリモート MCP サーバーのツール呼び出しの出力に含まれる URL にリクエストを送信したり、画像 URL を埋め込んだりすることには、危険が伴う場合があります。これらの URL をアプリケーションのコードに埋め込むなどして使用する前に、URL の提供元のドメインやサービスが信頼できることを確認してください。
サービスの提供元自身がホストする公式サーバーを選んでください。たとえば、サードパーティがホストする Stripe MCP サーバーではなく、Stripe が mcp.stripe.com でホストする Stripe サーバーへの接続を推奨します。現時点では公式のリモート MCP サーバーがまだ少ないため、サービスのサーバーを運営していない組織がホストし、お客様の API を介してそのサービスへのリクエストを中継する MCP サーバーの利用を考えるかもしれません。やむを得ず利用する場合は、こうした「アグリゲーター」の信頼性を特に入念に調査し、データの利用方法を慎重に確認してください。
MCP サーバーは独自にツールを定義するため、そのサーバーのホスト元とは共有したくないデータを要求する場合があります。このため、Responses API の MCP ツールでは、デフォルトで MCP ツールの呼び出しごとに承認が必要です。アプリケーションの開発時には、これらの MCP サーバーと共有されるデータの種類を慎重かつ徹底的に確認してください。その MCP サーバーを十分に信頼できると確信したら、承認を省略して実行時のレイテンシーを抑えることができます。
MCP サーバーに送信するすべてのデータを記録することも推奨します。Responses API を store=true で使用している場合、組織でゼロデータ保持が有効になっていなければ、これらのデータは API を通じてすでに 30 日間記録されています。データが想定どおりに共有されていることを確認するため、自社のシステムにも記録し、定期的にレビューすることを検討してください。
悪意のある MCP サーバーには、OpenAI のモデルに予期しない動作をさせるための隠された指示(プロンプトインジェクション)が含まれている可能性があります。OpenAI は、こうした脅威の検出と阻止を支援する安全対策を組み込んでいますが、入出力を慎重に確認し、信頼できるサーバーにのみ接続することが不可欠です。
MCP サーバーではツールの動作が予期せず変更されることがあり、意図しない動作や悪意のある動作につながる可能性があります。
MCP ツールはゼロデータ保持とデータレジデンシーに対応しています。ただし、MCP サーバーはサードパーティのサービスであり、送信したデータにはそのサービスのデータ保持ポリシーとデータレジデンシーポリシーが適用される点に注意してください。
つまり、欧州でのデータレジデンシーを利用している組織の場合、OpenAI は、MCP サーバーに通信やデータが送信される時点までは、お客様のコンテンツの推論と保存を欧州内に限定します。MCP サーバーも、お客様が求めるゼロデータ保持やデータレジデンシーの要件を満たしていることを確認する責任は、お客様にあります。ゼロデータ保持とデータレジデンシーの詳細は、こちら をご覧ください。
対応 API
レート制限
備考 ティア 1
200 RPM
ティア 2 および 3
1000 RPM
ティア 4 および 5
2000 RPM
料金
ZDR とデータレジデンシー