Agent skill

Building MCP Server On Cloudflare

by CommandCodeAI in CommandCodeAI/agent-skills

Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.

MITAuto-check passedAgent Workflows

Install Building MCP Server On Cloudflare

skills CLI
$ npx skills add CommandCodeAI/agent-skills --skill building-mcp-server-on-cloudflare -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install CommandCodeAI/agent-skills building-mcp-server-on-cloudflare --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/building-mcp-server-on-cloudflare .claude/skills/building-mcp-server-on-cloudflare && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
building-mcp-server-on-cloudflare
GitHub stars
132
Token cost
~1.5k tokens
SKILL.md length
275 words
Files
4 (incl. references)
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.

  • Works in 5 steps: Define Tools → Configure Entry Point → Test Locally → …
  • : user wants to build MCP server
  • SKILL.md covers When to Use, Prerequisites, Quick Start and Core Workflow, plus 5 more sections
  • Calls npm, npx and wrangler; reaches api.weather.com; needs GITHUB_CLIENT_SECRET

What it does

Building MCP Server On Cloudflare is an agent skill from CommandCodeAI/agent-skills. Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment. Generates server code, configures auth providers, and deploys to Workers. Use when: user wants to "build MCP server", "create MCP tools", "remote MCP", "deploy MCP", add "OAuth to MCP", or mentions Model Context Protocol on Cloudflare. Also triggers on "MCP authentication" or "MCP deployment".

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/examples.md`, `references/oauth-setup.md` and `references/troubleshooting.md`).

It sits in Agent Workflows, covering MCP servers and OAuth and OpenID Connect. It works with Model Context Protocol, Cloudflare, Cloudflare Workers and GitHub. The repository describes itself as: A curated list of awesome Skills, resources, and tools for customizing coding agent workflows. The licence is MIT.

When your agent uses it

  • : user wants to build MCP server
  • Create MCP tools
  • Add OAuth to MCP
  • Mentions Model Context Protocol on Cloudflare

Example prompts

  • “build MCP server”
  • “create MCP tools”
  • “remote MCP”
  • “/building-mcp-server-on-cloudflare”

Requirements

  • Node.js
  • A credential in GITHUB_CLIENT_SECRET

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Define Tools
  2. Configure Entry Point
  3. Test Locally
  4. Deploy
  5. Connect Clients

What it can do on your machine

Read from SKILL.md and the folder at commit f490dd9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm
    • npx
    • wrangler

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.weather.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • GITHUB_CLIENT_SECRET

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Building MCP Server On Cloudflare loads about 1.5k tokens when it runs, and up to ~6.1k if it reads all its reference files. Until then it costs about 116 tokens; SKILL.md has 275 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~116
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from CommandCodeAI/agent-skills at commit f490dd9, republished under its MIT licence (© CommandCodeAI). 275 words, ~1,522 tokens.

Download SKILL.mdSave it as .claude/skills/building-mcp-server-on-cloudflare/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
building-mcp-server-on-cloudflare
description
Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment. Generates server code, configures auth providers, and deploys to Workers. Use when: user wants to "build MCP server", "create MCP tools", "remote MCP", "deploy MCP", add "OAuth to MCP", or mentions Model Context Protocol on Cloudflare. Also triggers on "MCP authentication" or "MCP deployment".

Building MCP Servers on Cloudflare

Creates production-ready Model Context Protocol servers on Cloudflare Workers with tools, authentication, and deployment.

When to Use

  • User wants to build a remote MCP server
  • User needs to expose tools via MCP
  • User asks about MCP authentication or OAuth
  • User wants to deploy MCP to Cloudflare Workers

Prerequisites

  • Cloudflare account with Workers enabled
  • Node.js 18+ and npm/pnpm/yarn
  • Wrangler CLI (npm install -g wrangler)

Quick Start

Option 1: Public Server (No Auth)
bash
npm create cloudflare@latest -- my-mcp-server \
  --template=cloudflare/ai/demos/remote-mcp-authless
cd my-mcp-server
npm start

Server runs at http://localhost:8788/mcp

Option 2: Authenticated Server (OAuth)
bash
npm create cloudflare@latest -- my-mcp-server \
  --template=cloudflare/ai/demos/remote-mcp-github-oauth
cd my-mcp-server

Requires OAuth app setup. See references/oauth-setup.md.

Core Workflow

Step 1: Define Tools

Tools are functions MCP clients can call. Define them using server.tool():

typescript
import { McpAgent } from "agents/mcp";
import { z } from "zod";

export class MyMCP extends McpAgent {
  server = new Server({ name: "my-mcp", version: "1.0.0" });

  async init() {
    // Simple tool with parameters
    this.server.tool(
      "add",
      { a: z.number(), b: z.number() },
      async ({ a, b }) => ({
        content: [{ type: "text", text: String(a + b) }],
      })
    );

    // Tool that calls external API
    this.server.tool(
      "get_weather",
      { city: z.string() },
      async ({ city }) => {
        const response = await fetch(`https://api.weather.com/${city}`);
        const data = await response.json();
        return {
          content: [{ type: "text", text: JSON.stringify(data) }],
        };
      }
    );
  }
}
Step 2: Configure Entry Point

Public server (src/index.ts):

typescript
import { MyMCP } from "./mcp";

export default {
  fetch(request: Request, env: Env, ctx: ExecutionContext) {
    const url = new URL(request.url);
    if (url.pathname === "/mcp") {
      return MyMCP.serveSSE("/mcp").fetch(request, env, ctx);
    }
    return new Response("MCP Server", { status: 200 });
  },
};

export { MyMCP };

Authenticated server — See references/oauth-setup.md.

Step 3: Test Locally
bash
# Start server
npm start

# In another terminal, test with MCP Inspector
npx @modelcontextprotocol/inspector@latest
# Open http://localhost:5173, enter http://localhost:8788/mcp
Step 4: Deploy
bash
npx wrangler deploy

Server accessible at https://[worker-name].[account].workers.dev/mcp

Step 5: Connect Clients

Claude Desktop (claude_desktop_config.json):

json
{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["mcp-remote", "https://my-mcp.workers.dev/mcp"]
    }
  }
}

Restart Claude Desktop after updating config.

Tool Patterns

Return Types
typescript
// Text response
return { content: [{ type: "text", text: "result" }] };

// Multiple content items
return {
  content: [
    { type: "text", text: "Here's the data:" },
    { type: "text", text: JSON.stringify(data, null, 2) },
  ],
};
Input Validation with Zod
typescript
this.server.tool(
  "create_user",
  {
    email: z.string().email(),
    name: z.string().min(1).max(100),
    role: z.enum(["admin", "user", "guest"]),
    age: z.number().int().min(0).optional(),
  },
  async (params) => {
    // params are fully typed and validated
  }
);
Accessing Environment/Bindings
typescript
export class MyMCP extends McpAgent<Env> {
  async init() {
    this.server.tool("query_db", { sql: z.string() }, async ({ sql }) => {
      // Access D1 binding
      const result = await this.env.DB.prepare(sql).all();
      return { content: [{ type: "text", text: JSON.stringify(result) }] };
    });
  }
}

Authentication

For OAuth-protected servers, see references/oauth-setup.md.

Supported providers:

  • GitHub
  • Google
  • Auth0
  • Stytch
  • WorkOS
  • Any OAuth 2.0 compliant provider

Wrangler Configuration

Minimal wrangler.toml:

toml
name = "my-mcp-server"
main = "src/index.ts"
compatibility_date = "2024-12-01"

[durable_objects]
bindings = [{ name = "MCP", class_name = "MyMCP" }]

[[migrations]]
tag = "v1"
new_classes = ["MyMCP"]

With bindings (D1, KV, etc.):

toml
[[d1_databases]]
binding = "DB"
database_name = "my-db"
database_id = "xxx"

[[kv_namespaces]]
binding = "KV"
id = "xxx"

Common Issues

"Tool not found" in Client
  1. Verify tool name matches exactly (case-sensitive)
  2. Ensure init() registers tools before connections
  3. Check server logs: wrangler tail
Connection Fails
  1. Confirm endpoint path is /mcp
  2. Check CORS if browser-based client
  3. Verify Worker is deployed: wrangler deployments list
OAuth Redirect Errors
  1. Callback URL must match OAuth app config exactly
  2. Check GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET are set
  3. For local dev, use http://localhost:8788/callback

References

© CommandCodeAI, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in skills/building-mcp-server-on-cloudflare of CommandCodeAI/agent-skills.

  • SKILL.md
  • references/examples.md
  • references/oauth-setup.md
  • references/troubleshooting.md

Open the folder on GitHubat commit f490dd9

Compare with similar skills

Building MCP Server On Cloudflare next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Building MCP Server On Cloudflare compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Building MCP Server On Cloudflare this skillCommandCodeAI/agent-skills132—~1.5kAutomated safety check: PassMIT
Agents SDKcloudflare/skills3k2 repos~3kAutomated safety check: PassApache-2.0
Cloudflare Agentssecondsky/claude-skills2271 repos~691Automated safety check: PassMIT
Adding MCP Store ServersPostHog/posthog-foss721—~1.6kAutomated safety check: PassMIT
Agents SDKhodgef/apiker1273 repos~3kAutomated safety check: PassMIT
MCP Server Trello Growthdelorenj/mcp-server-trello446—~3.6kAutomated safety check: PassMIT

Similar skills

  • Agents SDK

    cloudflare/skills

    Official

    Build, debug, or review Cloudflare Agents SDK applications using the agents package.

    3k GitHub starsUsed in 2 repos~3k tokens
    Agent WorkflowsAuto-check passed
  • Cloudflare Agents

    secondsky/claude-skills

    Build AI agents on Cloudflare Workers with MCP integration, tool use, and LLM providers.

    227 GitHub starsUsed in 1 repo~691 tokens
    Agent WorkflowsAuto-check passed
  • Adding MCP Store Servers

    PostHog/posthog-foss

    Official

    Add a third-party MCP server (Linear, Notion, GitHub, ...) to the PostHog MCP store catalog.

    721 GitHub stars~1.6k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Agents SDK

    hodgef/apiker

    Build AI agents on Cloudflare Workers using the Agents SDK. An agent skill from hodgef/apiker.

    127 GitHub starsUsed in 3 repos~3k tokens
    Backend & APIsAuto-check passed
  • MCP Server Trello Growth

    delorenj/mcp-server-trello

    Distribution-first growth ledger for @delorenj/mcp-server-trello — grow reach now, defer (but record) monetization.

    446 GitHub stars~3.6k tokensUpdated 14 days ago
    Agent WorkflowsAuto-check passed
  • Glim MCP

    aeonfun/aeon

    Live-data research via the glim.sh MCP - web search, full page extraction, X/Twitter, Reddit, GitHub, Amazon, and YouTube transcripts - synthesized into a cited digest.

    767 GitHub stars~1.3k tokensUpdated yesterday
    Knowledge ManagementAuto-check: warnings

More from CommandCodeAI/agent-skills

  • Youtube Transcript

    CommandCodeAI/agent-skills

    Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube.

    132 GitHub starsUsed in 1 repo~3.4k tokens
    Auto-check: notes
  • Welcome Me

    CommandCodeAI/agent-skills

    Greet user with a specific message when they say they're new or ask for a welcome message.

    132 GitHub stars~182 tokensUpdated 7 mo ago
    Auto-check passed

Questions about Building MCP Server On Cloudflare

What does Building MCP Server On Cloudflare do?

Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment. Building MCP Server On Cloudflare is an agent skill from CommandCodeAI/agent-skills. Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.

When should I use Building MCP Server On Cloudflare?

Building MCP Server On Cloudflare fits situations like: : user wants to build MCP server; create MCP tools; add OAuth to MCP; mentions Model Context Protocol on Cloudflare.

How do I install Building MCP Server On Cloudflare in Claude Code?

Run `npx skills add CommandCodeAI/agent-skills --skill building-mcp-server-on-cloudflare -a claude-code`. Or copy the skill folder (skills/building-mcp-server-on-cloudflare in CommandCodeAI/agent-skills) into .claude/skills/building-mcp-server-on-cloudflare in your project. Claude Code loads it when a task matches its description.

How do I install Building MCP Server On Cloudflare in Codex?

Run `npx skills add CommandCodeAI/agent-skills --skill building-mcp-server-on-cloudflare -a codex`. Or copy the skill folder (skills/building-mcp-server-on-cloudflare in CommandCodeAI/agent-skills) into .agents/skills/building-mcp-server-on-cloudflare in your project. Codex loads it when a task matches its description.

Can I use Building MCP Server On Cloudflare in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add CommandCodeAI/agent-skills --skill building-mcp-server-on-cloudflare -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/building-mcp-server-on-cloudflare, .gemini/skills/building-mcp-server-on-cloudflare, .github/skills/building-mcp-server-on-cloudflare and .opencode/skills/building-mcp-server-on-cloudflare in your project.

What does Building MCP Server On Cloudflare need to run?

Going by SKILL.md and its folder, Building MCP Server On Cloudflare needs the command-line tools its instructions call (npm, npx and wrangler) and credentials named GITHUB_CLIENT_SECRET. Our summary lists: Node.js; A credential in GITHUB_CLIENT_SECRET.

Does Building MCP Server On Cloudflare access the network?

SKILL.md names 1 domain. In commands or code: api.weather.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Building MCP Server On Cloudflare safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Building MCP Server On Cloudflare use?

Building MCP Server On Cloudflare is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Building MCP Server On Cloudflare use?

About 1.5k tokens (SKILL.md is roughly 6.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.6k tokens, read only when the agent opens those files.

What are the alternatives to Building MCP Server On Cloudflare?

Skills that share tags, products or a category with Building MCP Server On Cloudflare: Agents SDK (cloudflare/skills, 3k stars), Cloudflare Agents (secondsky/claude-skills, 227 stars), Adding MCP Store Servers (PostHog/posthog-foss, 721 stars) and Agents SDK (hodgef/apiker, 127 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Building MCP Server On Cloudflare?

CommandCodeAI (a GitHub organization) maintains it in CommandCodeAI/agent-skills, which has 132 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on March 10, 2026.

Source: CommandCodeAI/agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.