cloudflare-mcp-server 1.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudflare_mcp_server-1.7.1/.github/.gitkeep +0 -0
- cloudflare_mcp_server-1.7.1/.github/dependabot.yml +26 -0
- cloudflare_mcp_server-1.7.1/.github/workflows/ci.yml +59 -0
- cloudflare_mcp_server-1.7.1/.github/workflows/image.yml +53 -0
- cloudflare_mcp_server-1.7.1/.github/workflows/publish.yml +52 -0
- cloudflare_mcp_server-1.7.1/.github/workflows/spec-update.yml +86 -0
- cloudflare_mcp_server-1.7.1/.gitignore +3 -0
- cloudflare_mcp_server-1.7.1/CHANGELOG.md +243 -0
- cloudflare_mcp_server-1.7.1/CONTRIBUTING.md +55 -0
- cloudflare_mcp_server-1.7.1/Dockerfile +20 -0
- cloudflare_mcp_server-1.7.1/EXAMPLES.md +364 -0
- cloudflare_mcp_server-1.7.1/LICENSE +21 -0
- cloudflare_mcp_server-1.7.1/PKG-INFO +318 -0
- cloudflare_mcp_server-1.7.1/QUICKSTART.md +221 -0
- cloudflare_mcp_server-1.7.1/README.md +283 -0
- cloudflare_mcp_server-1.7.1/ROADMAP.md +202 -0
- cloudflare_mcp_server-1.7.1/agent-card.json +2173 -0
- cloudflare_mcp_server-1.7.1/cloudflare-mcp-server.png +0 -0
- cloudflare_mcp_server-1.7.1/docs/hero.svg +40 -0
- cloudflare_mcp_server-1.7.1/pyproject.toml +63 -0
- cloudflare_mcp_server-1.7.1/scripts/build_spec.py +68 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/__init__.py +42 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/__main__.py +3 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/agent_card.py +158 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/client.py +339 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/config.py +109 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/context.py +106 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/data/openapi.json.gz +0 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/docs.py +266 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/guard.py +123 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/http_server.py +139 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/project.py +171 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/prompts.py +117 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/registry.py +108 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/resources.py +143 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/review.py +156 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/server.py +292 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/spec.py +451 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/__init__.py +42 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/account.py +54 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/analytics.py +158 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/api.py +343 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/cache.py +57 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/dns.py +333 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/docs.py +121 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/graphql.py +188 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/kv.py +202 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/platform.py +484 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/project.py +662 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/review.py +1100 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/security.py +232 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/storage.py +318 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/workers.py +314 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/tools/zones.py +73 -0
- cloudflare_mcp_server-1.7.1/src/cloudflare_mcp_server/web.py +78 -0
- cloudflare_mcp_server-1.7.1/tests/__init__.py +12 -0
- cloudflare_mcp_server-1.7.1/tests/conftest.py +33 -0
- cloudflare_mcp_server-1.7.1/tests/test_agent_card.py +32 -0
- cloudflare_mcp_server-1.7.1/tests/test_analytics.py +115 -0
- cloudflare_mcp_server-1.7.1/tests/test_api_tools.py +265 -0
- cloudflare_mcp_server-1.7.1/tests/test_client.py +102 -0
- cloudflare_mcp_server-1.7.1/tests/test_config.py +44 -0
- cloudflare_mcp_server-1.7.1/tests/test_docs.py +167 -0
- cloudflare_mcp_server-1.7.1/tests/test_graphql_tools.py +135 -0
- cloudflare_mcp_server-1.7.1/tests/test_phase6.py +189 -0
- cloudflare_mcp_server-1.7.1/tests/test_project.py +245 -0
- cloudflare_mcp_server-1.7.1/tests/test_readme.py +21 -0
- cloudflare_mcp_server-1.7.1/tests/test_review.py +393 -0
- cloudflare_mcp_server-1.7.1/tests/test_smoke.py +29 -0
- cloudflare_mcp_server-1.7.1/tests/test_tools.py +239 -0
- cloudflare_mcp_server-1.7.1/tests/test_toolsets.py +345 -0
- cloudflare_mcp_server-1.7.1/uv.lock +1387 -0
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Python dependencies (pip/pyproject.toml)
|
|
4
|
+
- package-ecosystem: "pip"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
day: "monday"
|
|
9
|
+
time: "09:00"
|
|
10
|
+
open-pull-requests-limit: 10
|
|
11
|
+
labels:
|
|
12
|
+
- "dependencies"
|
|
13
|
+
- "security"
|
|
14
|
+
commit-message:
|
|
15
|
+
prefix: "chore"
|
|
16
|
+
include: "scope"
|
|
17
|
+
|
|
18
|
+
# GitHub Actions
|
|
19
|
+
- package-ecosystem: "github-actions"
|
|
20
|
+
directory: "/"
|
|
21
|
+
schedule:
|
|
22
|
+
interval: "monthly"
|
|
23
|
+
open-pull-requests-limit: 5
|
|
24
|
+
labels:
|
|
25
|
+
- "dependencies"
|
|
26
|
+
- "github-actions"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-and-test:
|
|
13
|
+
name: build-and-test
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.10", "3.13"]
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
21
|
+
with:
|
|
22
|
+
persist-credentials: false
|
|
23
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
- name: Install (locked)
|
|
27
|
+
run: uv sync --locked --extra dev
|
|
28
|
+
- name: Lint
|
|
29
|
+
run: |
|
|
30
|
+
uv run ruff check .
|
|
31
|
+
uv run ruff format --check .
|
|
32
|
+
- name: Test
|
|
33
|
+
run: uv run pytest -q
|
|
34
|
+
- name: Build package
|
|
35
|
+
run: uv build
|
|
36
|
+
- name: Server starts and answers MCP initialize over stdio
|
|
37
|
+
env:
|
|
38
|
+
CLOUDFLARE_API_TOKEN: dummy-token-for-startup-check
|
|
39
|
+
run: |
|
|
40
|
+
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"ci","version":"0"}}}' \
|
|
41
|
+
| timeout 20 uv run cloudflare-mcp-server > out.json || true
|
|
42
|
+
cat out.json
|
|
43
|
+
grep -q '"serverInfo"' out.json
|
|
44
|
+
- name: HTTP entry point serves health and tools/list
|
|
45
|
+
env:
|
|
46
|
+
CLOUDFLARE_API_TOKEN: dummy-token-for-startup-check
|
|
47
|
+
MCP_AUTH_TOKENS: ci-read-token-0123456789:read
|
|
48
|
+
MCP_PORT: "8765"
|
|
49
|
+
run: |
|
|
50
|
+
uv run cloudflare-mcp-server-http &
|
|
51
|
+
for i in $(seq 1 30); do curl -sf http://127.0.0.1:8765/healthz && break; sleep 0.5; done
|
|
52
|
+
test "$(curl -s -o /dev/null -w '%{http_code}' -X POST http://127.0.0.1:8765/mcp/)" = 401
|
|
53
|
+
curl -sf -X POST http://127.0.0.1:8765/mcp/ \
|
|
54
|
+
-H 'Authorization: Bearer ci-read-token-0123456789' \
|
|
55
|
+
-H 'Accept: application/json, text/event-stream' -H 'Content-Type: application/json' \
|
|
56
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | grep -q '"list_zones"'
|
|
57
|
+
- name: Container image builds
|
|
58
|
+
if: matrix.python-version == '3.13'
|
|
59
|
+
run: docker build -t cloudflare-mcp-server:ci .
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Container image
|
|
2
|
+
|
|
3
|
+
# Builds the multi-arch image and pushes it to ghcr.io with an SBOM and provenance,
|
|
4
|
+
# on every published release (or by hand for an existing tag).
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
tag:
|
|
11
|
+
description: "Release tag to build, e.g. v1.7.0"
|
|
12
|
+
required: true
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
image:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
permissions:
|
|
21
|
+
contents: read
|
|
22
|
+
packages: write
|
|
23
|
+
id-token: write
|
|
24
|
+
attestations: write
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
27
|
+
with:
|
|
28
|
+
ref: ${{ github.event.release.tag_name || inputs.tag }}
|
|
29
|
+
persist-credentials: false
|
|
30
|
+
- uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
|
31
|
+
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
|
32
|
+
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
|
33
|
+
with:
|
|
34
|
+
registry: ghcr.io
|
|
35
|
+
username: ${{ github.actor }}
|
|
36
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
37
|
+
- id: meta
|
|
38
|
+
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
|
39
|
+
with:
|
|
40
|
+
images: ghcr.io/${{ github.repository }}
|
|
41
|
+
tags: |
|
|
42
|
+
type=semver,pattern={{version}},value=${{ github.event.release.tag_name || inputs.tag }}
|
|
43
|
+
type=semver,pattern={{major}}.{{minor}},value=${{ github.event.release.tag_name || inputs.tag }}
|
|
44
|
+
type=raw,value=latest
|
|
45
|
+
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
|
46
|
+
with:
|
|
47
|
+
context: .
|
|
48
|
+
platforms: linux/amd64,linux/arm64
|
|
49
|
+
push: true
|
|
50
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
51
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
52
|
+
sbom: true
|
|
53
|
+
provenance: mode=max
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Trusted publishing (OIDC): no API token is stored. The PyPI project must list this repo,
|
|
4
|
+
# workflow file publish.yml and environment "pypi" as a trusted publisher.
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
tag:
|
|
11
|
+
description: "Release tag to publish, e.g. v1.7.1"
|
|
12
|
+
required: true
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
|
+
with:
|
|
23
|
+
ref: ${{ github.event.release.tag_name || inputs.tag }}
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
26
|
+
- name: Tag matches the package version
|
|
27
|
+
env:
|
|
28
|
+
TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
|
29
|
+
run: |
|
|
30
|
+
version=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)
|
|
31
|
+
test "v$version" = "$TAG" || { echo "tag $TAG != version $version"; exit 1; }
|
|
32
|
+
- run: uv sync --locked --extra dev && uv run pytest -q
|
|
33
|
+
- run: uv build
|
|
34
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
35
|
+
with:
|
|
36
|
+
name: dist
|
|
37
|
+
path: dist/
|
|
38
|
+
|
|
39
|
+
publish:
|
|
40
|
+
needs: build
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
environment:
|
|
43
|
+
name: pypi
|
|
44
|
+
url: https://pypi.org/p/cloudflare-mcp-server
|
|
45
|
+
permissions:
|
|
46
|
+
id-token: write
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
49
|
+
with:
|
|
50
|
+
name: dist
|
|
51
|
+
path: dist/
|
|
52
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: Cloudflare API spec update
|
|
2
|
+
|
|
3
|
+
# Weekly: rebuild the bundled OpenAPI spec from cloudflare/api-schemas. When it changed, run the
|
|
4
|
+
# tests against it and open (or update) a pull request with what was added, removed or deprecated.
|
|
5
|
+
# The commit is made through the GitHub API, so it is signed (the default branch requires that).
|
|
6
|
+
#
|
|
7
|
+
# Pull requests opened with GITHUB_TOKEN don't start other workflows, so CI doesn't run on them by
|
|
8
|
+
# itself. This workflow runs the tests and reports the result in the PR body; to run CI too, close
|
|
9
|
+
# and reopen the PR, or push a commit to its branch.
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
schedule:
|
|
13
|
+
- cron: "17 6 * * 1"
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write
|
|
18
|
+
pull-requests: write
|
|
19
|
+
|
|
20
|
+
concurrency:
|
|
21
|
+
group: spec-update
|
|
22
|
+
cancel-in-progress: false
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
update:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
29
|
+
with:
|
|
30
|
+
persist-credentials: false
|
|
31
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
32
|
+
- name: Rebuild the spec
|
|
33
|
+
run: uv run --no-project python scripts/build_spec.py > summary.md
|
|
34
|
+
- name: Did it change?
|
|
35
|
+
id: changed
|
|
36
|
+
run: |
|
|
37
|
+
if git diff --quiet -- src/cloudflare_mcp_server/data/openapi.json.gz; then
|
|
38
|
+
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
39
|
+
echo "Spec unchanged."
|
|
40
|
+
else
|
|
41
|
+
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
42
|
+
fi
|
|
43
|
+
- name: Test against the new spec
|
|
44
|
+
id: tests
|
|
45
|
+
if: steps.changed.outputs.changed == 'true'
|
|
46
|
+
continue-on-error: true
|
|
47
|
+
run: |
|
|
48
|
+
uv sync --locked --extra dev
|
|
49
|
+
uv run pytest -q 2>&1 | tail -25 | tee pytest.txt
|
|
50
|
+
exit "${PIPESTATUS[0]}"
|
|
51
|
+
- name: Write the PR body
|
|
52
|
+
if: steps.changed.outputs.changed == 'true'
|
|
53
|
+
env:
|
|
54
|
+
TESTS: ${{ steps.tests.outcome }}
|
|
55
|
+
run: |
|
|
56
|
+
{
|
|
57
|
+
echo "Refreshes the bundled Cloudflare OpenAPI spec from [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas)."
|
|
58
|
+
echo
|
|
59
|
+
cat summary.md
|
|
60
|
+
echo
|
|
61
|
+
if [ "$TESTS" = "success" ]; then
|
|
62
|
+
echo "**Tests: passed** against the new spec."
|
|
63
|
+
else
|
|
64
|
+
echo "**Tests: failed** against the new spec. Fix them on this branch before merging."
|
|
65
|
+
echo
|
|
66
|
+
echo '```'
|
|
67
|
+
cat pytest.txt
|
|
68
|
+
echo '```'
|
|
69
|
+
fi
|
|
70
|
+
echo
|
|
71
|
+
echo "Before merging, add a CHANGELOG line if the change matters to users (new products, removed endpoints)."
|
|
72
|
+
} > body.md
|
|
73
|
+
rm -f summary.md pytest.txt
|
|
74
|
+
- name: Open or update the pull request
|
|
75
|
+
if: steps.changed.outputs.changed == 'true'
|
|
76
|
+
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
|
|
77
|
+
with:
|
|
78
|
+
token: ${{ github.token }}
|
|
79
|
+
sign-commits: true
|
|
80
|
+
add-paths: src/cloudflare_mcp_server/data/openapi.json.gz
|
|
81
|
+
branch: automation/cloudflare-spec
|
|
82
|
+
delete-branch: true
|
|
83
|
+
commit-message: "chore(spec): refresh the Cloudflare OpenAPI spec"
|
|
84
|
+
title: "chore(spec): refresh the Cloudflare OpenAPI spec"
|
|
85
|
+
body-path: body.md
|
|
86
|
+
labels: dependencies
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.7.1] - 2026-12-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **PyPI publishing** (`publish.yml`): each published release is tested, built and uploaded to PyPI with trusted publishing (OIDC, no stored token). Install with `uvx cloudflare-mcp-server`.
|
|
12
|
+
- The **container image** now builds and pushes to `ghcr.io/ry-ops/cloudflare-mcp-server` on every published release.
|
|
13
|
+
- PyPI metadata: classifiers, keywords and project links.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- README images and links are absolute, so they work on PyPI.
|
|
17
|
+
|
|
18
|
+
## [1.7.0] - 2026-12-06
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **HTTP with roles**: `cloudflare-mcp-server-http` serves MCP over streamable HTTP at `/mcp`. `MCP_AUTH_TOKENS` maps bearer tokens (16+ characters, compared in constant time) to `read`, `operator` or `admin`; each role gets its own server, so a client only sees the tools its role allows. `/healthz` for probes; `MCP_HOST`/`MCP_PORT`.
|
|
22
|
+
- **Protected names**: `CLOUDFLARE_PROTECTED` lists zones, record names (wildcards allowed), scripts, buckets and IDs that writes refuse to touch. Checked on every write request, including `cf_api_request` and DNS batches (record IDs are looked up to their names).
|
|
23
|
+
- **Audit log**: `CLOUDFLARE_AUDIT_LOG` appends one JSON line per write request (time, tool, method, path, status, or refused), mode 600, never bodies or headers.
|
|
24
|
+
- **Rate limiting**: requests are kept under 1,100 per 5 minutes (`CLOUDFLARE_RATE_LIMIT`; Cloudflare allows 1,200), on top of the existing Retry-After backoff.
|
|
25
|
+
- **Account names**: `account_id` arguments also take an account name.
|
|
26
|
+
- **Container image workflow** (`image.yml`): multi-arch build to ghcr.io with SBOM and provenance, run by hand for a release tag. CI now builds the image and checks the HTTP entry point.
|
|
27
|
+
- A test keeps the README's tool list and counts in step with the registry.
|
|
28
|
+
- `starlette` and `uvicorn` are now explicit dependencies (the MCP SDK already installed them).
|
|
29
|
+
|
|
30
|
+
## [1.6.0] - 2026-12-06
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- **Project help** (`project` toolset): `project_inspect` compares a local Wrangler project (jsonc/json/toml, environments) with the deployed Worker: missing binding targets, bindings/routes/custom domains in only one place, `.dev.vars` names not set as secrets, compatibility date and observability drift. Reads only inside `CLOUDFLARE_PROJECT_ROOTS` (default: home folder) and never returns secret or var values.
|
|
34
|
+
- `dns_plan`: diff desired records against a zone into create/change/delete, with the `batch_dns_records` arguments to apply it. The apex NS records are never pruned.
|
|
35
|
+
- `project_plan`: which resources exist, the create calls for the rest, the permissions they need (from the spec), and the Wrangler bindings to add.
|
|
36
|
+
- **MCP prompts**: audit_account, harden_zone, investigate_5xx, setup_domain, move_dns, ship_worker, clean_up, explain_rules. Each appears only when its tools are loaded.
|
|
37
|
+
- **MCP resources**: `cloudflare://accounts`, `cloudflare://zones`, `cloudflare://inventory`, and the template `cloudflare://zone/{name}/summary`.
|
|
38
|
+
- `tomli` on Python 3.10 for reading `wrangler.toml`.
|
|
39
|
+
|
|
40
|
+
## [1.5.0] - 2026-12-06
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
- **Review engine** (`review` toolset): `review_zone`, `review_account`, `review_workers`, `review_storage`, `review_zero_trust`, `review_traffic` and `review_all`. They only read, and return findings with a stable id, severity, resource, evidence, why it matters, a suggested `cf_api_request` fix (never run) and a docs link, plus a score out of 100.
|
|
44
|
+
- Zone checks: dangling CNAMEs (subdomain takeover, looked up with the local resolver), origin IPs exposed by DNS-only records, SPF/DMARC/CAA, DNS-only wildcards, DNSSEC, SSL mode, minimum TLS, Always Use HTTPS, HSTS, TLS 1.3, certificates, security level, Development Mode, performance settings, paused zones, 5xx rate and cache ratio.
|
|
45
|
+
- Account checks: members without 2FA, Super Administrator count, stale invitations, API token expiry/use/IP restriction, Registrar expiry and transfer lock.
|
|
46
|
+
- Workers checks: old compatibility dates, observability off, routes to deleted scripts, error rate and idle scripts from GraphQL, `workers.dev` left on beside a custom domain.
|
|
47
|
+
- Storage and Zero Trust checks: public `r2.dev` buckets, empty D1/KV, queues without consumers, Access apps with no policy or an Everyone allow/bypass, service tokens near expiry, tunnels down.
|
|
48
|
+
- Checks the token can't run are reported under `skipped` with the permission they need.
|
|
49
|
+
- `CLOUDFLARE_REVIEW_IGNORE` silences checks by id, prefix (`perf.*`) or id@resource.
|
|
50
|
+
|
|
51
|
+
## [1.3.0] - 2026-12-06
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
- **Docs knowledge** (roadmap Phase 2):
|
|
55
|
+
- `cf_docs_search`: searches all of developers.cloudflare.com (about 6,500 pages across 112 products) through the docs' own `llms.txt` indexes, fetched in parallel and cached for a day.
|
|
56
|
+
- `cf_docs_read`: reads a page as Markdown, whole or one section by heading. Only developers.cloudflare.com URLs are allowed.
|
|
57
|
+
- `cf_limits`: a product's current limits, read live from its docs limits page.
|
|
58
|
+
- `cf_changelog`: recent changelog entries, for all products or one, with optional word filtering.
|
|
59
|
+
- `CLOUDFLARE_CACHE_DIR` sets where docs are cached.
|
|
60
|
+
- Each dedicated tool declares the REST endpoints it calls, and a test checks they all exist in the spec and aren't deprecated.
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
- The weekly spec check opens a pull request (signed commit, branch `automation/cloudflare-spec`) instead of an issue. The PR body says what was added, removed or deprecated, and whether the tests pass against the new spec.
|
|
64
|
+
|
|
65
|
+
## [1.2.0] - 2026-12-06
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
- **The whole Cloudflare API** (roadmap Phase 1). The Cloudflare OpenAPI spec (3,976 operations, from `cloudflare/api-schemas`) ships with the server, and five tools use it:
|
|
69
|
+
- `cf_api_search`: ranked search over the spec, filterable by method, product and scope. Results include the token permissions and plan limits.
|
|
70
|
+
- `cf_api_describe`: an operation's parameters, request body schema (refs resolved, within a size budget), result shape, permissions, plans and a ready-to-run call.
|
|
71
|
+
- `cf_api_request`: calls any endpoint. Fills `{account_id}`/`{zone_id}` (zone names work), checks the path against the spec, and sends JSON, text or multipart bodies. Supports `dry_run` and `all_pages`. Explains a 403 with the permissions the token needs, and warns on deprecated or plan-limited endpoints.
|
|
72
|
+
- `cf_graphql`: runs GraphQL Analytics queries (read-only).
|
|
73
|
+
- `cf_graphql_schema`: lists datasets and shows each one's filters, sort orders and fields, read by introspection and cached per session.
|
|
74
|
+
- `CLOUDFLARE_MAX_OUTPUT_CHARS` (default 80,000) caps every tool result. `CLOUDFLARE_SPEC_PATH` uses another copy of the spec.
|
|
75
|
+
- `scripts/build_spec.py` refreshes the bundled spec and summarizes what changed. A weekly workflow opens an issue when Cloudflare's spec changes.
|
|
76
|
+
- A test checks that every dedicated tool maps to a real, non-deprecated operation in the spec.
|
|
77
|
+
|
|
78
|
+
### Changed
|
|
79
|
+
- `read_kv_value` cuts values at 50,000 characters (was 100,000), so the value fits under the output cap.
|
|
80
|
+
|
|
81
|
+
## [1.1.0] - 2026-12-06
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
- **The server crashed on startup with any fresh install** (`'Server' object has no attribute 'list_tools'`). `mcp` wasn't pinned and mcp 2.x removed the decorator API. The server now uses the mcp 2.x handler API, requires `mcp>=2.3,<3`, and ships a `uv.lock`.
|
|
85
|
+
- `get_zone_analytics` used the deprecated Zone Analytics REST endpoint. It now uses the GraphQL Analytics API (`httpRequests1dGroups`) and adds the cache hit ratio, 4xx/5xx error rates, status codes, top countries and a daily breakdown. `since`/`until` take dates, ISO times, spans (`7d`, `24h`) or the old negative minutes.
|
|
86
|
+
- Cloudflare's error codes and messages are kept on 4xx/5xx responses, and failures are returned as MCP errors (`isError`) with a hint.
|
|
87
|
+
- KV key names are URL-encoded, so keys with `/`, `?`, `#`, `%` or spaces work.
|
|
88
|
+
- `write_kv_value` sends metadata as multipart, as the API expects (it was sent as a query parameter and dropped).
|
|
89
|
+
- `update_dns_record` uses PATCH and changes only the fields you pass. PUT used to reset `proxied`, TTL and comment.
|
|
90
|
+
- `python -m cloudflare_mcp_server` works (there was no `__main__.py`), so the Docker image starts.
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- `verify_token`: token status and expiry, the accounts it reaches, and the server's safety settings.
|
|
94
|
+
- Pagination: list tools return `count`, `items`, `more_available` and `total_count`; `all_pages: true` reads every page up to `CLOUDFLARE_MAX_ITEMS` (default 1000).
|
|
95
|
+
- `zone_id` accepts a domain name. Account tools default to the token's only account when `CLOUDFLARE_ACCOUNT_ID` is unset.
|
|
96
|
+
- DNS: `name_contains`, `content_contains`, `proxied` and `search` filters; `tags`, `data` (SRV, CAA, HTTPS, ...) and `settings` on create/update.
|
|
97
|
+
- `purge_cache` takes `prefixes`; `read_kv_value` can return the key's metadata and cuts values over 100,000 characters.
|
|
98
|
+
- Tool annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`) and integer types where the API needs whole numbers.
|
|
99
|
+
- 429 responses are retried after `Retry-After`, and 5xx responses on GET are retried too.
|
|
100
|
+
- Tests: 78 tests with the API mocked (respx) and the MCP protocol driven in-process. CI runs Ruff, the tests on Python 3.10 and 3.13, a build, and a stdio startup check.
|
|
101
|
+
|
|
102
|
+
### Changed
|
|
103
|
+
- **Safety switches.** `CLOUDFLARE_READ_ONLY` offers only tools that read and fails closed (any value other than false/0/no/off turns it on). **Deletes and purge-everything are now off by default.** Set `CLOUDFLARE_ALLOW_DESTRUCTIVE=true` to use `delete_dns_record`, `delete_kv_value` or `purge_everything`.
|
|
104
|
+
- List tools return `{count, items, more_available, ...}` instead of a bare array.
|
|
105
|
+
- Results are compact JSON.
|
|
106
|
+
- The code is split into modules (`client`, `config`, `server`, `tools/*`). The Docker image uses uv with the lock file and runs as a non-root user.
|
|
107
|
+
|
|
108
|
+
## [1.0.0] - 2025-10-05
|
|
109
|
+
|
|
110
|
+
### Added
|
|
111
|
+
- Initial release of Cloudflare MCP Server (Python version)
|
|
112
|
+
- Built with Python 3.10+ and async/await
|
|
113
|
+
- Managed with uv for fast dependency management
|
|
114
|
+
- Zone management tools (list_zones, get_zone)
|
|
115
|
+
- DNS record management (list, create, update, delete)
|
|
116
|
+
- Cache purging capabilities (purge_cache)
|
|
117
|
+
- Workers KV operations (list, read, write, delete namespaces and keys)
|
|
118
|
+
- Zone analytics retrieval
|
|
119
|
+
- Comprehensive documentation (README, QUICKSTART, EXAMPLES, CONTRIBUTING)
|
|
120
|
+
- Full type hints for better IDE support
|
|
121
|
+
- Error handling for all API operations
|
|
122
|
+
- Support for pagination in list operations
|
|
123
|
+
- Filter support for DNS records and zones
|
|
124
|
+
- httpx async client for reliable HTTP requests
|
|
125
|
+
|
|
126
|
+
### Features by Category
|
|
127
|
+
|
|
128
|
+
#### DNS Management
|
|
129
|
+
- Create DNS records (A, AAAA, CNAME, TXT, MX, and more)
|
|
130
|
+
- Update existing DNS records
|
|
131
|
+
- Delete DNS records
|
|
132
|
+
- List and filter DNS records by type, name, content
|
|
133
|
+
- Support for proxied records
|
|
134
|
+
- Custom TTL configuration
|
|
135
|
+
- Priority support for MX/SRV records
|
|
136
|
+
- Record comments support
|
|
137
|
+
|
|
138
|
+
#### Zone Operations
|
|
139
|
+
- List all zones with filtering
|
|
140
|
+
- Get detailed zone information
|
|
141
|
+
- Filter by zone status
|
|
142
|
+
- Pagination support
|
|
143
|
+
|
|
144
|
+
#### Cache Management
|
|
145
|
+
- Purge entire zone cache
|
|
146
|
+
- Purge specific files by URL
|
|
147
|
+
- Purge by cache tags
|
|
148
|
+
- Purge by hostname
|
|
149
|
+
|
|
150
|
+
#### Workers KV
|
|
151
|
+
- List all KV namespaces
|
|
152
|
+
- Read values from KV storage
|
|
153
|
+
- Write values with optional TTL
|
|
154
|
+
- Delete keys from KV
|
|
155
|
+
- List keys with prefix filtering
|
|
156
|
+
- Metadata support for key-value pairs
|
|
157
|
+
- Pagination for key listings
|
|
158
|
+
|
|
159
|
+
#### Analytics
|
|
160
|
+
- Retrieve zone analytics
|
|
161
|
+
- Customizable time ranges
|
|
162
|
+
- Traffic and bandwidth statistics
|
|
163
|
+
- Threat and security metrics
|
|
164
|
+
|
|
165
|
+
### Technical Details
|
|
166
|
+
- Built with Python 3.10+
|
|
167
|
+
- Uses MCP SDK (Python) v1.1.2+
|
|
168
|
+
- httpx for async HTTP requests
|
|
169
|
+
- Full async/await support
|
|
170
|
+
- Type hints throughout
|
|
171
|
+
- uv-compatible pyproject.toml
|
|
172
|
+
- ruff for linting and formatting
|
|
173
|
+
- Comprehensive error handling
|
|
174
|
+
- JSON response formatting
|
|
175
|
+
|
|
176
|
+
### Development Features
|
|
177
|
+
- uv support for fast package management
|
|
178
|
+
- Editable install with `uv pip install -e .`
|
|
179
|
+
- Dev dependencies for testing and linting
|
|
180
|
+
- ruff configuration for code quality
|
|
181
|
+
- pytest-ready structure (tests to be implemented)
|
|
182
|
+
|
|
183
|
+
## [1.4.0] - 2026-12-06
|
|
184
|
+
|
|
185
|
+
### Added
|
|
186
|
+
- **Toolsets.** Tools are grouped by product and `CLOUDFLARE_TOOLSETS` (default `all`) loads only the groups you name; `core` and `api` are always on. An unknown name stops the server with the list of valid ones.
|
|
187
|
+
- **dns**: `batch_dns_records` (atomic posts/patches/puts/deletes; deletes need `CLOUDFLARE_ALLOW_DESTRUCTIVE`), `export_dns_records` and `import_dns_records` (BIND), `find_dns_records` across every zone, `get_dnssec`.
|
|
188
|
+
- **security**: `get_zone_settings` (reads settings one by one; the all-settings endpoint is deprecated), `update_zone_setting`, `list_certificate_packs`, `explain_rules` (every ruleset phase as readable rules), `list_turnstile_widgets`.
|
|
189
|
+
- **workers**: `list_workers`, `get_worker` (bindings, secret names, compatibility, observability, workers.dev, custom domains, deployments, optional routes), `list_worker_routes`, `query_worker_logs` (Workers Logs telemetry: events, errors, text search, grouped counts).
|
|
190
|
+
- **pages**: `list_pages_projects`, `list_pages_deployments`.
|
|
191
|
+
- **storage**: `list_r2_buckets`, `get_r2_bucket`, `list_d1_databases`, `d1_query` (read-only SQL only), `d1_execute`, `list_queues`, `list_vectorize_indexes`, `vectorize_query` (by vector, or by text embedded with a matching Workers AI model), `list_hyperdrive_configs` (no passwords).
|
|
192
|
+
- **ai**: `search_ai_models`, `run_ai_model`, `list_ai_gateways`, `list_ai_gateway_logs`.
|
|
193
|
+
- **zerotrust**: `list_access_apps`, `list_access_service_tokens`, `list_tunnels`, `list_gateway_rules`.
|
|
194
|
+
- **email** `get_email_routing`; **network** `list_load_balancers`, `list_registrar_domains`; **logs** `get_audit_logs`; **account** `list_account_members`, `list_api_tokens`; **radar** `radar_domain`.
|
|
195
|
+
- Every new tool declares the API operations it uses, and a test checks they exist in the bundled spec and aren't deprecated.
|
|
196
|
+
|
|
197
|
+
### Planned Features
|
|
198
|
+
- Automated tests with pytest
|
|
199
|
+
- Cloudflare Workers script management
|
|
200
|
+
- R2 storage operations
|
|
201
|
+
- Pages deployment management
|
|
202
|
+
- Load Balancer configuration
|
|
203
|
+
- Stream video operations
|
|
204
|
+
- Email routing configuration
|
|
205
|
+
- WAF rule management
|
|
206
|
+
- Rate limiting configuration
|
|
207
|
+
- Better error messages
|
|
208
|
+
- Rate limit handling
|
|
209
|
+
- Batch operations
|
|
210
|
+
- Response caching
|
|
211
|
+
|
|
212
|
+
### Improvements
|
|
213
|
+
- Add mypy for static type checking
|
|
214
|
+
- Add more comprehensive tests
|
|
215
|
+
- Improve error messages
|
|
216
|
+
- Add request retry logic
|
|
217
|
+
- Add response validation
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Version History
|
|
222
|
+
|
|
223
|
+
### Format
|
|
224
|
+
- `Added` for new features
|
|
225
|
+
- `Changed` for changes in existing functionality
|
|
226
|
+
- `Deprecated` for soon-to-be removed features
|
|
227
|
+
- `Removed` for now removed features
|
|
228
|
+
- `Fixed` for any bug fixes
|
|
229
|
+
- `Security` for vulnerability fixes
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Migration from Node.js Version
|
|
234
|
+
|
|
235
|
+
This is a complete rewrite in Python. Key differences:
|
|
236
|
+
- Uses Python's async/await instead of TypeScript/Node.js
|
|
237
|
+
- Managed with uv instead of npm
|
|
238
|
+
- Uses httpx instead of fetch
|
|
239
|
+
- Uses MCP Python SDK instead of TypeScript SDK
|
|
240
|
+
- Same functionality, different implementation
|
|
241
|
+
|
|
242
|
+
*Note: This is version 1.0.0 - the initial Python release.*
|
|
243
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping. The work list is [ROADMAP.md](ROADMAP.md): pick an item, open an issue or a draft PR, and say which item it is.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
You need Python 3.10+ and [uv](https://github.com/astral-sh/uv).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/ry-ops/cloudflare-mcp-server
|
|
11
|
+
cd cloudflare-mcp-server
|
|
12
|
+
uv sync --extra dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Checks
|
|
16
|
+
|
|
17
|
+
CI runs all of these on Python 3.10 and 3.13. Run them before you push:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv run ruff check .
|
|
21
|
+
uv run ruff format --check .
|
|
22
|
+
uv run pytest -q
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The tests mock the Cloudflare API with [respx](https://lundberg.github.io/respx/) and drive the MCP protocol in-process with `mcp.Client`. They need no token and make no network calls.
|
|
26
|
+
|
|
27
|
+
## Layout
|
|
28
|
+
|
|
29
|
+
| Path | What it holds |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `src/cloudflare_mcp_server/client.py` | HTTP client: the v4 envelope, `CloudflareAPIError`, retries, page and cursor pagination, GraphQL |
|
|
32
|
+
| `src/cloudflare_mcp_server/config.py` | Environment settings (the safety switches fail closed) |
|
|
33
|
+
| `src/cloudflare_mcp_server/registry.py` | `ToolSpec`: schema, annotations, safety flags, argument checks |
|
|
34
|
+
| `src/cloudflare_mcp_server/context.py` | What handlers get: the client, the config, zone-name and account lookups |
|
|
35
|
+
| `src/cloudflare_mcp_server/server.py` | MCP handlers (mcp 2.x `Server`), tool filtering, error results |
|
|
36
|
+
| `src/cloudflare_mcp_server/tools/` | One module per tool group, each exporting `SPECS` |
|
|
37
|
+
| `src/cloudflare_mcp_server/agent_card.py` | Builds `agent-card.json` from the registry |
|
|
38
|
+
|
|
39
|
+
## Adding a tool
|
|
40
|
+
|
|
41
|
+
1. Write an async handler `(ctx, args) -> result` in the right `tools/` module, and add a `ToolSpec` to its `SPECS`. Set `read_only=False` for anything that changes state, `destructive=True` when it can't be undone, and `gated=True` when it should need `CLOUDFLARE_ALLOW_DESTRUCTIVE`.
|
|
42
|
+
2. Use `ctx.zone_id(...)` and `ctx.account_id(...)` so names and defaults work, and `ctx.client.list_pages` / `list_cursor` for lists.
|
|
43
|
+
3. Add tests in `tests/` with the API mocked.
|
|
44
|
+
4. Regenerate the agent card: `uv run python -m cloudflare_mcp_server.agent_card` (a test fails if it's stale).
|
|
45
|
+
5. Update the README tool table and CHANGELOG.
|
|
46
|
+
|
|
47
|
+
## Pull requests
|
|
48
|
+
|
|
49
|
+
- One topic per PR, with a [Keep a Changelog](https://keepachangelog.com/) entry.
|
|
50
|
+
- Commits to `main` must be signed (repository ruleset).
|
|
51
|
+
- Never commit a real token; tests use dummy values.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
By contributing, you agree that your contributions are licensed under the MIT License.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
FROM python:3.13-slim
|
|
2
|
+
|
|
3
|
+
COPY --from=ghcr.io/astral-sh/uv:0.13 /uv /usr/local/bin/uv
|
|
4
|
+
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
|
7
|
+
|
|
8
|
+
# Dependencies first, for layer caching.
|
|
9
|
+
COPY pyproject.toml uv.lock README.md ./
|
|
10
|
+
RUN uv sync --locked --no-dev --no-install-project
|
|
11
|
+
|
|
12
|
+
COPY src ./src
|
|
13
|
+
RUN uv sync --locked --no-dev && useradd --system --uid 10001 mcp
|
|
14
|
+
USER mcp
|
|
15
|
+
|
|
16
|
+
# MCP over stdio: run with `docker run -i` and pass CLOUDFLARE_API_TOKEN with -e.
|
|
17
|
+
# Over HTTP: --entrypoint /app/.venv/bin/cloudflare-mcp-server-http -e MCP_HOST=0.0.0.0
|
|
18
|
+
# -e MCP_AUTH_TOKENS=<token>:<role> -p 8000:8000
|
|
19
|
+
EXPOSE 8000
|
|
20
|
+
ENTRYPOINT ["/app/.venv/bin/cloudflare-mcp-server"]
|