Skip to main content
You can build an AI SDK agent connected to an MCP server and expose it through one streaming endpoint.

Install and configure

Install @mcpjam/sdk first. It provides MCPClientManager, which connects your agent to an MCP server and exposes MCP tools to AI SDK.

Build the agent

Use MCPClientManager to connect to your MCP server, fetch AI SDK-compatible tools, and pass them directly into streamText in your /api/chat handler.
Then point your widget at the same endpoint:

How this appears in Open Chat Widget

The widget displays MCP tool execution as normal AI SDK tool parts:
  • Tool cards show each tool call and status (running, complete, denied, error).
  • Approval-required tools can be approved or denied in the chat UI.
  • Responses keep streaming while tools are called in agent steps.
Because this is standard AI SDK tool streaming, MCP and non-MCP tools can be mixed in one agent.

Example

MCP example in Open Chat Widget