Skip to content

Commit 469cefa

Browse files
authored
docs: explain hosted mcp connectors (#447)
1 parent f398241 commit 469cefa

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

docs/src/content/docs/guides/mcp.mdx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import hostedAgentExample from '../../../../../examples/docs/mcp/hostedAgent.ts?
88
import hostedExample from '../../../../../examples/docs/mcp/hosted.ts?raw';
99
import hostedStreamExample from '../../../../../examples/docs/mcp/hostedStream.ts?raw';
1010
import hostedHITLExample from '../../../../../examples/docs/mcp/hostedHITL.ts?raw';
11+
import hostedConnectorExample from '../../../../../examples/docs/mcp/hostedConnector.ts?raw';
1112
import streamableHttpExample from '../../../../../examples/docs/mcp/streamableHttp.ts?raw';
1213
import stdioExample from '../../../../../examples/docs/mcp/stdio.ts?raw';
1314
import toolFilterExample from '../../../../../examples/docs/mcp/tool-filter.ts?raw';
@@ -68,6 +69,18 @@ If you can programmatically determine whether a tool call is safe, you can use t
6869
title="Human in the loop with hosted MCP tools"
6970
/>
7071

72+
### Connector-backed hosted servers
73+
74+
Hosted MCP also supports OpenAI connectors. Instead of providing a `serverUrl`, pass the connector's `connectorId` and an `authorization` token. The Responses API then handles authentication and exposes the connector's tools through the hosted MCP interface.
75+
76+
<Code
77+
lang="typescript"
78+
code={hostedConnectorExample}
79+
title="Connector-backed hosted MCP tool"
80+
/>
81+
82+
In this example the `GOOGLE_CALENDAR_AUTHORIZATION` environment variable holds an OAuth token obtained from the Google OAuth Playground, which authorizes the connector-backed server to call the Calendar API. For a runnable sample that also demonstrates streaming, see [`examples/connectors`](https://github.com/openai/openai-agents-js/tree/main/examples/connectors).
83+
7184
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.
7285

7386
## 2. Streamable HTTP MCP servers
@@ -102,11 +115,7 @@ Only enable this if you're confident the tool list won't change. To invalidate t
102115

103116
You can restrict which tools are exposed from each server by passing either a static filter via `createMCPToolStaticFilter` or a custom function. Here’s a combined example showing both approaches:
104117

105-
<Code
106-
lang="typescript"
107-
code={toolFilterExample}
108-
title="Tool filtering"
109-
/>
118+
<Code lang="typescript" code={toolFilterExample} title="Tool filtering" />
110119

111120
## Further reading
112121

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import hostedAgentExample from '../../../../../../examples/docs/mcp/hostedAgent.
88
import hostedExample from '../../../../../../examples/docs/mcp/hosted.ts?raw';
99
import hostedStreamExample from '../../../../../../examples/docs/mcp/hostedStream.ts?raw';
1010
import hostedHITLExample from '../../../../../../examples/docs/mcp/hostedHITL.ts?raw';
11+
import hostedConnectorExample from '../../../../../../examples/docs/mcp/hostedConnector.ts?raw';
1112
import streamableHttpExample from '../../../../../../examples/docs/mcp/streamableHttp.ts?raw';
1213
import stdioExample from '../../../../../../examples/docs/mcp/stdio.ts?raw';
1314
import toolFilterExample from '../../../../../../examples/docs/mcp/tool-filter.ts?raw';
@@ -68,6 +69,18 @@ Hosted ツールは、往復の処理全体をモデル側に任せます。あ
6869
title="Human in the loop with hosted MCP tools"
6970
/>
7071

72+
### コネクター対応の Hosted サーバー
73+
74+
Hosted MCP は OpenAI コネクターにも対応しています。`serverUrl` の代わりにコネクターの `connectorId``authorization` トークンを指定すると、Responses API が認証を処理し、コネクターが公開するツールを hosted MCP インターフェース経由で利用できます。
75+
76+
<Code
77+
lang="typescript"
78+
code={hostedConnectorExample}
79+
title="Connector-backed hosted MCP tool"
80+
/>
81+
82+
この例では、`GOOGLE_CALENDAR_AUTHORIZATION` 環境変数に Google OAuth Playground で取得した OAuth トークンを保存し、コネクター経由で Calendar API を呼び出しています。ストリーミングを含む実行可能なサンプルは [`examples/connectors`](https://github.com/openai/openai-agents-js/tree/main/examples/connectors) を参照してください。
83+
7184
完全に動作するサンプル(Hosted ツール/Streamable HTTP/stdio + Streaming、HITL、onApproval)は、GitHub リポジトリの [examples/mcp](https://github.com/openai/openai-agents-js/tree/main/examples/mcp) にあります。
7285

7386
## 2. Streamable HTTP MCP servers
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Agent, hostedMcpTool } from '@openai/agents';
2+
3+
const authorization = process.env.GOOGLE_CALENDAR_AUTHORIZATION!;
4+
5+
export const connectorAgent = new Agent({
6+
name: 'Calendar Assistant',
7+
instructions:
8+
"You are a helpful assistant that can answer questions about the user's calendar.",
9+
tools: [
10+
hostedMcpTool({
11+
serverLabel: 'google_calendar',
12+
connectorId: 'connector_googlecalendar',
13+
authorization,
14+
requireApproval: 'never',
15+
}),
16+
],
17+
});

0 commit comments

Comments
 (0)