Skip to main content

Woxware Internal Docs

Internal engineering documentation for Woxware teams—architecture, platform services, deployment guides, and operational runbooks.

Easy to Use

Platform & architecture

How Woxware services fit together—Workers, microfrontends, auth, and shared packages in the core monorepo.

Focus on What Matters

Build & deploy

Staging and production workflows, environment configuration, and deployment patterns used across teams.

Powered by React

Runbooks & standards

Operational guides, conventions, and internal practices so teams ship consistently on the same platform.

Telegram Agent with Independent MCP Microservices

Absolutely, you can. Having each microservice exposed as an independent MCP (Model Context Protocol) server running on Cloudflare is an excellent, highly scalable architecture for this.

To bring this all together into a Telegram chat agent, you need to build a central orchestrator (the MCP host). Telegram communicates with this orchestrator, and the orchestrator handles the LLM logic and connects to your various microservice MCP servers.

The Architecture

Instead of Telegram trying to talk to multiple services, everything routes through a central orchestration Worker.

┌──────────┐      Webhook      ┌───────────────────────────────┐
│ Telegram │ ────────────────> │   Central Orchestrator        │
└──────────┘ <──────────────── │  (Cloudflare Worker / Host)   │
                               └───────────────────────────────┘
                                   │                       ▲
                             1. Send Prompt          2. Request Tool
                                   ▼                       │
                               ┌───────┐               ┌───────┐
                               │  LLM  │ <───────────> │  MCP  │
                               │ (AI)  │               │Client │
                               └───────┘               └───────┘
                                                           │
                                            ┌──────────────┼──────────────┐
                                            │ (HTTP / SSE) │              │
                                            ▼              ▼              ▼
                                      ┌───────────┐  ┌───────────┐  ┌───────────┐
                                      │  MCP #1   │  │  MCP #2   │  │  MCP #3   │
                                      │ (Workers) │  │ (Workers) │  │ (Workers) │
                                      └───────────┘  └───────────┘  └───────────┘

How to Build It

1. The Telegram Gateway

Set up a standard Cloudflare Worker configured with a Telegram webhook. This Worker captures incoming text messages from users, handles chat IDs, and formats final responses back to the Telegram Bot API.

2. The Orchestrator (The MCP Host)

This is the core of your agent. The orchestrator needs to act as an MCP host. When a message comes in from Telegram:

  • Initialize an MCP client connection to each microservice MCP server (using Streamable HTTP or SSE transports supported by Cloudflare Workers).
  • Fetch all available tools across microservices using tools/list.
  • Convert those definitions into the tool format expected by your LLM provider (Workers AI, OpenAI, Anthropic, etc.).

3. The LLM Tool-Calling Loop

  • The orchestrator sends the user's prompt and the combined tool list to the LLM.
  • The LLM decides which microservice tool to call and returns a tool_call request.
  • The orchestrator routes that call to the correct microservice MCP server URL, receives execution output, and feeds it back to the LLM.
  • Once satisfied, the LLM returns final text and the Worker sends it back to Telegram.

Implementation Tips for Cloudflare

  • Avoid tool overload: Too many tool schemas increase tokens, latency, and cost. Use a router pattern or contextual tool grouping.
  • Keep connections stateless: Use Cloudflare remote MCP helpers like createMcpHandler on microservices for fast HTTP execution.
  • Manage agent state: Store chat history by Telegram chat_id in KV or D1 so context survives webhook invocations.