Skip to main content
Glama
Cloudflare MCP Toolbox

Cloudflare MCP Toolbox

by jezweb

Cloudflare MCP Toolbox

Deploy to Cloudflare Workers

Utility tools for AI agents - date/time, math, text processing, validation, KV storage, and Workers AI integration.

Built on Cloudflare Workers for global edge deployment with zero cold starts.

Live Demo: https://cloudflare-mcp-toolbox.webfonts.workers.dev


πŸš€ Features

  • 30 Utility Tools across 6 categories

  • Australia/Sydney timezone as default for all date/time operations

  • Bearer token authentication for secure access

  • Cloudflare Workers AI integration with automatic embedding caching

  • Edge deployment with global low-latency access

  • MCP Protocol compliant (Model Context Protocol)


Related MCP server: TinyFn MCP Server

πŸ“¦ Tool Categories

Category

Tools

Description

Date/Time (5)

get_current_datetime, convert_timezone, calculate_duration, format_date, parse_date

Timezone conversion, duration calculations, natural language date parsing

Math (6)

calculate, convert_units, statistics, random_number, percentage, roll_dice

Safe expression evaluation, unit conversions, crypto-secure random, dice rolling

Text (6)

transform_text, encode_decode, extract_patterns, hash_text, count_words, truncate_text

Text transformation, encoding, pattern extraction, hashing

Validation (6)

validate_email, validate_url, validate_phone, validate_json, sanitize_html, validate_schema

Input validation and sanitization

KV Storage (4)

kv_get, kv_set, kv_delete, kv_list

Persistent key-value storage with TTL

Workers AI (3)

ai_chat, ai_classify, ai_embed

LLM inference, sentiment analysis, text embeddings


πŸ”§ Setup

Prerequisites

  • Node.js 18+

  • Cloudflare account with Workers AI enabled

  • Wrangler CLI

Installation

npm install

Configuration

  1. KV Namespace:

    wrangler kv namespace create MCP_TOOLBOX_CACHE

    Update wrangler.jsonc with the returned ID:

    "kv_namespaces": [
      {
        "binding": "CACHE",
        "id": "YOUR_KV_NAMESPACE_ID"
      }
    ]
  2. Generate AUTH_TOKEN:

    node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"

    Update wrangler.jsonc:

    "vars": {
      "AUTH_TOKEN": "YOUR_GENERATED_TOKEN_HERE"
    }

Deploy

npm run deploy

Local Development

npm run dev

Server will start at http://localhost:8787


πŸ“– Usage

BetterChat Configuration

Add to your BetterChat MCP servers config:

{
  "url": "https://your-worker.workers.dev/mcp",
  "headers": {
    "Authorization": "Bearer YOUR_AUTH_TOKEN_HERE"
  }
}

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "cloudflare-toolbox": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://your-worker.workers.dev/mcp"],
      "env": {
        "MCP_REMOTE_HEADERS": "{\"Authorization\":\"Bearer YOUR_TOKEN\"}"
      }
    }
  }
}

MCP Inspector (Testing)

npx @modelcontextprotocol/inspector \
  https://your-worker.workers.dev/mcp \
  -H "Authorization: Bearer YOUR_TOKEN"

MCP Protocol

Initialize:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05"
  }
}

List Tools:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list"
}

Call Tool:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "get_current_datetime",
    "arguments": {}
  }
}

🎯 Example Tool Calls

Date/Time

// Get current time in Sydney
get_current_datetime({ timezone: "Australia/Sydney", format: "readable" })
// β†’ "Wednesday, November 6, 2025 at 2:30 PM AEDT"

// Parse natural language
parse_date({ expression: "next Friday at 3pm" })
// β†’ "2025-11-08T15:00:00+11:00"

Math

// Calculate expression
calculate({ expression: "2 + 2 * 3" })
// β†’ "8"

// Roll dice
roll_dice({ notation: "2d6+5" })
// β†’ { "rolls": [3, 5], "sum": 8, "total": 13 }

// Convert units
convert_units({ value: 100, from_unit: "km", to_unit: "miles" })
// β†’ "62.137"

Text

// Transform text
transform_text({ text: "Hello World", operation: "slug" })
// β†’ "hello-world"

// Extract emails
extract_patterns({ text: "Contact us at support@example.com", pattern: "emails" })
// β†’ ["support@example.com"]

Validation

// Validate email
validate_email({ email: "user@example.com" })
// β†’ { "valid": true, "email": "user@example.com" }

// Sanitize HTML
sanitize_html({ html: "<script>alert('xss')</script>Hello", mode: "strip" })
// β†’ "Hello"

KV Storage

// Store data
kv_set({ key: "user_prefs", value: { theme: "dark" }, ttl: 3600 })
// β†’ { "success": true, "expires_at": 1730894400 }

// Retrieve data
kv_get({ key: "user_prefs", type: "json" })
// β†’ { "found": true, "value": { "theme": "dark" } }

Workers AI

// Chat completion
ai_chat({ prompt: "What is the capital of Australia?" })
// β†’ { "response": "The capital of Australia is Canberra.", ... }

// Sentiment analysis
ai_classify({ text: "This is amazing!" })
// β†’ { "classification": "POSITIVE", "score": 0.9987 }

// Generate embeddings (cached)
ai_embed({ text: "Cloudflare Workers are serverless functions" })
// β†’ { "embedding": [...], "dimensions": 768 }

πŸ”’ Security

  • Bearer Token Authentication: All MCP endpoints require valid Authorization: Bearer TOKEN header

  • Input Validation: All inputs validated before processing

  • Safe Expression Evaluation: Math expressions use recursive descent parser (no eval() or Function())

  • HTML Sanitization: XSS protection via tag stripping or entity escaping

  • Rate Limiting: Can be added via KV-based tracking (see Phase 8 docs)


πŸ“š Documentation

  • API Endpoints: See docs/API_ENDPOINTS.md for complete tool documentation

  • Implementation: See docs/IMPLEMENTATION_PHASES.md for build phases

  • MCP Protocol: https://modelcontextprotocol.io


πŸ› οΈ Development

Project Structure

cloudflare-mcp-toolbox/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Main Hono app + auth
β”‚   β”œβ”€β”€ mcp/
β”‚   β”‚   β”œβ”€β”€ server.ts         # MCP request handler
β”‚   β”‚   β”œβ”€β”€ types.ts          # TypeScript types
β”‚   β”‚   └── tools.ts          # Tool definitions (30 tools)
β”‚   β”œβ”€β”€ handlers/             # Tool implementations
β”‚   β”‚   β”œβ”€β”€ datetime.ts       # Date/time tools (5)
β”‚   β”‚   β”œβ”€β”€ math.ts           # Math tools (6)
β”‚   β”‚   β”œβ”€β”€ text.ts           # Text tools (6)
β”‚   β”‚   β”œβ”€β”€ validation.ts     # Validation tools (6)
β”‚   β”‚   β”œβ”€β”€ kv.ts             # KV tools (4)
β”‚   β”‚   └── ai.ts             # AI tools (3)
β”‚   └── utils/
β”‚       └── responses.ts      # MCP response builders
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ API_ENDPOINTS.md      # Complete tool documentation
β”‚   └── IMPLEMENTATION_PHASES.md  # Build phases
β”œβ”€β”€ wrangler.jsonc            # Cloudflare config
β”œβ”€β”€ package.json
└── tsconfig.json

Adding New Tools

  1. Create handler function in appropriate src/handlers/*.ts file

  2. Add tool definition to src/mcp/tools.ts

  3. Wire handler in src/mcp/server.ts switch statement

  4. Test locally with npm run dev

  5. Deploy with npm run deploy


🚦 Status

βœ… All 30 tools implemented and tested βœ… Deployed to Cloudflare Workers βœ… Bearer token authentication enabled βœ… KV namespace configured βœ… Workers AI binding active βœ… Production ready


πŸ“ License

MIT


πŸ‘€ Author

Jeremy Dawes (Jez) Jezweb | AI Engineer jeremy@jezweb.net | www.jezweb.com.au


πŸ™ Built With


Total Tools: 30 Categories: 6 Global Edge Deployment: βœ… Cold Start Time: 0ms Authentication: Bearer Token Default Timezone: Australia/Sydney

Known Issues

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to dynamically discover and invoke containerized tools that can be registered at runtime without redeployment. Built on Cloudflare Workers with scale-to-zero containers for secure, isolated tool execution.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides over 500 deterministic tools for math, conversions, validation, hashing, and more, enabling AI agents to perform accurate calculations and data transformations without hallucination.
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding assistants and agents (Cursor, Claude Code, Windsurf) to access 19 native MCP tools and 400+ deterministic sub-30ms edge APIsβ€”web-to-markdown, TokenSlimmer (-70% LLM cost cutter), prompt security shield, SEPA IBAN VoP, and EU DORA/AI Act complianceβ€”via https://topaigateway.com
      19
      34 npm
      1
      MIT