Skip to main content

MCP server instrumentation for Cerberus API monitoring

Project description

cerberus-mcp

MCP (Model Context Protocol) server instrumentation for Cerberus API monitoring.

Drop-in replacement for FastMCP that captures tool, resource, and prompt call metrics and streams them to the Cerberus analytics pipeline.

Installation

pip install cerberus-mcp

Quick Start

Replace FastMCP with CerberusMCP — a single-line change:

from cerberus_mcp import CerberusMCP

mcp = CerberusMCP(
    "my-server",
    cerberus_config={
        "token": "your-api-key",
        "client_id": "your-client-id",
        "ws_url": "wss://your-cerberus-backend:8765",
    }
)

@mcp.tool()
def get_weather(location: str) -> str:
    """Get weather for a location."""
    return f"Sunny in {location}"

@mcp.resource("config://settings")
def get_settings() -> str:
    """Return server settings."""
    return '{"theme": "dark"}'

@mcp.prompt()
def summarize(text: str) -> str:
    """Summarize text."""
    return f"Please summarize: {text}"

All tool calls, resource reads, and prompt invocations are automatically captured with:

  • Execution timing (duration_ms)
  • Sanitized arguments (sensitive values redacted)
  • Error tracking
  • Result summaries
  • MCP client identity (name, version) and session correlation

Events are sent asynchronously via WebSocket to the Cerberus event_ingest backend using the same pipeline as cerberus-django.

Configuration

Key Required Description
token Yes API key for Cerberus authentication
client_id Yes Client identifier for your MCP server
ws_url Yes WebSocket URL of your Cerberus event_ingest server
server_name No Override server name in events (defaults to MCP server name)

Set CERBERUS_DEBUG=true to enable verbose logging.

How It Works

CerberusMCP subclasses FastMCP from the MCP Python SDK and wraps the tool(), resource(), and prompt() decorators. Each handler call is intercepted to capture timing, arguments, results, and errors. Events are queued into a thread-safe queue and sent via a background WebSocket connection — zero impact on your MCP server's response times.

Requirements

  • Python >= 3.10
  • mcp >= 1.0 (MCP Python SDK)
  • websockets >= 12.0
  • A running Cerberus backend (cerberus-int)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cerberus_mcp-0.1.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cerberus_mcp-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file cerberus_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: cerberus_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cerberus_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1ec1abc3472ee48732b37c48733ec2852b8e980949c3e8abe1c6ff12b2dbd888
MD5 5a0e8251c7d4f95d806f43ab420cf606
BLAKE2b-256 019dc7d9c6ddb015314920e87d22d070896c4acdf46579b9f48c759c95f4c6e3

See more details on using hashes here.

File details

Details for the file cerberus_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cerberus_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cerberus_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6655e2809940a24f211d0934a2263c13b2e86e12837a298a295ad024970267a0
MD5 342a334e5803e186b90bd9e445faaa7a
BLAKE2b-256 4856b4fb4f1d974851b3e7abf1341a61451586cf55d83134342f45b9bf231957

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page