Add Cloudflare and Loki MCP server integrations
Features: - Cloudflare Code Mode MCP: Exposes entire Cloudflare API (2,500+ endpoints) via remote MCP server at https://mcp.cloudflare.com/mcp * Two tools: search() to query OpenAPI spec, execute() to run JS code * Uses npx mcp-remote as stdio bridge * Auth via CLOUDFLARE_API_TOKEN as Bearer header - Loki MCP Server: Log querying and analysis via Loki HTTP API * Query logs with LogQL syntax * Real-time log streaming support * Label introspection and metrics queries * Configurable via LOKI_URL environment variable Technical changes: - Created mcp_servers/cloudflare/ with config and connection logic - Created mcp_servers/loki/ with HTTP client and MCP tool wrappers - Added promtail-config-optimized.yaml for syslog ingestion config - Updated .env.example with Cloudflare and Loki configuration templates Both integrations: - Use environment variables for configuration (no hardcoded credentials) - Include feature flags (CLOUDFLARE_MCP_ENABLED, LOKI_MCP_ENABLED) - Follow existing MCP server patterns for consistency Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
"""
|
||||
Loki MCP Server - Configuration
|
||||
|
||||
This is where we store settings for connecting to your Loki instance.
|
||||
We use environment variables with sensible defaults so you can override
|
||||
them without editing code.
|
||||
Settings for connecting to your Loki instance via its HTTP API.
|
||||
Uses environment variables with sensible defaults.
|
||||
|
||||
Environment variables:
|
||||
LOKI_URL - Base URL for your Loki instance
|
||||
LOKI_TIMEOUT - Request timeout in seconds (default: 30)
|
||||
LOKI_DEFAULT_LIMIT - Default number of log lines to return (default: 100)
|
||||
LOKI_URL - Base URL for your Loki instance
|
||||
LOKI_TIMEOUT - Request timeout in seconds (default: 30)
|
||||
LOKI_DEFAULT_LIMIT - Default number of log lines to return (default: 100)
|
||||
LOKI_MCP_ENABLED - Enable/disable integration (default: true)
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -18,7 +18,7 @@ import os
|
||||
# Connection settings
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# The URL where Loki is reachable. This goes through your Caddy reverse proxy.
|
||||
# The URL where Loki is reachable (through Caddy reverse proxy).
|
||||
LOKI_URL = os.getenv("LOKI_URL", "https://loki.apophisnetworking.net")
|
||||
|
||||
# How long (seconds) to wait for Loki to respond before giving up.
|
||||
@@ -29,10 +29,16 @@ LOKI_TIMEOUT = int(os.getenv("LOKI_TIMEOUT", "30"))
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# How many log lines to return if the caller doesn't specify.
|
||||
# 100 is a good balance — enough to see what's happening, not so many
|
||||
# that it floods the response.
|
||||
DEFAULT_LIMIT = int(os.getenv("LOKI_DEFAULT_LIMIT", "100"))
|
||||
|
||||
# Default time range for queries if none specified (in hours).
|
||||
# "1" means "show me the last hour of logs."
|
||||
DEFAULT_RANGE_HOURS = 1
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Feature flag
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Set to "false" to disable the integration without removing config
|
||||
LOKI_MCP_ENABLED = os.getenv(
|
||||
"LOKI_MCP_ENABLED", "true"
|
||||
).lower() in ("true", "1", "yes")
|
||||
|
||||
Reference in New Issue
Block a user