api-workers

A guide for running an MCP server on Cloudflare Workers, a platform that runs code at Cloudflare’s network edge. It explains how to register tools, resources, and prompts and connect them to Cloudflare settings.

In plain words
What is it for?
Use it when building or deploying an MCP server with Cloudflare Workers. It covers the request handler, environment and storage setup, custom bindings, and scheduled tasks.
Why use it?
It removes guesswork when adapting an MCP server to the Cloudflare Workers runtime, including how to provide configuration and external service bindings.

Skill for Claude CodeCodex

Part of the workflows-mcp-server plugin — 34 skills, 1 MCP server shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cyanheads/workflows-mcp-server/api-workers
Any agent
npx skills add cyanheads/workflows-mcp-server --skill api-workers
Clone the repo
git clone --depth 1 https://github.com/cyanheads/workflows-mcp-server

Made for: Claude Code, Codex.

Or install workflows-mcp-server, the plugin that ships this one along with the rest of its 34 skills, 1 MCP server.

Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,537 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00051 $0.03537
Opus 5 $0.00026 $0.01768
Sonnet 5 $0.00010 $0.00707
Haiku 4.5 $0.00005 $0.00354

Measured 3d ago against content hash 7979fbfdc182, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-workers scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

await worker.fetch(request, r2Env, ctx);
Origin

This is a copy

100% identical to api-workers — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/api-workers/SKILL.md · 318 lines

How it starts

The opening of the file, as written. The whole thing — 318 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Overview

@cyanheads/mcp-ts-core/worker exports createWorkerHandler — the Workers entry point. It wraps tool/resource/prompt registries into a per-request McpServer factory that integrates with the Cloudflare Workers runtime.


createWorkerHandler(options)

import { createWorkerHandler } from '@cyanheads/mcp-ts-core/worker';
import { echoTool } from './mcp-server/tools/definitions/echo.tool.js';
import { echoResource } from './mcp-server/resources/definitions/echo.resource.js';
import { echoPrompt } from './mcp-server/prompts/definitions/echo.prompt.js';
import { initMyService } from './services/my-domain/my-service.js';

export default createWorkerHandler({
  tools: [echoTool],
  resources: [echoResource],
  prompts: [echoPrompt],
  setup(core) {
    initMyService(core.config, core.storage);
  },
  extraEnvBindings: [['MY_API_KEY', 'MY_API_KEY']],
  extraObjectBindings: [['MY_CUSTOM_KV', 'MY_CUSTOM_KV']],
  onScheduled: async (controller, env, ctx) => {
    // Cloudflare cron trigger handler
  },
});

Fresh scaffolds register definitions directly in the entry point as shown above. If your project later adds barrel files for definitions, importing arrays from those barrels is also fine.

Options

Option Type Purpose
tools AnyToolDefinition[] Tool definitions to register
resources AnyResourceDefinition[] Resource definitions to register
prompts PromptDefinition[] Prompt definitions to register
extensions Record<string, object> SEP-2133 extensions to advertise in server capabilities
instructions string | (env: CloudflareBindings) => string Server-level orientation forwarded to the model on every initialize. Resolver form runs inside initializeApp(env) so env-derived text is available (see Workers-specific warnings). Empty string treated as unset.
setup (core: CoreServices) => void | Promise<void> Runs after core services are ready, during the first request (lazy init inside the fetch handler)
extraEnvBindings [bindingKey: string, processEnvKey: string][] Maps CF string bindings to process.env keys
extraObjectBindings [bindingKey: string, globalKey: string][] Maps CF object bindings (KV, R2, D1, AI) to globalThis keys
onScheduled (controller, env, ctx) => Promise<void> Cloudflare cron trigger handler

Read the full file on GitHub · 318 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 318 lines · 51 tokens per session scan A 7979fbfdc182

Subscribe to this mod's changes

api-workers is a skill published in the GitHub repository cyanheads/workflows-mcp-server (31 stars, last pushed 12d ago), licensed Apache-2.0. It adds 51 tokens to every session and 3,537 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to api-workers, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

test-workflow

Universal n8n workflow testing via webhook or sub-workflow pattern.

anatolykoptev/n8n-mcp-agent · 17 tokens

n8n-self-hosting

Deploy a production self-hosted n8n end-to-end to a fresh Linux VM over SSH, using Docker Compose behind a Caddy reverse proxy with automatic HTTPS. Use whenever the user wants to self-host, install, set up, provision, or deploy n8n on their own server/VPS/box (Hetzner, DigitalOcean, AWS EC2, bare metal, etc.) — in…

czlonkowski/n8n-mcp · 265 tokens

remote-compute-modal

Run GPU jobs on the user's own Modal account via host.compute.create('byoc:modal', ...). Covers the create→submit→waitfornotification flow, the computeprovider kernel for env setup, image/volume resolution, and the two approval cards. Load once you've decided to dispatch to Modal.

UnicomAI/wanwu · 65 tokens

compute-env-setup

Set up a compute environment on a remote provider so Claude Science jobs can run there. Covers direct SSH/conda hosts, Slurm clusters, container-via-bridge runners, and managed-API providers (Modal, GCP, RunPod). Use when standing up a new provider, porting an env to a different backend, adding a tool that needs its…

UnicomAI/wanwu · 134 tokens

unifi-network

How to manage UniFi network infrastructure — devices, clients, firewall, VPN, routing, WLANs, Traffic Flows, and statistics. Use this skill when the user mentions UniFi, Ubiquiti, network management, WiFi configuration, firewall rules, port forwarding, VPN, QoS, bandwidth, traffic flows, connected clients, network…

sirkirby/unifi-mcp · 83 tokens

cloud-run

Manage Cloud Run services and jobs.

GoogleCloudPlatform/cloud-run-mcp · 10 tokens