Testing Guide: agui-test-server → mcpui-test-server Integration
November 23, 2025 · View on GitHub
Overview
This guide explains how to test that agui-test-server makes tool calls to mcpui-test-server. The integration works as follows:
- agui-test-server runs an LLM agent that receives tool calls from an LLM
- When a tool call is detected, it uses the MCP client to call tools on mcpui-test-server
- mcpui-test-server executes the tool and returns UI resources
- agui-test-server streams the results back as AG-UI events
Architecture
┌─────────────────┐ ┌──────────────────┐
│ agui-test-server │─────────▶│ mcpui-test-server│
│ (Port 3000) │ HTTP │ (Port 3100) │
│ │◀─────────│ │
└─────────────────┘ └──────────────────┘
│
│ AG-UI Events (SSE)
▼
Client/NeuronKit
Key Components
agui-test-server:
src/mcp/client.ts- MCP client managersrc/mcp/http-transport.ts- HTTP transport for MCP protocolsrc/agents/llm.ts- LLM agent that calls MCP tools (lines 338-430)src/server.ts- Initializes MCP connection on startup (lines 78-107)
mcpui-test-server:
src/server.ts- Express server with MCP endpointssrc/tools/- All available tools (HTML, URL, Remote DOM, etc.)
Setup Instructions
Step 1: Build Both Servers
# Build mcpui-test-server
cd mcpui-test-server
npm install
npm run build
# Build agui-test-server
cd ../agui-test-server
npm install
npm run build
Step 2: Configure agui-test-server
Create or edit .env file in agui-test-server/:
Option A: HTTP Transport (Recommended for Testing)
# Server configuration
PORT=3000
HOST=0.0.0.0
LOG_LEVEL=debug
LOG_PRETTY=true
# Agent mode - must be 'llm' to enable MCP tool calls
AGENT_MODE=llm
# LLM Configuration (choose one)
# Option 1: LiteLLM
LLM_PROVIDER=litellm
LITELLM_ENDPOINT=http://localhost:4000/v1
LITELLM_API_KEY=your-key-here
LITELLM_MODEL=deepseek-chat
# Option 2: DeepSeek Direct
# LLM_PROVIDER=deepseek
# DEEPSEEK_API_KEY=your-deepseek-key
# DEEPSEEK_MODEL=deepseek-chat
# MCP Configuration - HTTP Transport
MCP_SERVER_URL=http://localhost:3100/mcp
Option B: stdio Transport (Alternative)
# MCP Configuration - stdio transport
MCP_SERVER_COMMAND=node
MCP_SERVER_ARGS=../mcpui-test-server/dist/server.js
Step 3: Start mcpui-test-server
cd mcpui-test-server
PORT=3100 npm start
You should see:
🚀 MCP-UI Test Server running at http://0.0.0.0:3100
📡 MCP endpoint: POST/GET/DELETE /mcp
❤️ Health check: GET /health
🔧 Tools list: GET /tools
Step 4: Start agui-test-server
cd agui-test-server
npm start
Look for these log messages:
✅ Success indicators:
Initializing MCP client with HTTP transport { url: 'http://localhost:3100/mcp' }
Using HTTP transport for MCP connection { serverId: 'mcpui-server', url: 'http://localhost:3100/mcp' }
Connected to MCP server { serverId: 'mcpui-server', transport: 'http' }
MCP client initialized successfully
AG-UI Test Server started
❌ Failure indicators:
Failed to initialize MCP client, continuing without MCP support
Testing Methods
Method 1: Using the HTTP Integration Test Script
The repository includes a test script:
cd compliance-servers
chmod +x test-http-mcp-integration.sh
./test-http-mcp-integration.sh
This script:
- Builds both servers
- Starts mcpui-test-server on port 3100
- Starts agui-test-server on port 3000
- Tests MCP protocol directly
- Tests agui-test-server agent endpoint
- Verifies HTTP transport usage
Method 2: Manual Testing with cURL
Test 1: Verify mcpui-test-server is Running
curl http://localhost:3100/health
Expected response:
{
"status": "ok",
"timestamp": "2025-01-XX...",
"uptime": 123.45,
"sessions": 0,
"version": "1.0.0"
}
Test 2: Verify agui-test-server Connected to MCP
curl http://localhost:3000/health
Check the agui-test-server logs - you should see MCP connection messages.
Test 3: Trigger Tool Call via LLM Agent
Prerequisites: You need a working LLM (LiteLLM or DeepSeek API key)
curl -X POST http://localhost:3000/agent \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"threadId": "test-123",
"runId": "run_1",
"messages": [
{
"id": "msg-1",
"role": "user",
"content": "Show me a simple HTML page"
}
],
"tools": [],
"context": []
}'
What to look for in the response:
- TOOL_CALL_START event with tool name (e.g.,
showSimpleHtml) - TOOL_CALL_ARGS events with arguments
- TOOL_CALL_END event
- TOOL_CALL_RESULT event with text content
- CUSTOM event with
name: "mcp-ui-resource"containing the UI resource
Expected event flow:
event: message
data: {"type":"RUN_STARTED","threadId":"test-123","runId":"run_1"}
event: message
data: {"type":"TEXT_MESSAGE_START","messageId":"msg_xxx","role":"assistant"}
event: message
data: {"type":"TEXT_MESSAGE_CHUNK","messageId":"msg_xxx","delta":"I'll show you..."}
event: message
data: {"type":"TOOL_CALL_START","toolCallId":"call_xxx","toolCallName":"showSimpleHtml","parentMessageId":"msg_xxx"}
event: message
data: {"type":"TOOL_CALL_ARGS","toolCallId":"call_xxx","delta":"{}"}
event: message
data: {"type":"TOOL_CALL_END","toolCallId":"call_xxx"}
event: message
data: {"type":"TOOL_CALL_RESULT","toolCallId":"call_xxx","messageId":"msg_result_xxx","content":"Tool executed successfully","role":"tool"}
event: message
data: {"type":"CUSTOM","name":"mcp-ui-resource","value":{"type":"resource","resource":{"uri":"mcp-ui://html/...","mimeType":"text/html"}}}
event: message
data: {"type":"RUN_FINISHED","threadId":"test-123","runId":"run_1"}
Method 3: Testing Without LLM (Emulated Mode)
If you don't have an LLM configured, you can test the MCP connection directly:
Test MCP Connection Status
Check if the MCP client is connected by looking at server logs on startup. The connection happens in src/server.ts lines 78-107.
Test Direct MCP Tool Call (Bypassing LLM)
You can modify the scenario agent to test MCP calls, or create a test endpoint. However, the current implementation only calls MCP tools when:
- Agent mode is
llm(notemulated) - LLM returns a tool call
- MCP server ID is configured (
mcpServerId: 'mcpui-server')
Monitoring and Debugging
Key Log Messages to Watch
agui-test-server logs:
-
On startup:
Initializing MCP client with HTTP transport Using HTTP transport for MCP connection Connected to MCP server MCP client initialized successfully -
When tool call happens:
Executing tool via MCP { toolCallId: '...', toolName: 'showSimpleHtml', mcpServerId: 'mcpui-server' } Calling MCP tool { serverId: 'mcpui-server', toolName: 'showSimpleHtml', args: {...} } MCP tool call completed { serverId: 'mcpui-server', toolName: 'showSimpleHtml', contentCount: 1 } Emitted MCP UI resource as CUSTOM event -
On errors:
Failed to execute MCP tool { toolCallId: '...', toolName: '...', error: '...' }
mcpui-test-server logs:
-
On connection:
Received MCP POST request MCP session initialized { sessionId: '...' } -
On tool call:
Tool called: showSimpleHtml
Common Issues and Solutions
Issue 1: MCP Client Not Initializing
Symptoms:
- Log shows "Failed to initialize MCP client"
- No MCP connection messages
Solutions:
- Check
MCP_SERVER_URLis correct:http://localhost:3100/mcp - Verify mcpui-test-server is running:
curl http://localhost:3100/health - Check network connectivity between servers
- Review error logs for specific error messages
Issue 2: Tool Calls Not Happening
Symptoms:
- LLM responds but no tool calls are made
- No
TOOL_CALL_STARTevents in response
Solutions:
- Verify
AGENT_MODE=llm(notemulated) - Check LLM is configured correctly (API keys, endpoints)
- Ensure LLM actually returns tool calls (some prompts may not trigger tools)
- Check
mcpServerIdis set in agent factory (src/routes/agent-factory.tsline 46 or 62)
Issue 3: Tool Call Fails
Symptoms:
TOOL_CALL_STARTappears butTOOL_CALL_RESULTshows error- Log shows "Failed to execute MCP tool"
Solutions:
- Verify tool name matches available tools:
curl http://localhost:3100/tools - Check tool arguments are valid JSON
- Review mcpui-test-server logs for errors
- Verify MCP session is still active
Issue 4: HTTP Transport Not Working
Symptoms:
- Connection fails with HTTP errors
- Session ID not being maintained
Solutions:
- Check
MCP_SERVER_URLincludes/mcppath - Verify CORS is configured correctly in mcpui-test-server
- Check
mcp-session-idheader is being sent/received - Review HTTP transport implementation (
src/mcp/http-transport.ts)
Code Flow Analysis
How Tool Calls Work
-
LLM Agent receives tool call (
src/agents/llm.ts:284-327)- Parses tool call from LLM stream
- Emits
TOOL_CALL_START,TOOL_CALL_ARGS,TOOL_CALL_ENDevents
-
MCP tool execution (
src/agents/llm.ts:338-430)- Checks if MCP client is connected:
mcpClientManager.isConnected('mcpui-server') - Parses tool arguments from JSON
- Calls MCP tool:
mcpClientManager.callTool('mcpui-server', toolName, args)
- Checks if MCP client is connected:
-
MCP client makes HTTP request (
src/mcp/client.ts:111-153)- Uses HTTP transport to send
tools/callrequest - Receives response with tool result
- Uses HTTP transport to send
-
HTTP transport (
src/mcp/http-transport.ts:62-190)- Sends POST request to
http://localhost:3100/mcp - Includes
mcp-session-idheader - Parses SSE or JSON response
- Sends POST request to
-
Results streamed back (
src/agents/llm.ts:375-408)- Emits
TOOL_CALL_RESULTwith text content - Emits
CUSTOMevents for UI resources
- Emits
Connection Initialization
On server startup (src/server.ts:78-107):
if (config.mcpServerUrl || config.mcpServerCommand) {
let mcpConfig: MCPClientConfig;
if (config.mcpServerUrl) {
mcpConfig = { url: config.mcpServerUrl };
} else if (config.mcpServerCommand) {
mcpConfig = {
command: config.mcpServerCommand,
args: config.mcpServerArgs
};
}
await mcpClientManager.connect('mcpui-server', mcpConfig);
}
Available Tools for Testing
The mcpui-test-server provides these tools (check with curl http://localhost:3100/tools):
showSimpleHtml- Simple HTML pageshowInteractiveForm- Form with validationshowComplexLayout- Multi-column layoutshowAnimatedContent- Animated HTMLshowResponsiveCard- Responsive card layoutshowExampleSite- External URL (example.com)showCustomUrl- Custom URLshowApiDocs- API documentation URLshowRemoteDomButton- Remote DOM buttonshowRemoteDomForm- Remote DOM formshowRemoteDomChart- Remote DOM chartshowRemoteDomWebComponents- Web componentsshowWithPreferredSize- With preferred size metadatashowWithRenderData- With render data metadatashowResponsiveLayout- Responsive layoutshowAsyncToolCall- Async protocol demoshowProgressIndicator- Progress indicator
Example Test Prompts
Try these prompts with the LLM agent to trigger different tools:
- "Show me a simple HTML page" →
showSimpleHtml - "Display example.com" →
showExampleSite - "Show me a form" →
showInteractiveForm - "Create a button with counter" →
showRemoteDomButton - "Show me a chart" →
showRemoteDomChart
Verification Checklist
- Both servers build successfully
- mcpui-test-server starts on port 3100
- agui-test-server starts on port 3000
- MCP client initializes successfully (check logs)
- Health endpoints respond correctly
- LLM agent mode is configured (
AGENT_MODE=llm) - LLM API keys/endpoints are configured
- Tool calls appear in event stream
- Tool results are returned correctly
- UI resources appear as CUSTOM events
- No errors in server logs
Next Steps
Once basic testing works:
- Test with different tools
- Test error scenarios (invalid tool names, network failures)
- Test session management (multiple concurrent requests)
- Test with real NeuronKit client
- Monitor performance and resource usage
- Test cloud deployment scenarios
Additional Resources
test-http-mcp-integration.sh- Automated test scripttest-mcp-integration.sh- Manual test guidedocs/cloud-deployment-guide.md- Deployment guide