Build and Deploy a Lightweight Model Context Protocol Server on Edge Compute
Deploy a 167-line Python Model Context Protocol (MCP) server to Telnyx Edge Compute using only the standard library. The server exposes Telnyx APIs as native tools for Claude, Cursor, and other agentic systems without cold-starts.
Impact: Medium
Why it matters
It provides a blueprint to build production-grade, low-latency MCP servers running close to APIs without heavy frameworks like FastAPI or Express.
TL;DR
- 01MCP tool discovery and execution are simple HTTP contracts reachable with standard library calls.
- 02Deploying tool hosting closer to target APIs reduces round-trip network latency significantly.
- 03Using ASGI directly avoids heavy external packages and decreases serverless function cold-starts.
Key facts
- Code Volume
- 167 lines of Python
- Dependencies
- Standard library only (0 external packages)
- Exposed MCP Tools
- 4 (SMS, Number Search, Inference, Number List)
ASGI-Based MCP Implementation
By bypassing heavy frameworks, this implementation defines a bare-bones ASGI handler handle(scope, receive, send) that intercepts HTTP requests directly. The contract requires handling two core MCP actions:
tools/list: Returns a JSON array of tool definitions outlining names, descriptions, and structural input schemas.tools/call: Executes the tool matching the requested name, receiving arguments in either flat or nested formats.
Zero-Dependency Architecture
The backend code runs with zero dependencies beyond Python's standard library. The core tooling relies on urllib.request to communicate with underlying REST APIs and json to serialize payload responses. Environment variables securely inject secrets like TELNYX_API_KEY on boot, keeping them hidden from downstream agents.
Deployment Steps
To test the setup locally or deploy it to Telnyx Edge Compute, clone the official examples and configure your secrets:
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/edge-mcp-server-deploy-python
telnyx-edge secrets add TELNYX_API_KEY <your_key>Try it in 2 minutes
async def handle(self, scope, receive, send):
path = scope.get("path", "")
method = scope.get("method", "")
if path == "/mcp/tools/list" and method in ("GET", "POST"):
await self._respond(send, 200, {"tools": TOOLS})python
✓ When to use
- When deploying low-latency AI agent tools that must run close to your telecom or database infrastructure.
- When you want to avoid container overhead and cold starts using serverless edge runtimes.
- When building lightweight MCP connectors without the footprint of FastAPI or Express.
✕ When NOT to use
- When your tools require complex OAuth flows or third-party SDK dependencies not easily bundled.
- If your environment lacks an ASGI-compliant web server or runner.
What to do today
- Clone the Telnyx MCP Python repository.
- Deploy the serverless function using the telnyx-edge CLI tool.
- Point your Claude Code or Cursor MCP configuration to the live edge URL.
Sources