Skip to content

Commit be32c05

Browse files
docs(guides): document local MCP tools (#65)
1 parent adeb218 commit be32c05

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

docs/src/content/docs/guides/tools.mdx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import toolsFunctionExample from '../../../../../examples/docs/tools/functionToo
88
import toolsHostedToolsExample from '../../../../../examples/docs/tools/hostedTools.ts?raw';
99
import nonStrictSchemaTools from '../../../../../examples/docs/tools/nonStrictSchemaTools.ts?raw';
1010
import agentsAsToolsExample from '../../../../../examples/docs/tools/agentsAsTools.ts?raw';
11+
import mcpLocalServer from '../../../../../examples/docs/tools/mcpLocalServer.ts?raw';
1112

1213
Tools let an Agent **take actions** – fetch data, call external APIs, execute code, or even use a
13-
computer. The JavaScript/TypeScript SDK supports three categories:
14+
computer. The JavaScript/TypeScript SDK supports four categories:
1415

1516
1. **Hosted tools** – run alongside the model on OpenAI servers. _(web search, file search, computer use, code interpreter, image generation)_
1617
2. **Function tools** – wrap any local function with a JSON schema so the LLM can call it.
1718
3. **Agents as tools** – expose an entire Agent as a callable tool.
19+
4. **Local MCP servers** – attach a Model Context Protocol server running on your machine.
1820

1921
---
2022

@@ -86,6 +88,17 @@ Under the hood the SDK:
8688

8789
---
8890

91+
## 4. Local MCP servers
92+
93+
You can expose tools via a local [Model Context Protocol](https://modelcontextprotocol.io/) server and attach them to an agent.
94+
Use `MCPServerStdio` to spawn and connect to the server:
95+
96+
<Code lang="typescript" code={mcpLocalServer} title="Local MCP server" />
97+
98+
See [`filesystem-example.ts`](https://github.com/openai/openai-agents-js/tree/main/examples/mcp/filesystem-example.ts) for a complete example.
99+
100+
---
101+
89102
## Tool use behaviour
90103

91104
Refer to the [Agents guide](/openai-agents-js/guides/agents#forcing-tool-use) for controlling when and how a model

docs/src/content/docs/ja/guides/tools.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import toolsFunctionExample from '../../../../../../examples/docs/tools/function
88
import toolsHostedToolsExample from '../../../../../../examples/docs/tools/hostedTools.ts?raw';
99
import nonStrictSchemaTools from '../../../../../../examples/docs/tools/nonStrictSchemaTools.ts?raw';
1010
import agentsAsToolsExample from '../../../../../../examples/docs/tools/agentsAsTools.ts?raw';
11+
import mcpLocalServer from '../../../../../../examples/docs/tools/mcpLocalServer.ts?raw';
1112

12-
ツールを使うことで、エージェントは **行動を実行** できます。たとえばデータの取得、外部 API の呼び出し、コードの実行、さらにはコンピュータ操作まで可能です。JavaScript / TypeScript SDK は次の 3 カテゴリーをサポートします:
13+
ツールを使うことで、エージェントは **行動を実行** できます。たとえばデータの取得、外部 API の呼び出し、コードの実行、さらにはコンピュータ操作まで可能です。JavaScript / TypeScript SDK は次の 4 カテゴリーをサポートします:
1314

1415
1. **組み込みツール(Hosted)** – モデルと同じ OpenAI サーバー上で動作します。 _(Web 検索、ファイル検索、コンピュータ操作、Code Interpreter、画像生成)_
1516
2. **関数ツール** – 任意のローカル関数を JSON スキーマでラップし、LLM から呼び出せるようにします。
1617
3. **エージェントをツールとして使用** – エージェント全体を呼び出し可能なツールとして公開します。
18+
4. **ローカル MCP サーバー** – ローカルで動作する Model Context Protocol サーバーをエージェントに追加します。
1719

1820
---
1921

@@ -82,6 +84,16 @@ SDK は内部で次の処理を行います:
8284

8385
---
8486

87+
## 4. ローカル MCP サーバー
88+
89+
ローカルで動作する [Model Context Protocol](https://modelcontextprotocol.io/) サーバーからツールを公開し、エージェントに接続できます。`MCPServerStdio` を使用してサーバーを起動し接続します:
90+
91+
<Code lang="typescript" code={mcpLocalServer} title="Local MCP server" />
92+
93+
`filesystem-example.ts` の完全な例もご覧ください。
94+
95+
---
96+
8597
## ツール使用の挙動
8698

8799
ツールを **いつ・どのように** 使うかを制御する方法は、[エージェント](/openai-agents-js/ja/guides/agents#forcing-tool-use) を参照してください (`tool_choice``toolUseBehavior` など)。
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Agent, MCPServerStdio } from '@openai/agents';
2+
3+
const server = new MCPServerStdio({
4+
fullCommand: 'npx -y @modelcontextprotocol/server-filesystem ./sample_files',
5+
});
6+
7+
await server.connect();
8+
9+
const agent = new Agent({
10+
name: 'Assistant',
11+
mcpServers: [server],
12+
});

0 commit comments

Comments
 (0)