This directory contains example clients, configuration templates, and usage patterns for the Agent Platform.
simple_client.py- Comprehensive Python gRPC client examplecursor-mcp-config.json- Cursor IDE MCP configuration templateREADME.md- This file
✅ The router handles service discovery and routes requests to backend services.
❌ Do NOT connect directly to backend service ports (they use dynamic ports).
The cursor-mcp-config.json file provides a ready-to-use configuration for connecting Cursor IDE to the Agent Platform via the Model Context Protocol (MCP).
To use it:
-
Make sure the platform is running:
make up
-
Copy the configuration to your Cursor settings:
# View the template cat examples/cursor-mcp-config.json # Add to Cursor Settings → MCP Servers
-
The configuration uses SSE transport and connects to the MCP server via HAProxy:
{ "mcpServers": { "agent-platform": { "url": "http://localhost:3000/sse", "transport": "sse", "description": "Agent Platform via HAProxy load balancer" } } } -
Once configured, ask Cursor: "What's the weather in Tokyo?"
For complete setup instructions, see:
- CURSOR_INTEGRATION.md - Complete integration guide
- MCP_CURSOR_SETUP.md - Quick reference
A comprehensive example showing all platform capabilities:
# Make sure services are running
make up
# Activate virtual environment
source venv/bin/activate
# Run the example
python examples/simple_client.pyThis example demonstrates:
- Echo Agent - Basic task execution
- Weather Tool - Using external tools
- Itinerary Worker - Complex task processing
- Streaming - Real-time response streaming
====================================================
Agent Platform - Example Client
====================================================
Example 1: Echo Agent
📤 Sending task to Echo Agent...
Task ID: abc-123
Input: Hello from the Agent Platform!
📥 Received response:
Success: True
Output: Echo Agent Response: Hello from the Agent Platform!
...
Example 2: Weather Tool
🌤️ Getting weather for New York...
Location: New York
Temperature: 72°F
Condition: Partly Cloudy
...
Example 3: Itinerary Task Worker
✈️ Planning a 3-day trip to Paris...
Destination: Paris
Duration: 3 days
📅 Daily Schedule:
Day 1 (2025-10-14):
🌅 Morning: Eiffel Tower
☀️ Afternoon: Louvre Museum
🌙 Evening: Dinner at Le Jules Verne
...
✓ All examples completed successfully!
import grpc
import agent_platform_pb2
import agent_platform_pb2_grpc
import uuid
# 1. Connect to MCP Router (NOT directly to services!)
channel = grpc.insecure_channel('localhost:50051')
# 2. Create appropriate stub based on what you're accessing
stub = agent_platform_pb2_grpc.AgentServiceStub(channel)
# OR
stub = agent_platform_pb2_grpc.ToolServiceStub(channel)
# OR
stub = agent_platform_pb2_grpc.TaskWorkerStub(channel)
# 3. Create request
request = agent_platform_pb2.TaskRequest(
task_id=str(uuid.uuid4()),
agent_id='echo-agent', # Router will discover this
input='Your input',
parameters={'key': 'value'}
)
# 4. Call service (router handles discovery and routing)
response = stub.ExecuteTask(request)
# 5. Process response
print(f"Success: {response.success}")
print(f"Output: {response.output}")
# 6. Close connection
channel.close()Your Client
↓
MCP Router (localhost:50051)
↓
Consul Service Discovery
↓
Backend Service (echo-agent, weather-tool, etc.)
↓
Response back through Router
↓
Your Client
All accessed through MCP Router on port 50051:
| Service Type | Stub | Agent/Tool ID | Methods |
|---|---|---|---|
| Echo Agent | AgentServiceStub |
echo-agent |
ExecuteTask, StreamTask, GetStatus |
| Weather Tool | ToolServiceStub |
weather-tool |
ExecuteTool, ListTools |
| Itinerary Worker | TaskWorkerStub |
itinerary-worker |
ProcessTask, GetTaskStatus |
import grpc
import agent_platform_pb2
import agent_platform_pb2_grpc
import uuid
# Connect through MCP Router
channel = grpc.insecure_channel('localhost:50051')
stub = agent_platform_pb2_grpc.AgentServiceStub(channel)
# Execute task
request = agent_platform_pb2.TaskRequest(
task_id=str(uuid.uuid4()),
agent_id='echo-agent',
input='Hello!'
)
response = stub.ExecuteTask(request)
print(response.output)
channel.close()import grpc
import agent_platform_pb2
import agent_platform_pb2_grpc
# Connect through MCP Router
channel = grpc.insecure_channel('localhost:50051')
stub = agent_platform_pb2_grpc.ToolServiceStub(channel)
# Get weather
request = agent_platform_pb2.ToolRequest(
tool_id='weather-tool',
operation='get_weather',
parameters={'location': 'Tokyo'}
)
response = stub.ExecuteTool(request)
print(response.result)
channel.close()import grpc
import agent_platform_pb2
import agent_platform_pb2_grpc
import uuid
# Connect through MCP Router
channel = grpc.insecure_channel('localhost:50051')
stub = agent_platform_pb2_grpc.TaskWorkerStub(channel)
# Plan itinerary
request = agent_platform_pb2.TaskRequest(
task_id=str(uuid.uuid4()),
agent_id='itinerary-worker',
input='Plan a trip',
parameters={
'destination': 'Paris',
'days': '3'
}
)
response = stub.ProcessTask(request)
print(response.output)
channel.close()# Run official test suite
make test
# View service health
make consul-check
# Check router logs
make logs-routerThe platform supports horizontal scaling! Try scaling services while running examples:
# Scale MCP Router (load balanced by HAProxy)
make scale-router N=3
# Scale backend services
make scale-echo N=3
make scale-weather N=2
# Monitor in HAProxy dashboard
make ui-haproxy
# Monitor in Consul
make ui-consul
# Check service registry
make consul-checkYour client code doesn't change! The router automatically discovers and routes to healthy instances.
- Service Discovery - No need to know backend addresses
- Load Balancing - Automatic distribution across instances
- Health Checking - Only routes to healthy services
- Scalability - Add/remove instances without client changes
- Failover - Automatic routing around failed instances
Check the test client for additional examples:
# Comprehensive test suite
python scripts/test_client.py
# View test source code
cat scripts/test_client.py- Quick Start: QUICKSTART.md
- Architecture: ARCHITECTURE.md
- Complete Docs: README.md
- Makefile Commands: MAKEFILE_REFERENCE.md
- Scaling Guide: SCALING_GUIDE.md
- Load Balancing: LOAD_BALANCING.md
- Make sure services are running:
make status - Verify router is healthy:
make consul-check - Check router logs:
make logs-router
- Check Consul registry:
make consul-check - Clean up stale registrations:
make consul-cleanup - Restart services:
make restart
make help # Show all available commandsRemember: Always connect to localhost:50051 (MCP Router), not directly to backend services!