Skip to main content
Glama
puspoaditya

Cloudflare Workers AI MCP Server

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_models

List supported chat, embedding, and image models

chat_completion

LLM chat completion (Llama 3.3 70B, Llama 3.1 8B, Llama 4 Scout, Qwen Coder 32B, DeepSeek R1 Distill)

embed_text

Text embeddings (BGE small/base)

generate_image

Image generation (Flux 1 Schnell) → base64 image (PNG/JPEG)

Related MCP server: Remote MCP Server Authless

Setup

  1. Create a Cloudflare API token with the Workers AI permission: https://dash.cloudflare.com/profile/api-tokens

  2. Get your Account ID (right sidebar of the Cloudflare dashboard, or the /accounts/{id} segment of any dashboard URL)

  3. 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 server

Claude 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-instruct was deprecated by Cloudflare (2026-05-30) — use @cf/meta/infire-llama-3.1-8b-instruct.

Test

npm test   # unit tests (mocked fetch) + protocol test

License

MIT — built by puspoaditya.

Available Tools

4 tools
chat_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).

ParametersJSON Schema
NameRequiredDescriptionDefault
modelYesWorkers AI chat model id. Available models: @cf/meta/llama-3.3-70b-instruct-fp8-fast (default, strong generalist), @cf/meta/infire-llama-3.1-8b-instruct (small and cheap), @cf/meta/llama-4-scout-17b-16e-instruct, @cf/qwen/qwen2.5-coder-32b-instruct (coding), @cf/deepseek-ai/deepseek-r1-distill-qwen-32b (reasoning). Call list_models for the full catalog.
messagesYesChat messages in chronological order. Use role system for instructions, user for the human input, assistant for prior model replies when continuing a conversation.
max_tokensNoMaximum number of tokens to generate. Default 512. Lower values return faster and cheaper; higher values allow longer replies.
temperatureNoSampling temperature between 0 and 2. Default 0.7. Lower values produce more deterministic output; higher values increase creativity and variety.

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description carries full responsibility and delivers: endpoint destination, exact return shape (assistant reply as a text block with model id and finish reason), non-streaming behavior, required environment variables, and cost/billing context. This far exceeds typical descriptions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each earning its place: purpose+usage, behavior/return, and operational requirements. Information is front-loaded and free of redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given moderate complexity, no annotations, and no output schema, the description still explains return values, authentication, billing, and the endpoint. It fully equips an agent to invoke the tool correctly and interpret the response.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with detailed parameter descriptions for model, messages, max_tokens, and temperature. The tool description adds contextual framing but no new parameter-level semantics, so the baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Run an LLM chat completion using Cloudflare Workers AI' — a clear verb+resource statement. It distinguishes the tool from siblings (list_models, embed_text, generate_image) by specifying the message-list interaction and concrete use cases like summarization, translation, Q&A, and code generation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'Use this tool when you need direct LLM inference with an explicit message list' and lists example tasks. It also clarifies what this tool does not do ('No streaming is performed'), helping the agent choose appropriately among sibling inference tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
modelYesEmbedding model id. Available: @cf/baai/bge-small-en-v1.5 (384 dimensions, faster), @cf/baai/bge-base-en-v1.5 (768 dimensions, higher quality).
textsYesOne or more texts to embed (up to 10 per call). Each text becomes one embedding vector returned in the same order.

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: deterministic output for identical inputs, output ordering matching input order, dimensionality varying by model, environment variable requirements, and native endpoint usage. This goes well beyond a minimal 'embed' description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three focused sentences with zero filler. The first sentence states the core action, the second gives usage context and return format, and the third covers prerequisites and determinism. Each sentence earns its place and the most essential action is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter tool with no output schema, the description fully covers what an agent needs: return value shape, array ordering, model dimensionality differences, determinism, and required environment variables. It is complete for its complexity and unlikely to cause confusion among siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters (model, texts) are fully documented in the schema. The description adds some model-dimension detail, but that is already present in the schema's model property description. It re-states 'same order' which is also in the texts property description. No significant new semantic information is added beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: 'Generate numerical vector embeddings for one or more text inputs using Cloudflare Workers AI.' It clearly distinguishes this from siblings like chat_completion and generate_image by stating the exact purpose (semantic vector representations) and mechanism (Workers AI endpoint).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use guidance: 'Use this tool when you need semantic vector representations of text — for example similarity search, clustering, deduplication, or retrieval-augmented generation.' It does not explicitly state when-not-to-use or name alternatives, but the use-case list is clear and sufficient for an embedding tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
stepsNoNumber of diffusion steps. Default 4, maximum 8 for Flux 1 Schnell. More steps improve detail at the cost of latency.
promptYesDetailed text description of the image to generate. Be specific about subject, style, colors, composition, and lighting for best results.

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full behavioral burden and delivers: it discloses the base64-encoded return format (including decode instructions), asynchronous latency ('typically takes a few seconds'), content moderation rejecting NSFW prompts, and required environment variables for auth. This goes well beyond minimal disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Five sentences, each earning its place: purpose, use cases, output format, async behavior, moderation, and auth requirements. The most critical info (what it does, when to use) comes first, with no filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-param tool with no output schema, the description is self-sufficient: it explains the output (base64, PNG/JPEG), operational characteristics (asynchronous, a few seconds), failure modes (NSFW rejection), and setup needs (env vars). An agent has everything it needs to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides 100% coverage with detailed descriptions for both 'prompt' and 'steps'. The description doesn't add new parameter-specific meaning beyond what the schema includes, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: 'Generate an image from a text prompt using Cloudflare Workers AI (Flux 1 Schnell).' It clearly distinguishes from sibling tools like chat_completion and embed_text, and provides concrete examples (logos, scene descriptions, thumbnails, design mockups) that settle any ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'Use this tool when the user asks for a picture, illustration, concept art, or visual asset' with examples. This provides unambiguous when-to-use direction, and the sibling names (chat_completion, embed_text) make the alternatives obvious even without an explicit 'do not use for' clause.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full transparency burden and does well by disclosing that the tool does not call the Cloudflare API, works without credentials, and returns a catalog with model roles. It lacks details about exact return formatting, but the absence of an output schema is partially compensated by the clear catalog description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences with no filler. It front-loads the core purpose, then gives usage guidance, then adds credential/API behavior context—each sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple, parameterless listing tool with no output schema, the description fully covers what it returns, when to use it, and its external behavior. Nothing essential is missing given the tool's low complexity and rich sibling context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the baseline is 4. The description correctly implies the tool requires no input and instead focuses on its output purpose, which is sufficient for a no-parameter discovery tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('List') and resource ('Cloudflare Workers AI models supported by this server'), clearly distinguishing this discovery tool from the execution-oriented siblings chat_completion, embed_text, and generate_image. It also states the exact deliverable: a complete catalog of chat, embedding, and image models with their roles.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly tells the agent when to use the tool: 'before calling chat_completion, embed_text, or generate_image'. It also clarifies that no credentials are needed and that no Cloudflare API call is made, preventing unnecessary setup or external calls.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv0.1.0
    • First observedchat_completion
    • First observedembed_text
    • First observedgenerate_image
    • First observedlist_models

TDQS

A4.7/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/puspoaditya/cloudflare-workers-ai-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server