This is a Model Context Protocol (MCP) server for interacting with Cloudflare services. It provides a unified interface for managing Cloudflare KV Store, Workers, and Analytics.
kv_get
: Retrieve a value from KV storekv_put
: Store a value in KV storekv_delete
: Delete a key from KV storekv_list
: List keys in KV store
worker_list
: List all Workers in your accountworker_get
: Get a Worker's script contentworker_put
: Create or update a Worker scriptworker_delete
: Delete a Worker script
analytics_get
: Retrieve analytics data for your domain- Includes metrics like requests, bandwidth, threats, and page views
- Supports date range filtering
- Clone this repository
- Copy
.env.example
to.env
and fill in your Cloudflare credentials:CLOUDFLARE_ACCOUNT_ID=your_account_id_here CLOUDFLARE_API_TOKEN=your_api_token_here CLOUDFLARE_KV_NAMESPACE_ID=your_namespace_id_here
- Install dependencies:
npm install
- Run the server:
./start-cloudflare.sh
// Get value
kv_get({ key: "myKey" })
// Store value
kv_put({ key: "myKey", value: "myValue" })
// List keys
kv_list({ prefix: "app_", limit: 10 })
// List workers
worker_list()
// Get worker code
worker_get({ name: "my-worker" })
// Update worker
worker_put({
name: "my-worker",
script: "addEventListener('fetch', event => { ... })"
})
// Get today's analytics
analytics_get({
zoneId: "your_zone_id",
since: "2024-11-26T00:00:00Z",
until: "2024-11-26T23:59:59Z"
})
- Never commit your
.env
file - Ensure your Cloudflare API token has appropriate permissions
- Monitor analytics for suspicious activity
Contributions are welcome! Please feel free to submit a Pull Request.