Skip to main content
Glama
ry-ops

Cloudflare MCP Server

by ry-ops

purge_cache

Clear Cloudflare's cache for a zone to remove outdated content. Purge all cached files or target specific URLs, tags, and hosts to ensure visitors see updated website content.

Instructions

Purge Cloudflare's cache for a zone. Can purge everything or specific files/tags/hosts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zone_idYesThe zone ID
purge_everythingNoPurge all cached content (use cautiously!)
filesNoArray of URLs to purge
tagsNoArray of cache tags to purge
hostsNoArray of hosts to purge

Implementation Reference

  • The handler function _purge_cache that executes the tool logic. It builds the purge request body from arguments (purge_everything, files, tags, hosts) and sends a POST request to Cloudflare's /zones/{zone_id}/purge_cache endpoint using _make_request.
    async def _purge_cache(self, args: dict) -> Any:
        """Purge cache."""
        data = {}
    
        if args.get("purge_everything"):
            data["purge_everything"] = True
        else:
            if args.get("files"):
                data["files"] = args["files"]
            if args.get("tags"):
                data["tags"] = args["tags"]
            if args.get("hosts"):
                data["hosts"] = args["hosts"]
    
        return await self._make_request(
            f"/zones/{args['zone_id']}/purge_cache", method="POST", data=data
        )
  • Registration of the purge_cache tool in the list_tools() decorator callback, defining its name, description, and input schema.
    Tool(
        name="purge_cache",
        description="Purge Cloudflare's cache for a zone. Can purge everything or specific files/tags/hosts.",
        inputSchema={
            "type": "object",
            "properties": {
                "zone_id": {"type": "string", "description": "The zone ID"},
                "purge_everything": {
                    "type": "boolean",
                    "description": "Purge all cached content (use cautiously!)",
                },
                "files": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Array of URLs to purge",
                },
                "tags": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Array of cache tags to purge",
                },
                "hosts": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Array of hosts to purge",
                },
            },
            "required": ["zone_id"],
        },
    ),
  • Input schema definition for the purge_cache tool, specifying parameters like zone_id (required), purge_everything, files, tags, hosts.
    inputSchema={
        "type": "object",
        "properties": {
            "zone_id": {"type": "string", "description": "The zone ID"},
            "purge_everything": {
                "type": "boolean",
                "description": "Purge all cached content (use cautiously!)",
            },
            "files": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Array of URLs to purge",
            },
            "tags": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Array of cache tags to purge",
            },
            "hosts": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Array of hosts to purge",
            },
        },
        "required": ["zone_id"],
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ry-ops/cloudflare-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server