Update MCP and tool docs (#736)
## Summary - mention MCPServerStreamableHttp in MCP server docs - document CodeInterpreterTool, HostedMCPTool, ImageGenerationTool and LocalShellTool - update Japanese translations
This commit is contained in:
parent
db462e32a3
commit
a96108e279
4 changed files with 16 additions and 6 deletions
|
|
@ -12,12 +12,13 @@ Agents SDK は MCP をサポートしており、これにより幅広い MCP
|
|||
|
||||
## MCP サーバー
|
||||
|
||||
現在、MCP 仕様では使用するトランスポート方式に基づき 2 種類のサーバーが定義されています。
|
||||
現在、MCP 仕様では使用するトランスポート方式に基づき 3 種類のサーバーが定義されています。
|
||||
|
||||
1. **stdio** サーバー: アプリケーションのサブプロセスとして実行されます。ローカルで動かすイメージです。
|
||||
1. **stdio** サーバー: アプリケーションのサブプロセスとして実行されます。ローカルで動かすイメージです。
|
||||
2. **HTTP over SSE** サーバー: リモートで動作し、 URL 経由で接続します。
|
||||
3. **Streamable HTTP** サーバー: MCP 仕様に定義された Streamable HTTP トランスポートを使用してリモートで動作します。
|
||||
|
||||
これらのサーバーへは [`MCPServerStdio`][agents.mcp.server.MCPServerStdio] と [`MCPServerSse`][agents.mcp.server.MCPServerSse] クラスを使用して接続できます。
|
||||
これらのサーバーへは [`MCPServerStdio`][agents.mcp.server.MCPServerStdio]、[`MCPServerSse`][agents.mcp.server.MCPServerSse]、[`MCPServerStreamableHttp`][agents.mcp.server.MCPServerStreamableHttp] クラスを使用して接続できます。
|
||||
|
||||
たとえば、[公式 MCP filesystem サーバー](https://www.npmjs.com/package/@modelcontextprotocol/server-filesystem)を利用する場合は次のようになります。
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ agent=Agent(
|
|||
|
||||
## キャッシュ
|
||||
|
||||
エージェントが実行されるたびに、MCP サーバーへ `list_tools()` が呼び出されます。サーバーがリモートの場合は特にレイテンシが発生します。ツール一覧を自動でキャッシュしたい場合は、[`MCPServerStdio`][agents.mcp.server.MCPServerStdio] と [`MCPServerSse`][agents.mcp.server.MCPServerSse] の両方に `cache_tools_list=True` を渡してください。ツール一覧が変更されないと確信できる場合のみ使用してください。
|
||||
エージェントが実行されるたびに、MCP サーバーへ `list_tools()` が呼び出されます。サーバーがリモートの場合は特にレイテンシが発生します。ツール一覧を自動でキャッシュしたい場合は、[`MCPServerStdio`][agents.mcp.server.MCPServerStdio]、[`MCPServerSse`][agents.mcp.server.MCPServerSse]、[`MCPServerStreamableHttp`][agents.mcp.server.MCPServerStreamableHttp] の各クラスに `cache_tools_list=True` を渡してください。ツール一覧が変更されないと確信できる場合のみ使用してください。
|
||||
|
||||
キャッシュを無効化したい場合は、サーバーで `invalidate_tools_cache()` を呼び出します。
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ OpenAI は [`OpenAIResponsesModel`][agents.models.openai_responses.OpenAIRespons
|
|||
- [`WebSearchTool`][agents.tool.WebSearchTool] はエージェントに Web 検索を行わせます。
|
||||
- [`FileSearchTool`][agents.tool.FileSearchTool] は OpenAI ベクトルストアから情報を取得します。
|
||||
- [`ComputerTool`][agents.tool.ComputerTool] はコンピュータ操作タスクを自動化します。
|
||||
- [`CodeInterpreterTool`][agents.tool.CodeInterpreterTool] はサンドボックス環境でコードを実行します。
|
||||
- [`HostedMCPTool`][agents.tool.HostedMCPTool] はリモート MCP サーバーのツールをモデルから直接利用できるようにします。
|
||||
- [`ImageGenerationTool`][agents.tool.ImageGenerationTool] はプロンプトから画像を生成します。
|
||||
- [`LocalShellTool`][agents.tool.LocalShellTool] はローカルマシンでシェルコマンドを実行します。
|
||||
|
||||
```python
|
||||
from agents import Agent, FileSearchTool, Runner, WebSearchTool
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ Currently, the MCP spec defines two kinds of servers, based on the transport mec
|
|||
|
||||
1. **stdio** servers run as a subprocess of your application. You can think of them as running "locally".
|
||||
2. **HTTP over SSE** servers run remotely. You connect to them via a URL.
|
||||
3. **Streamable HTTP** servers run remotely using the Streamable HTTP transport defined in the MCP spec.
|
||||
|
||||
You can use the [`MCPServerStdio`][agents.mcp.server.MCPServerStdio] and [`MCPServerSse`][agents.mcp.server.MCPServerSse] classes to connect to these servers.
|
||||
You can use the [`MCPServerStdio`][agents.mcp.server.MCPServerStdio], [`MCPServerSse`][agents.mcp.server.MCPServerSse], and [`MCPServerStreamableHttp`][agents.mcp.server.MCPServerStreamableHttp] classes to connect to these servers.
|
||||
|
||||
For example, this is how you'd use the [official MCP filesystem server](https://www.npmjs.com/package/@modelcontextprotocol/server-filesystem).
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ agent=Agent(
|
|||
|
||||
## Caching
|
||||
|
||||
Every time an Agent runs, it calls `list_tools()` on the MCP server. This can be a latency hit, especially if the server is a remote server. To automatically cache the list of tools, you can pass `cache_tools_list=True` to both [`MCPServerStdio`][agents.mcp.server.MCPServerStdio] and [`MCPServerSse`][agents.mcp.server.MCPServerSse]. You should only do this if you're certain the tool list will not change.
|
||||
Every time an Agent runs, it calls `list_tools()` on the MCP server. This can be a latency hit, especially if the server is a remote server. To automatically cache the list of tools, you can pass `cache_tools_list=True` to [`MCPServerStdio`][agents.mcp.server.MCPServerStdio], [`MCPServerSse`][agents.mcp.server.MCPServerSse], and [`MCPServerStreamableHttp`][agents.mcp.server.MCPServerStreamableHttp]. You should only do this if you're certain the tool list will not change.
|
||||
|
||||
If you want to invalidate the cache, you can call `invalidate_tools_cache()` on the servers.
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ OpenAI offers a few built-in tools when using the [`OpenAIResponsesModel`][agent
|
|||
- The [`WebSearchTool`][agents.tool.WebSearchTool] lets an agent search the web.
|
||||
- The [`FileSearchTool`][agents.tool.FileSearchTool] allows retrieving information from your OpenAI Vector Stores.
|
||||
- The [`ComputerTool`][agents.tool.ComputerTool] allows automating computer use tasks.
|
||||
- The [`CodeInterpreterTool`][agents.tool.CodeInterpreterTool] lets the LLM execute code in a sandboxed environment.
|
||||
- The [`HostedMCPTool`][agents.tool.HostedMCPTool] exposes a remote MCP server's tools to the model.
|
||||
- The [`ImageGenerationTool`][agents.tool.ImageGenerationTool] generates images from a prompt.
|
||||
- The [`LocalShellTool`][agents.tool.LocalShellTool] runs shell commands on your machine.
|
||||
|
||||
```python
|
||||
from agents import Agent, FileSearchTool, Runner, WebSearchTool
|
||||
|
|
|
|||
Loading…
Reference in a new issue