Deploy AG-UI servers in AgentCore Runtime
Amazon Bedrock AgentCore Runtime lets you deploy and run Agent User Interface (AG-UI) servers in the AgentCore Runtime. This guide walks you through creating, testing, and deploying your first AG-UI server.
In this section, you learn:
-
How Amazon Bedrock AgentCore supports AG-UI
-
How to create an AG-UI server
-
How to test your server locally
-
How to deploy your server to AWS
-
How to invoke your deployed server
For more information about AG-UI, see AG-UI protocol contract.
How Amazon Bedrock AgentCore supports AG-UI
Amazon Bedrock AgentCore’s AG-UI protocol support enables integration with agent user interface servers by acting as a proxy layer. When configured for AG-UI, Amazon Bedrock AgentCore expects containers to run servers on port 8080 at the /invocations path for HTTP/SSE or /ws for WebSocket connections. Although AG-UI uses the same port and paths as the HTTP protocol, the runtime distinguishes between them based on the --protocol flag specified during deployment configuration.
Amazon Bedrock AgentCore acts as a proxy between clients and your AG-UI container. Requests from the InvokeAgentRuntime API are passed through to your container without modification. Amazon Bedrock AgentCore handles authentication (SigV4/OAuth 2.0), session isolation, and scaling.
Key differences from other protocols:
- Port
-
AG-UI servers run on port 8080 (same as HTTP, vs 8000 for MCP, 9000 for A2A)
- Path
-
AG-UI servers use
/invocationsfor HTTP/SSE and/wsfor WebSocket (same as HTTP protocol) - Message Format
-
Uses event streams via Server-Sent Events (SSE) for streaming, or WebSocket for bidirectional communication
- Protocol Focus
-
Agent-to-User interaction (vs MCP for tools, A2A for agent-to-agent)
- Authentication
-
Supports both SigV4 and OAuth 2.0 authentication schemes
For more information, see https://docs.ag-ui.com/introduction
Using AG-UI with AgentCore Runtime
In this tutorial you create, test, and deploy an AG-UI server.
For complete examples and framework-specific implementations, see AG-UI Quickstart Documentation
Topics
Prerequisites
-
Python 3.12 or higher, or Node.js 18+ for TypeScript, installed with a basic understanding of your chosen language
-
An AWS account with appropriate permissions and local credentials configured
-
Understanding of the AG-UI protocol and event-based agent-to-user communication concepts
Step 1: Create your AG-UI server
AG-UI is supported by multiple agent frameworks. Choose the framework that best fits your needs. AWS Strands provides first-party AG-UI integrations for both Python and TypeScript.
Install required packages
Install packages for AWS Strands with AG-UI support:
Example
For other frameworks, see the AG-UI framework integrations
Create your first AG-UI server
Create your AG-UI server file in the language of your choice. Both examples below produce a server that listens on port 8080 , exposes /invocations for AG-UI traffic, and /ping for health checks — the contract that AgentCore Runtime expects from AG-UI containers.
Example
For complete, framework-specific examples, see:
Understanding the code
- Event Streams
-
AG-UI uses Server-Sent Events (SSE) to stream typed events to the client
- /invocations Endpoint
-
Primary endpoint for HTTP/SSE communication (same as HTTP protocol)
- Port 8080
-
AG-UI servers run on port 8080 by default in AgentCore Runtime
Step 2: Test your AG-UI server locally
Run and test your AG-UI server in a local development environment.
Start your AG-UI server
Run your AG-UI server locally:
Example
You should see output indicating the server is running on port 8080.
Test the endpoint
Test the SSE endpoint with a properly formatted AG-UI request:
curl -N -X POST http://localhost:8080/invocations \ -H "Content-Type: application/json" \ -d '{ "threadId": "test-123", "runId": "run-456", "state": {}, "messages": [{"role": "user", "content": "Hello, agent!", "id": "msg-1"}], "tools": [], "context": [], "forwardedProps": {} }'
You should see AG-UI event streams returned in SSE format, including RUN_STARTED , TEXT_MESSAGE_CONTENT , and RUN_FINISHED events.
Step 3: Deploy your AG-UI server to Bedrock AgentCore Runtime
Deploy your AG-UI server to AWS using the Amazon Bedrock AgentCore starter toolkit.
Install deployment tools
Install the Amazon Bedrock AgentCore starter toolkit:
pip install bedrock-agentcore-starter-toolkit
Start by creating a project folder with the following structure:
Example
Set up Cognito user pool for authentication
Configure authentication for secure access to your deployed server. For detailed Cognito setup instructions, see Set up Cognito user pool for authentication . This provides the OAuth tokens required for secure access to your deployed server.
Configure your AG-UI server for deployment
After setting up authentication, create the deployment configuration. Pass the entrypoint that matches the language you used:
Example
-
Select protocol as AGUI
-
Configure with OAuth configuration as setup in the previous step
Deploy to AWS
Deploy your agent:
agentcore deploy
After deployment, you’ll receive an agent runtime ARN that looks like:
arn:aws:bedrock-agentcore:us-west-2:accountId:runtime/my_agui_server-xyz123
Step 4: Invoke your deployed AG-UI server
Invoke your deployed Amazon Bedrock AgentCore AG-UI server and interact with the event streams.
Set up environment variables
Set up environment variables
-
Export bearer token as an environment variable. For bearer token setup, see Set up Cognito user pool for authentication.
export BEARER_TOKEN="<BEARER_TOKEN>" -
Export the agent ARN.
export AGENT_ARN="arn:aws:bedrock-agentcore:us-west-2:accountId:runtime/my_agui_server-xyz123"
Invoke the AG-UI server
To invoke the AG-UI server programmatically, choose the language that matches your client:
Example
For building full UI applications, see CopilotKit
Appendix
Set up Cognito user pool for authentication
For detailed Cognito setup instructions, see Set up Cognito user pool for authentication in the MCP documentation. The setup process is identical for AG-UI servers.
Troubleshooting
Common AG-UI-specific issues
The following are common issues you might encounter:
- Port conflicts
-
AG-UI servers must run on port 8080 in the AgentCore Runtime environment
- Authorization method mismatch
-
Make sure your request uses the same authentication method (OAuth or SigV4) that the agent was configured with
- Event format errors
-
Ensure your events follow the AG-UI protocol specification. See AG-UI Events Documentation