You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/cookbook/01-next/73-mcp-tools.mdx
+37-18Lines changed: 37 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,24 +12,25 @@ The AI SDK supports Model Context Protocol (MCP) tools by offering a lightweight
12
12
13
13
Let's create a route handler for `/api/completion` that will generate text based on the input prompt and MCP tools that can be called at any time during a generation. The route will call the `streamText` function from the `ai` module, which will then generate text based on the input prompt and stream it to the client.
14
14
15
-
To use the `StreamableHTTPClientTransport`, you will need to install the official Typescript SDK for Model Context Protocol:
15
+
If you prefer to use the official transports (optional), install the official TypeScript SDK for Model Context Protocol:
The AI SDK supports Model Context Protocol (MCP) tools by offering a lightweight client that exposes a `tools` method for retrieving tools from a MCP server. After use, the client should always be closed to release resources.
10
10
11
-
Use the official Model Context Protocol Typescript SDK to create the connection to the MCP server.
11
+
If you prefer to use the official transports (optional), install the official Model Context Protocol TypeScript SDK.
Copy file name to clipboardExpand all lines: content/docs/03-ai-sdk-core/16-mcp-tools.mdx
+36-12Lines changed: 36 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,35 @@ We recommend using HTTP transport (like `StreamableHTTPClientTransport`) for pro
18
18
19
19
Create an MCP client using one of the following transport options:
20
20
21
-
-**HTTP transport (Recommended)**: Use transports from MCP's official TypeScript SDK like `StreamableHTTPClientTransport` for production deployments
21
+
-**HTTP transport (Recommended)**: Either configure HTTP directly via the client using `transport: { type: 'http', ... }`, or use MCP's official TypeScript SDK `StreamableHTTPClientTransport`
22
22
- SSE (Server-Sent Events): An alternative HTTP-based transport
23
23
-`stdio`: For local development only. Uses standard input/output streams for local MCP servers
24
24
25
25
### HTTP Transport (Recommended)
26
26
27
-
For production deployments, we recommend using HTTP transports like `StreamableHTTPClientTransport` from MCP's official TypeScript SDK:
27
+
For production deployments, we recommend using the HTTP transport. You can configure it directly on the client:
SSE provides an alternative HTTP-based transport option. Configure it with a `type` and `url` property:
62
+
SSE provides an alternative HTTP-based transport option. Configure it with a `type` and `url` property. You can also provide an `authProvider` for OAuth:
0 commit comments