Initial commit: BunnyCDN MCP server with K8s deployment
- FastMCP server with 12 tools (pullzone, cache, statistics, shield) - Dockerfile with multi-stage build (python:3.11-slim + uv) - K8s manifests (Deployment + Service) - Gitea Actions CI/CD pipeline (build → push → deploy)
This commit is contained in:
35
bunnycdn_mcp/tools/cache.py
Normal file
35
bunnycdn_mcp/tools/cache.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""Cache purge tools."""
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from ..client import client
|
||||
from ..config import logger
|
||||
|
||||
|
||||
def register_cache_tools(mcp):
|
||||
|
||||
@mcp.tool()
|
||||
async def bunny_purge_zone(
|
||||
pullzone_id: Annotated[int, Field(description="Pull Zone ID to purge all cache for")],
|
||||
) -> str:
|
||||
"""Purge the entire cache for a Pull Zone."""
|
||||
try:
|
||||
await client.post(f"/pullzone/{pullzone_id}/purgeCache")
|
||||
return f"Cache purged for Pull Zone {pullzone_id}"
|
||||
except Exception as e:
|
||||
logger.error("bunny_purge_zone failed: %s", e)
|
||||
return f"Error: {e}"
|
||||
|
||||
@mcp.tool()
|
||||
async def bunny_purge_url(
|
||||
url: Annotated[str, Field(description="Full URL to purge from cache (e.g. https://cdn.example.com/path/to/file)")],
|
||||
) -> str:
|
||||
"""Purge a specific URL from the CDN cache."""
|
||||
try:
|
||||
await client.get("/purge", params={"url": url})
|
||||
return f"Cache purged for URL: {url}"
|
||||
except Exception as e:
|
||||
logger.error("bunny_purge_url failed: %s", e)
|
||||
return f"Error: {e}"
|
||||
Reference in New Issue
Block a user