IplanRio2025–2026in production
EAí gateway and the city's MCP server
The infrastructure that connects WhatsApp service channels to the City of Rio's AI agents.
500 → 50 ms
average latency compared with the previous Python version
- 6
- audio formats transcribed before reaching the agent
The problem
The EAí assistant receives text and voice messages over WhatsApp. The Python gateway had become a bottleneck, and the agents needed standardized access to city tools and data.
The solution
In the Go rewrite, the webhook responds immediately and enqueues the message on RabbitMQ, and workers route it to Google Agent Engine or Letta, with voice notes transcribed first by Speech-to-Text. On the official MCP server, I implemented hybrid token verification (Keycloak JWT or service token), stateless HTTP transport for running multiple replicas and the web search tool backed by Surkai.
Technical notes
Consumer reconnection after RabbitMQ failures, retries with backoff and a dead-letter queue.
Transcription of MP3, WAV, FLAC, OGG, OPUS and M4A before the message reaches the agent.
The citizen data service queries the MCP server to identify each resident's reference family health clinic automatically.
An API to version agent system prompts, with history, and to run evaluations.
Outcome
According to the team, average gateway latency dropped from about 500 ms to 50 ms compared with the Python version.