1. Overview
Same MCP server. Worker runtime. Zero-cold-start in most regions. Pennies-per-million.
2. Edge stack
Workers
Stateless compute, global.
KV + R2
Cache + blob storage.
D1
SQLite at the edge.
AI + Vectorize
Inference + embeddings.
3. Wrangler config
wrangler.jsonc jsonc
{
"name": "wp-mcp-edge",
"main": "src/worker.ts",
"compatibility_date": "2026-05-12",
"kv_namespaces": [{ "binding": "CACHE", "id": "..." }],
"d1_databases": [{ "binding": "STATE", "database_name": "wp-mcp" }],
"r2_buckets": [{ "binding": "MEDIA", "bucket_name": "wp-mcp-media" }],
"ai": { "binding": "AI" }
} 4. D1, KV, R2
Tools that need durability go to D1. Hot reads go to KV. Media goes to R2. Don't mix.
5. Workers AI binding
src/worker.ts typescript
export default {
async fetch(req: Request, env: Env) {
const out = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
messages: [{ role: 'user', content: 'Summarise this post' }],
})
return Response.json(out)
},
}