Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/content/docs/guides/mcp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The [**Model Context Protocol (MCP)**](https://modelcontextprotocol.io) is an op
There are three types of MCP servers this SDK supports:

1. **Hosted MCPserver tools** – remote MCP servers used as tools by the [OpenAI Responses API](https://platform.openai.com/docs/guides/tools-remote-mcp)
1. **Hosted MCP server tools** – remote MCP servers used as tools by the [OpenAI Responses API](https://platform.openai.com/docs/guides/tools-remote-mcp)
2. **Streamable HTTP MCP servers** – local or remote servers that implement the [Streamable HTTP transport](https://modelcontextprotocol.io/docs/concepts/transports#streamable-http)
3. **Stdio MCP servers** – servers accessed via standard input/output (the simplest option)

Expand All @@ -28,7 +28,7 @@ Choose a server type based on your use‑case:
| Call publicly accessible remote servers with default OpenAI responses models | **1. Hosted MCP tools** |
| Use publicly accessible remote servers but have the tool calls triggered locally | **2. Streamable HTTP** |
| Use locally running Streamable HTTP servers | **2. Streamable HTTP** |
| Use any Streamable HTTP servers with non-OpenAI Responses models | **2. Streamable HTTP** |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translation script understands this like "responses compatible models operated by non-OpenAI providers" and that's understandable. So, I just slightly changed the nuance here.

| Use any Streamable HTTP servers with non-OpenAI-Responses models | **2. Streamable HTTP** |
| Work with local MCP servers that only support the standard-I/O protocol | **3. Stdio** |

## 1. Hosted MCP server tools
Expand Down Expand Up @@ -67,7 +67,7 @@ If you can programatically determine whether a tool call is safe, you can use th
title="Human in the loop with hosted MCP tools"
/>

Fully working samples (streaming, approval, HITL) are [examples/mcp](https://github.com/openai/openai-agents-js/tree/main/examples/mcp) in our GitHub repository.
Fully working samples (Hosted tools/Streamable HTTP/stdio + Streaming, HITL, onApproval) are [examples/mcp](https://github.com/openai/openai-agents-js/tree/main/examples/mcp) in our GitHub repository.

## 2. Streamable HTTP MCP servers

Expand Down
56 changes: 28 additions & 28 deletions docs/src/content/docs/ja/guides/mcp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,43 @@ import hostedHITLExample from '../../../../../../examples/docs/mcp/hostedHITL.ts
import streamableHttpExample from '../../../../../../examples/docs/mcp/streamableHttp.ts?raw';
import stdioExample from '../../../../../../examples/docs/mcp/stdio.ts?raw';

[**Model Context Protocol (MCP)**](https://modelcontextprotocol.io) は、アプリケーションが LLM にツールとコンテキストを提供する方法を標準化するオープンプロトコルです。MCP ドキュメントより引用します
[** Model Context Protocol ( MCP ) **](https://modelcontextprotocol.io) は、アプリケーションが LLM にツールとコンテキストを提供する方法を標準化するオープンプロトコルです。MCP ドキュメントでは次のように説明されています

> MCP は、アプリケーションが LLM にコンテキストを提供する方法を標準化するオープンプロトコルです。MCP AI アプリケーション向けの USB-C ポートのようなものと考えてください。USB-C がデバイスをさまざまな周辺機器やアクセサリーに接続するための標準化された方法を提供するのと同様に、MCP は AI モデルをさまざまなデータソースやツールに接続するための標準化された方法を提供します
> MCP は、アプリケーションが LLM にコンテキストを提供する方法を標準化するオープンプロトコルです。MCP AI アプリケーション向けの USB-C ポートと考えてください。USB-C がデバイスをさまざまな周辺機器に接続するための標準化された方法を提供するのと同様に、MCP は AI モデルを複数のデータソースやツールに接続するための標準化された方法を提供します

この SDK がサポートする MCP サーバーには次の 3 種類があります
この SDK がサポートする MCP サーバーは次の 3 種類です

1. **Hosted MCP-server tools** – [OpenAI Responses API](https://platform.openai.com/docs/guides/tools-remote-mcp) によりツールとして呼び出されるリモート MCP サーバー
2. **Streamable HTTP MCP サーバー** – [Streamable HTTP transport](https://modelcontextprotocol.io/docs/concepts/transports#streamable-http) を実装したローカルまたはリモートサーバー
3. **Stdio MCP サーバー** – 標準入力/出力経由でアクセスするサーバー(もっともシンプル
1. **リモート MCP サーバーツール(Hosted)** – [OpenAI Responses API](https://platform.openai.com/docs/guides/tools-remote-mcp) がツールとして利用するリモート MCP サーバー
2. **Streamable HTTP MCP サーバー** – [Streamable HTTP トランスポート](https://modelcontextprotocol.io/docs/concepts/transports#streamable-http) を実装したローカルまたはリモートサーバー
3. **Stdio MCP サーバー** – 標準入力 / 出力経由でアクセスするサーバー(最もシンプルなオプション

ユースケースに応じてサーバータイプを選択してください。

| 必要なこと | 推奨オプション |
| ---------------------------------------------------------------------------------------- | ----------------------- |
| 公開アクセス可能なリモートサーバーを、デフォルトの OpenAI Responses モデルで呼び出したい | **1. Hosted MCP tools** |
| 公開アクセス可能なリモートサーバーを使用しつつ、ツール呼び出しをローカルでトリガーしたい | **2. Streamable HTTP** |
| ローカルで動作する Streamable HTTP サーバーを使用したい | **2. Streamable HTTP** |
| OpenAI 以外の Responses モデルと組み合わせて任意の Streamable HTTP サーバーを使いたい | **2. Streamable HTTP** |
| 標準 I/O プロトコルのみをサポートするローカル MCP サーバーと連携したい | **3. Stdio** |
| 必要なもの | 推奨オプション |
| -------------------------------------------------------------------------------------------- | -------------------------------------------- |
| 公開アクセス可能なリモートサーバーを既定の OpenAI Responses モデルで呼び出したい | **1. リモート MCP サーバーツール(Hosted)** |
| 公開アクセス可能なリモートサーバーを利用するが、ツール呼び出し自体はローカルでトリガーしたい | **2. Streamable HTTP** |
| ローカルで動作する Streamable HTTP サーバーを利用したい | **2. Streamable HTTP** |
| OpenAI Responses 以外のモデルで任意の Streamable HTTP サーバーを利用したい | **2. Streamable HTTP** |
| 標準 I/O プロトコルのみをサポートするローカル MCP サーバーを利用したい | **3. Stdio** |

## 1. Hosted MCP サーバーツール
## 1. リモート MCP サーバーツール(Hosted)

Hosted tool では、往復すべてがモデル内部で完結します。あなたのコードが MCP サーバーを呼び出す代わりに、OpenAI Responses API がリモートツールのエンドポイントを呼び出し、その結果をストリームでモデルに返します
Hosted ツールでは、往復処理をすべてモデル内部で完結させます。コードから MCP サーバーを呼び出す代わりに、OpenAI Responses API がリモートツールのエンドポイントを呼び出し、その結果をストリーミングでモデルに返します

Hosted MCP サーバーツールを使うもっともシンプルな例を示します。`hostedMcpTool` ユーティリティ関数にリモート MCP サーバーのラベルと URL を渡すだけで作成できます
Hosted MCP ツールを利用する最も簡単な例を以下に示します。`hostedMcpTool` ユーティリティ関数にリモート MCP サーバーのラベルと URL を渡して、Hosted MCP サーバーツールを作成します

<Code lang="typescript" code={hostedAgentExample} title="hostedAgent.ts" />

続いて、`run` 関数(またはカスタマイズした `Runner` インスタンスの `run` メソッド)でエージェントを実行します。
次に、`run` 関数(またはカスタマイズした `Runner` インスタンスの `run` メソッド)でエージェントを実行します。

<Code
lang="typescript"
code={hostedExample}
title="Run with hosted MCP tools"
/>

MCP の増分結果をストリーミングする場合は、`Agent` を実行するときに `stream: true` を渡してください
増分的な MCP 実行結果をストリームで受け取りたい場合は、`Agent` を実行するときに `stream: true` を渡します

<Code
lang="typescript"
Expand All @@ -57,47 +57,47 @@ MCP の増分結果をストリーミングする場合は、`Agent` を実行

#### オプションの承認フロー

機微な操作の場合、個々のツール呼び出しに人間の承認を必須にできます。`requireApproval: 'always'` を渡すか、ツール名ごとに `'never'` / `'always'` を指定するオブジェクトを渡してください
機微な操作に対しては、個々のツール呼び出しに人間の承認を要求できます。`requireApproval: 'always'` を渡すか、ツール名ごとに `'never'` / `'always'` を指定する詳細オブジェクトを渡してください

ツール呼び出しが安全かどうかをプログラム的に判断できる場合は、[`onApproval` コールバック](https://github.com/openai/openai-agents-js/blob/main/examples/mcp/hosted-mcp-on-approval.ts) を使って承認または拒否できます。人間の承認が必要な場合は、ローカルの関数ツールと同様に `interruptions` を使用した [人間の介入(HITL)](/openai-agents-js/ja/guides/human-in-the-loop/) のアプローチが利用できます
ツール呼び出しが安全かどうかをプログラムで判断できる場合は、[`onApproval` コールバック](https://github.com/openai/openai-agents-js/blob/main/examples/mcp/hosted-mcp-on-approval.ts) を使って承認または拒否できます。人間の承認が必要な場合は、ローカル関数ツールと同じく `interruptions` を使った [人間の介入(HITL)](/openai-agents-js/ja/guides/human-in-the-loop/) の手法を利用できます

<Code
lang="typescript"
code={hostedHITLExample}
title="Human in the loop with hosted MCP tools"
/>

ストリーミング、承認、HITL を含む完全な動作例は GitHub リポジトリの [examples/mcp](https://github.com/openai/openai-agents-js/tree/main/examples/mcp) にあります。
完全な動作例(Hosted ツール / Streamable HTTP / stdio + Streaming, HITL, onApproval)は GitHub リポジトリの [examples/mcp](https://github.com/openai/openai-agents-js/tree/main/examples/mcp) にあります。

## 2. Streamable HTTP MCP サーバー

エージェントがローカルまたはリモートの Streamable HTTP MCP サーバーと直接通信する場合は、サーバーの `url`、`name`、オプション設定を指定して `MCPServerStreamableHttp` を生成します
エージェントがローカルまたはリモートの Streamable HTTP MCP サーバーに直接接続する場合は、サーバーの `url`、`name` と任意の設定を渡して `MCPServerStreamableHttp` をインスタンス化します

<Code
lang="typescript"
code={streamableHttpExample}
title="Run with Streamable HTTP MCP servers"
/>

コンストラクターでは `authProvider`, `requestInit`, `reconnectionOptions`, `sessionId` など、MCP TypeScript SDK の追加オプションも指定できます。詳細は [MCP TypeScript SDK リポジトリ](https://github.com/modelcontextprotocol/typescript-sdk) とそのドキュメントをご覧ください
コンストラクタは `authProvider``requestInit``reconnectionOptions``sessionId` などの MCP TypeScript-SDK 追加オプションも受け取ります。詳細は [MCP TypeScript SDK リポジトリ](https://github.com/modelcontextprotocol/typescript-sdk) のドキュメントを参照してください

## 3. Stdio MCP サーバー

標準 I/O のみを公開するサーバーには、`fullCommand` を指定して `MCPServerStdio` を生成します
標準 I/O だけを公開しているサーバーには、`fullCommand` を渡して `MCPServerStdio` をインスタンス化します

<Code
lang="typescript"
code={stdioExample}
title="Run with Stdio MCP servers"
/>

## 知っておくべきその他のポイント
## その他のポイント

**Streamable HTTP** および **Stdio** サーバーの場合、`Agent` は実行のたびに利用可能なツールを確認するため `list_tools()` を呼び出すことがあります。この往復は、特にリモートサーバーではレイテンシーを増やす可能性があります。ツールリストが変わらないと確信できる場合は、`MCPServerStdio` または `MCPServerStreamableHttp` に `cacheToolsList: true` を渡して結果をメモリにキャッシュできます
**Streamable HTTP** および **Stdio** サーバーの場合、`Agent` が実行されるたびに使用可能なツールを確認するために `list_tools()` を呼び出すことがあります。この往復処理は、特にリモートサーバーではレイテンシーを増加させるため、`MCPServerStdio` または `MCPServerStreamableHttp` に `cacheToolsList: true` を渡すことで結果をメモリにキャッシュできます

後からキャッシュを無効化したい場合は、サーバーインスタンスの `invalidateToolsCache()` を呼び出してください
ツール一覧が変更されないと確信できる場合にのみ有効化してください。後でキャッシュを無効化するには、サーバーインスタンスの `invalidateToolsCache()` を呼び出します

## 参考文献
## さらに学ぶ

- [Model Context Protocol](https://modelcontextprotocol.io/) – 公式仕様
- [examples/mcp](https://github.com/openai/openai-agents-js/tree/main/examples/mcp) – 上記で参照した実行可能デモ
1 change: 1 addition & 0 deletions docs/src/scripts/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const engToNonEngMapping: Record<string, Record<string, string>> = {
'TypeScript-first': 'TypeScript ファースト',
'Human in the loop': 'Human in the loop (人間の介入)',
'Hosted tool': '組み込みツール(Hosted)',
'Hosted MCP server tools': 'リモート MCP サーバーツール(Hosted)',
raw: '元',
},
};
Expand Down