Cloudflare Workers AI MCP Server
Provides access to Cloudflare Workers AI for serverless LLM inference, text embeddings, and image generation using Cloudflare's API.
Enables AI agents to interact with Cloudflare Workers AI, offering tools for chat completions, embeddings, and image generation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Cloudflare Workers AI MCP Server Generate an image of a red fox in a snowstorm"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Cloudflare Workers AI MCP Server
Model Context Protocol (MCP) server that gives AI agents access to Cloudflare Workers AI — serverless LLM inference, embeddings, and image generation with a generous free tier.
Tools
Tool | Description |
| List supported chat, embedding, and image models |
| LLM chat completion (Llama 3.3 70B, Llama 3.1 8B, Llama 4 Scout, Qwen Coder 32B, DeepSeek R1 Distill) |
| Text embeddings (BGE small/base) |
| Image generation (Flux 1 Schnell) → base64 image (PNG/JPEG) |
Related MCP server: Foundry Agents MCP Server
Setup
Create a Cloudflare API token with the Workers AI permission: https://dash.cloudflare.com/profile/api-tokens
Get your Account ID (right sidebar of the Cloudflare dashboard, or the
/accounts/{id}segment of any dashboard URL)Export the env vars:
export CLOUDFLARE_ACCOUNT_ID="your-account-id"
export CLOUDFLARE_API_TOKEN="your-api-token"Run
npm install && npm run build
npm start # stdio MCP serverClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"cloudflare-workers-ai": {
"command": "node",
"args": ["/absolute/path/to/cloudflare-workers-ai-mcp/dist/index.js"],
"env": {
"CLOUDFLARE_ACCOUNT_ID": "your-account-id",
"CLOUDFLARE_API_TOKEN": "your-api-token"
}
}
}
}Cursor / VS Code / other MCP clients
Point the client at the same command (node dist/index.js with the two env vars).
OpenClaw
OpenClaw supports MCP servers — add the same command to its MCP configuration.
Example prompts
"Summarize this text using the Llama 3.3 70B model on Cloudflare Workers AI"
"Generate an image of a red fox in a snowstorm"
"Embed these 3 sentences for a similarity search"
Models (verified live)
Chat: POST /ai/v1/chat/completions (OpenAI-compatible) · Embeddings & images: POST /ai/run/{model} (native)
Models — chat: @cf/meta/llama-3.3-70b-instruct-fp8-fast · @cf/meta/infire-llama-3.1-8b-instruct · @cf/meta/llama-4-scout-17b-16e-instruct · @cf/qwen/qwen2.5-coder-32b-instruct · @cf/deepseek-ai/deepseek-r1-distill-qwen-32b
Embeddings: @cf/baai/bge-small-en-v1.5 · @cf/baai/bge-base-en-v1.5
Images: @cf/black-forest-labs/flux-1-schnell
Note:
@cf/meta/llama-3.1-8b-instructwas deprecated by Cloudflare (2026-05-30) — use@cf/meta/infire-llama-3.1-8b-instruct.
Test
npm test # unit tests (mocked fetch) + protocol testLicense
MIT — built by puspoaditya.
Available Tools
4 toolschat_completionA
Run an LLM chat completion using Cloudflare Workers AI. Use this tool when you need direct LLM inference with an explicit message list (system/user/assistant roles) — for example summarization, translation, Q&A, classification, or code generation. The request is sent to the Workers AI OpenAI-compatible endpoint and the full assistant reply is returned as a single text block together with the model id and finish reason. No streaming is performed. Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN environment variables; costs are billed to your Cloudflare account (free tier available).
Inputs: model (required), messages (required), max_tokens, temperature.
embed_textA
Generate numerical vector embeddings for one or more text inputs using Cloudflare Workers AI. Use this tool when you need semantic vector representations of text — for example similarity search, clustering, deduplication, or retrieval-augmented generation. Returns one embedding array (384-dimensional for BGE small, 768 for BGE base) per input text, in the same order as the inputs. Embeddings are generated by the native Workers AI endpoint and are deterministic for identical inputs. Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN environment variables.
Inputs: model (required), texts (required).
generate_imageA
Generate an image from a text prompt using Cloudflare Workers AI (Flux 1 Schnell). Use this tool when the user asks for a picture, illustration, concept art, or visual asset — e.g. logos, scene descriptions, thumbnails, or design mockups. The image is generated by the Flux 1 Schnell model on Workers AI and returned as a base64-encoded string; decode it to obtain the image file (PNG or JPEG depending on the model output). Generation is asynchronous and typically takes a few seconds. Note: Cloudflare applies content moderation — prompts containing NSFW content are rejected with an error. Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN environment variables.
Inputs: prompt (required), steps.
list_modelsA
List the Cloudflare Workers AI models supported by this server. Use this tool to discover available model ids before calling chat_completion, embed_text, or generate_image — it returns the complete catalog of chat models, embedding models, and image models with their roles. This tool does not call the Cloudflare API and works without credentials.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool addresses a distinct capability: discovery (list_models), text generation (chat_completion), vector embeddings (embed_text), and image generation (generate_image). There is no overlap in purpose, making selection unambiguous.
All tool names follow a clear verb_noun pattern (list_models, chat_completion, embed_text, generate_image) with consistent snake_case. The style is uniform and predictable, aiding agent understanding.
With only four tools, the server is tightly scoped to core AI inference tasks (listing, chat, embeddings, images). Each tool is essential and the count is well below the threshold for bloat, making the surface easy to navigate.
The server covers the three primary inference modalities advertised (chat, embeddings, images) plus model discovery. Minor gaps exist (e.g., audio or translation tasks), but for its stated purpose as a Workers AI inference wrapper, the surface is reasonably complete.
Maintenance
Related MCP Connectors
Cloudflare Workers MCP server: agent-workflow-engine
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Cloudflare Workers MCP server: ai-agent-scratchpad
214 tools for AI agents over one MCP endpoint: image, video, audio, 3D, data, storage, mail, GPUs.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides browser automation, audio transcription, and LLM chat as MCP tools for any agent.7MIT
- AlicenseAqualityDmaintenanceExposes Azure AI Foundry agents, workflows, and AI Search vector-database capabilities as MCP tools, enabling natural language interaction with agents, semantic search, and index management.102MIT
- FlicenseNot gradedqualityCmaintenanceEnables coding agents to create, deploy, invoke, and monitor serverless functions using 12 MCP tools, with support for multiple runtimes and remote MCP access.106 npm-
- AlicenseNot gradedqualityCmaintenanceExposes free-tier AI APIs as MCP tools for AI agents, enabling text generation, web search, embeddings, and vision analysis with automatic failover and capability routing.18MIT