AG-UI agent transport
Understand how MCP Stack Agents expose AG-UI to frontends while MCP servers, Gateway, budgets, logs, and permissions stay server-side.
MCP Stack Agents speak AG-UI at the frontend boundary. That lets AgentSDK, CopilotKit, or a custom AG-UI client connect to the same agent without changing how servers, Gateway, or AuthGateway work.
For the customer-facing overview, see AG-UI agents for SaaS apps. For the dogfood dashboard surface, see In-app agent operations.
AgentSDK / CopilotKit / custom AG-UI frontend
-> AG-UI
MCP Stack Agent
-> MCP
MCP Stack Server
-> Gateway / AuthGateway
-> SaaS APIAG-UI clients run an agent through:
POST /api/v1/agents/{agentId}/ag-ui
Accept: text/event-stream
Authorization: Bearer mcpstack_pk_...The response is a data-only Server-Sent Events stream. Each data: payload is an AG-UI event object with a type.
The agent stream includes:
frontendToolsfrontendTools are AG-UI frontend tools. They are right for local app behavior:
Frontend tools should not perform authoritative backend writes directly. If a durable write matters for audit, permissions, or consistency, expose it as a server MCP tool.
Server tools still run through MCP Stack's server-side path.
For app-token embeds, AgentSDK forwards the current host-app token with the AG-UI run. When the agent needs a server MCP tool, MCP Stack exchanges that host token through Gateway, starts an MCP session, calls the tool, records the result, and continues the agent run.
That means AG-UI does not bypass:
AgentSDK is the first-party integration point:
import { useAppAgent } from "@mcpstack/agent-sdk/react";
const agent = useAppAgent({
apiKey: "mcpstack_pk_...",
agentId: "ag_support",
appSessionKey: session.id,
userIdentity: {
subject: user.id,
email: user.email,
organizationId,
},
auth: {
mode: "app-token",
getToken: () => session.getAccessToken(),
},
appContext: {
page: "ticket-detail",
ticketId,
},
frontendTools,
});AgentSDK uses AG-UI for agent turns. The public app model is useAppAgent, createAppAgent, and McpStackChat, with frontendTools for app-local actions.
A custom AG-UI client should send:
threadId for conversation continuityrunId for the current runmessages with the latest user message or tool resulttools for frontend tool schemascontext or forwardedProps.mcpstack.context for app contextforwardedProps.mcpstack.externalUserId or externalUser for budget and identity attributionUse frontendTools or AG-UI frontend tools for app-local behavior. Use MCP servers for authoritative backend capabilities.
AG-UI is the frontend protocol for MCP Stack Agents. MCP remains the server tool protocol, and Gateway/AuthGateway remain the control layer for backend access.
In the MCP Stack dashboard, the embedded MCP Stack Operator uses this same AgentSDK AG-UI path. Its browser tools provide page context, navigation, approval cards, and rendering; its server tools still run through the seeded MCP Stack Operations MCP server.