MCP Server on Edge Compute 167 Lines of Python

harpreetseehra1 pts0 comments

Deploy an MCP Server to Edge Compute: Expose Telnyx APIs as Tools for AI Agents | Low Latency Club

Skip to main content

Blog<br>Code-first technical deep dives

Glossary<br>Voice AI & telecom terminology

Developer Docs<br>API references & integration guides

GitHub<br>Open-source repos & SDKs

Articles<br>Tutorials & support articles

AI Agents<br>Build voice AI agents

Voice API<br>Programmable voice calls

ClawHouse<br>AI-powered voice assistant

ClawdTalk<br>Conversational AI platform

Events<br>Videos<br>Podcast<br>Integrations

Resources

Blog<br>Code-first technical deep dives

Glossary<br>Voice AI & telecom terminology

Developer Docs<br>API references & integration guides

GitHub<br>Open-source repos & SDKs

Articles<br>Tutorials & support articles

Products

AI Agents<br>Build voice AI agents

Voice API<br>Programmable voice calls

ClawHouse<br>AI-powered voice assistant

ClawdTalk<br>Conversational AI platform

Contact us<br>Join our Slack

The Model Context Protocol (MCP) has become the standard way for AI agents to call external tools. Claude, Cursor, and a growing ecosystem of agent frameworks speak MCP natively, they discover tools via a tools/list endpoint and call them via tools/call. Any HTTP service that implements that contract becomes a tool provider the agent can use.

This walkthrough deploys a working MCP server to Telnyx Edge Compute. The whole server is 167 lines of Python in function/func.py, uses Python's standard library for the HTTP layer, and exposes four Telnyx APIs (send_sms, search_numbers, run_inference, list_phone_numbers) as MCP tools. There is no Express, no FastAPI, no SDK, just urllib, json, os, and an ASGI handler.

The canonical code example lives in the Telnyx code examples repo:

https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-mcp-server-deploy-python

What This Example Builds

A single ASGI function deployed to Telnyx Edge Compute that exposes four MCP tools:

ToolTelnyx APIPurposesend_smsPOST /v2/messagesSend an SMS message to an E.164 numbersearch_numbersGET /v2/available_phone_numbersSearch available phone numbers by country and area coderun_inferencePOST /v2/ai/chat/completionsRun LLM inference via Telnyx AI (OpenAI-compatible)list_phone_numbersGET /v2/phone_numbersList phone numbers on the account<br>The function exposes four HTTP endpoints:

MethodPathPurposeGET, POST/mcp/tools/listReturn the tool catalogPOST/mcp/tools/callExecute a tool by name with argumentsGET/healthHealth check (tool count, API key presence)GET/Service info (name, tool list, endpoint paths)<br>Once deployed, an AI agent that supports MCP can be pointed at the deployed URL and immediately call Telnyx APIs as part of its reasoning loop.

Why Edge Compute

Edge Compute runs serverless functions co-located with the Telnyx private network, the same network that handles voice, messaging, and AI inference. For an MCP server that calls Telnyx APIs as tools, that means:

No public internet round trips for the tool execution path. The function runs in the same network as the Telnyx API endpoints.

Single API key surface. The Telnyx API key is injected as a function secret at deploy time, never sent over the wire by the AI agent.

No cold-start container orchestration. Edge Compute is a function runtime, not a container host.

The MCP server sits one network hop away from every Telnyx API it calls. That is the carrier-edge advantage for AI agents: the same private network that carries SMS traffic carries the tool calls.

Products Used

telnyx_products: [Edge Compute, Messaging, Numbers, AI Inference]<br>Telnyx Edge Compute runs the ASGI function. Messaging powers send_sms. Numbers powers search_numbers and list_phone_numbers. AI Inference powers run_inference via the OpenAI-compatible chat completions endpoint.

Architecture

AI Agent (Claude / Cursor / MCP client)<br>│ HTTPS<br>┌──────────────────────┐<br>│ Edge Compute │ function/func.py<br>│ ASGI handler │ 167 lines, stdlib only<br>│ │<br>│ GET /mcp/tools/list │ → returns TOOLS array<br>│ POST /mcp/tools/call │ → _execute_tool(name, args)<br>│ GET /health │<br>└──────────┬────────────┘<br>│ Bearer TELNYX_API_KEY<br>│ (injected as secret at deploy time)<br>https://api.telnyx.com/v2<br>├── /messages (Messaging)<br>├── /available_phone_numbers (Numbers)<br>├── /phone_numbers (Numbers)<br>└── /ai/chat/completions (AI Inference)<br>The agent only knows the deployed URL. It never sees the Telnyx API key. The key is injected by the Edge Compute runtime as the TELNYX_API_KEY environment variable when the function boots.

The Code

The full function is 167 lines in function/func.py. Three pieces matter.

The tool catalog

The TOOLS array is the contract the agent reads during tools/list. Each entry has a name, a human-readable description, and a JSON Schema inputSchema. The schema is what the agent uses to construct valid arguments:

TOOLS = [<br>"name": "send_sms",<br>"description": "Send an SMS message via Telnyx",<br>"inputSchema": {<br>"type": "object",<br>"properties": {<br>"to": {"type": "string", "description": "Destination phone number in E.164...

telnyx tools edge compute voice function

Related Articles