The Quick Answer
Configure MCPcat to send telemetry to multiple observability platforms simultaneously using the exporters configuration:
# Install MCPcat SDK$pip install mcpcat
import mcpcat
import os
# Configure multi-platform telemetry
mcpcat.track(server, "proj_YOUR_PROJECT_ID", mcpcat.MCPCatOptions(
exporters={
"otlp": {
"type": "otlp",
"endpoint": "http://localhost:4318/v1/traces"
},
"sentry": {
"type": "sentry",
"dsn": os.getenv("SENTRY_DSN")
},
"datadog": {
"type": "datadog",
"api_key": os.getenv("DD_API_KEY"),
"site": "datadoghq.com"
}
}
))
This enables MCPcat to simultaneously export telemetry to OpenTelemetry-compatible backends, Sentry for error tracking, and Datadog for APM, providing comprehensive observability across all platforms.
Prerequisites
- MCPcat SDK installed (Python 3.8+ or Node.js 16+)
- MCPcat project ID from dashboard (optional if using exporters only)
- Access to target observability platforms (Sentry, Datadog, or OTLP backend)
- MCP server implementation ready for instrumentation
Installation
Install the MCPcat SDK for your language:
# Python installation$pip install mcpcat# Node.js installation$npm install mcpcat
The MCPcat SDK includes all necessary dependencies for exporting to OpenTelemetry, Sentry, and Datadog platforms. No additional packages are required for telemetry export functionality.
Configuration
MCPcat's multi-platform telemetry uses an exporters
configuration object passed directly to the track()
function. Each exporter is configured independently while sharing the same underlying telemetry data stream from your MCP server.
Basic Multi-Platform Configuration
Configure multiple exporters by providing them in the exporters
object. Each exporter requires platform-specific configuration parameters:
import mcpcat
import os
# Python configuration with multiple exporters
mcpcat.track(
server,
"proj_YOUR_PROJECT_ID", # Optional when using exporters
mcpcat.MCPCatOptions(
exporters={
# OpenTelemetry configuration
"otlp": {
"type": "otlp",
"endpoint": "http://localhost:4318/v1/traces",
"protocol": "http/protobuf",
"headers": {
"api-key": os.getenv("OTLP_API_KEY")
}
},
# Sentry configuration
"sentry": {
"type": "sentry",
"dsn": os.getenv("SENTRY_DSN"),
"environment": "production",
"release": "1.0.0",
"enable_tracing": True
},
# Datadog configuration
"datadog": {
"type": "datadog",
"api_key": os.getenv("DD_API_KEY"),
"site": "datadoghq.com",
"service": "my-mcp-server",
"env": "production"
}
}
)
)
For TypeScript/JavaScript, the configuration follows the same pattern with appropriate syntax:
import * as mcpcat from "mcpcat";
// TypeScript configuration with multiple exporters
mcpcat.track(
server,
"proj_YOUR_PROJECT_ID", // Optional when using exporters
{
exporters: {
// OpenTelemetry configuration
otlp: {
type: "otlp",
endpoint: "http://localhost:4318/v1/traces",
protocol: "http/protobuf",
headers: {
"api-key": process.env.OTLP_API_KEY
}
},
// Sentry configuration
sentry: {
type: "sentry",
dsn: process.env.SENTRY_DSN,
environment: "production",
release: "1.0.0",
enableTracing: true
},
// Datadog configuration
datadog: {
type: "datadog",
apiKey: process.env.DD_API_KEY,
site: "datadoghq.com",
service: "my-mcp-server",
env: "production"
}
}
}
);
Using Without an MCPcat Account
You can use MCPcat purely as a telemetry forwarding library without creating an MCPcat account. Simply pass null
(Python: None
) as the project ID:
# Forward telemetry without MCPcat account
mcpcat.track(server, None, mcpcat.MCPCatOptions(
exporters={
"otlp": {
"type": "otlp",
"endpoint": "http://localhost:4318/v1/traces"
}
}
))
This configuration sends all telemetry directly to your specified platforms without routing through MCPcat's servers, making it suitable for air-gapped environments or organizations with strict data residency requirements.
Usage
With multi-platform telemetry configured, MCPcat automatically distributes telemetry data to all configured exporters. The SDK handles batching, retries, and error recovery for each platform independently, ensuring that issues with one exporter don't affect others.
OpenTelemetry (OTLP) Configuration
OpenTelemetry provides the most flexible integration option, supporting any OTLP-compatible backend including Jaeger, Tempo, New Relic, and AWS X-Ray:
mcpcat.track(server, None, mcpcat.MCPCatOptions(
exporters={
"otlp": {
"type": "otlp",
"endpoint": "http://localhost:4318/v1/traces",
"protocol": "http/protobuf", # or "grpc"
"headers": {
"api-key": "your-api-key"
},
"compression": "gzip" # or "none"
}
}
))
MCPcat maps your MCP events to OpenTelemetry spans with proper trace context. Each session becomes a trace, with individual MCP events as spans. The SDK preserves all MCP-specific attributes like event type, resource name, user intent, and actor information as span attributes prefixed with mcp.
.
Datadog Configuration
Datadog integration sends events as both logs and metrics for comprehensive monitoring:
mcpcat.track(server, None, mcpcat.MCPCatOptions(
exporters={
"datadog": {
"type": "datadog",
"api_key": os.getenv("DD_API_KEY"), # Required
"site": "datadoghq.com", # or datadoghq.eu for EU
"service": "my-mcp-server", # Required
"env": "production" # Optional, defaults to "production"
}
}
))
Events appear in Datadog with proper tagging for filtering and grouping. The integration creates logs with the message format "{event_type} - {resource_name}"
and sends metrics including mcp.events.count
, mcp.event.duration
, and mcp.errors.count
. All MCP event data is preserved in the mcp
object within each log entry.
Sentry Configuration
Sentry integration provides error tracking and optional performance monitoring:
mcpcat.track(server, None, mcpcat.MCPCatOptions(
exporters={
"sentry": {
"type": "sentry",
"dsn": "https://key@o123456.ingest.sentry.io/789", # Required
"environment": "production", # Optional
"release": "1.0.0", # Optional
"enable_tracing": True # Enables performance monitoring
}
}
))
When enable_tracing
is set to True
, Sentry receives both log events and transaction events for performance analysis. Error events automatically appear in Sentry's Issues tab with full context including session IDs, user identification (if configured), and MCP-specific metadata.
Multiple Platforms Example
A typical production configuration routes different telemetry types to specialized platforms based on their strengths:
import mcpcat
import os
# Production multi-platform setup
mcpcat.track(
server,
"proj_YOUR_PROJECT_ID", # MCPcat for session replay
mcpcat.MCPCatOptions(
exporters={
# Traces to Jaeger for distributed tracing
"otlp": {
"type": "otlp",
"endpoint": os.getenv("JAEGER_ENDPOINT", "http://localhost:4318/v1/traces")
},
# Errors to Sentry for issue tracking
"sentry": {
"type": "sentry",
"dsn": os.getenv("SENTRY_DSN"),
"environment": os.getenv("ENVIRONMENT", "production")
},
# Metrics to Datadog for monitoring
"datadog": {
"type": "datadog",
"api_key": os.getenv("DD_API_KEY"),
"site": os.getenv("DD_SITE", "datadoghq.com"),
"service": "mcp-server"
}
}
)
)
This configuration leverages MCPcat's session replay capabilities while also sending telemetry to specialized platforms. The combination provides comprehensive observability: MCPcat for understanding user interactions, Jaeger for trace visualization, Sentry for error management, and Datadog for metrics and alerting.
Privacy and Security
MCPcat provides client-side redaction capabilities to protect sensitive information before it reaches any telemetry platform:
def redact_sensitive_data(text):
"""Redact sensitive information before telemetry export"""
if "@" in text: # Email addresses
return "[REDACTED-EMAIL]"
if "secret" in text.lower() or "key" in text.lower():
return "[REDACTED-SECRET]"
# Add more redaction patterns as needed
return text
mcpcat.track(server, "proj_YOUR_PROJECT_ID", mcpcat.MCPCatOptions(
redact_sensitive_information=redact_sensitive_data,
exporters={
# Your exporters configuration
}
))
The redaction function is applied recursively to all string values in event data before any telemetry is exported. This ensures sensitive information never leaves your environment, regardless of which observability platforms you're using.
Disabling Telemetry
Implement user-controllable telemetry by checking environment variables before initialization:
import os
import mcpcat
# Check for telemetry opt-out
telemetry_enabled = os.getenv("DISABLE_TELEMETRY") != "true"
if telemetry_enabled:
mcpcat.track(server, "proj_YOUR_PROJECT_ID", mcpcat.MCPCatOptions(
exporters={
# Your exporters configuration
}
))
This pattern gives users control over telemetry collection through environment variables, respecting privacy preferences while maintaining observability for those who opt in.
Common Issues
Error: OTLP export failing with connection refused
OpenTelemetry export failures typically occur when the collector endpoint is misconfigured or unreachable. The OTLP exporter attempts to establish connections to the configured endpoint, and connection refused errors indicate the collector isn't listening on the expected port.
# Verify collector is running before initialization
import requests
try:
response = requests.get("http://localhost:4318/v1/traces")
print("OTLP collector is accessible")
except requests.exceptions.ConnectionError:
print("Warning: OTLP collector not reachable")
# Continue without OTLP or use a different endpoint
To prevent this issue, verify your OTLP collector is running before starting your MCP server. Consider implementing a health check during initialization to validate connectivity and fall back gracefully if the collector is unavailable.
Error: Datadog API key authentication failure
Datadog requires a valid API key for authentication. Authentication failures prevent telemetry from being delivered to your Datadog account.
# Validate Datadog configuration before initialization
dd_api_key = os.getenv("DD_API_KEY")
if not dd_api_key:
print("Warning: DD_API_KEY not set, Datadog export disabled")
exporters = {} # Skip Datadog configuration
else:
exporters = {
"datadog": {
"type": "datadog",
"api_key": dd_api_key,
"site": "datadoghq.com"
}
}
Always validate that required environment variables are set before configuring exporters. This prevents runtime errors and provides clear feedback about configuration issues.
Error: Sentry events not appearing in dashboard
Sentry events may fail to appear due to incorrect DSN format, network issues, or project configuration. The DSN must match the format https://key@org.ingest.sentry.io/project
.
# Validate Sentry DSN format
import re
dsn = os.getenv("SENTRY_DSN", "")
dsn_pattern = r"https://[\w]+@[\w.]+\.ingest\.sentry\.io/\d+"
if not re.match(dsn_pattern, dsn):
print(f"Warning: Invalid Sentry DSN format: {dsn}")
# Skip Sentry configuration or use a default
Ensure your Sentry project is configured to accept events from your environment and that rate limits haven't been exceeded. Check the Sentry project settings for any filters that might be dropping events.
Examples
Production Setup with Error Handling
This example demonstrates a production configuration with proper error handling and fallback options:
import os
import mcpcat
from mcp.server import Server
def setup_telemetry(server):
"""Configure multi-platform telemetry with error handling"""
# Build exporters configuration based on available credentials
exporters = {}
# Configure OTLP if endpoint is available
otlp_endpoint = os.getenv("OTLP_ENDPOINT")
if otlp_endpoint:
exporters["otlp"] = {
"type": "otlp",
"endpoint": otlp_endpoint,
"headers": {"Authorization": f"Bearer {os.getenv('OTLP_TOKEN', '')}"}
}
# Configure Sentry if DSN is available
sentry_dsn = os.getenv("SENTRY_DSN")
if sentry_dsn:
exporters["sentry"] = {
"type": "sentry",
"dsn": sentry_dsn,
"environment": os.getenv("ENVIRONMENT", "production"),
"enable_tracing": os.getenv("SENTRY_TRACING", "false").lower() == "true"
}
# Configure Datadog if API key is available
dd_api_key = os.getenv("DD_API_KEY")
if dd_api_key:
exporters["datadog"] = {
"type": "datadog",
"api_key": dd_api_key,
"site": os.getenv("DD_SITE", "datadoghq.com"),
"service": "mcp-server",
"env": os.getenv("ENVIRONMENT", "production")
}
# Get MCPcat project ID
project_id = os.getenv("MCPCAT_PROJECT_ID")
# Only initialize if we have either a project ID or exporters
if project_id or exporters:
options = {}
if exporters:
options = mcpcat.MCPCatOptions(exporters=exporters)
try:
mcpcat.track(server, project_id, options if exporters else None)
print(f"Telemetry initialized: MCPcat={'yes' if project_id else 'no'}, "
f"Exporters={list(exporters.keys()) if exporters else 'none'}")
except Exception as e:
print(f"Warning: Telemetry initialization failed: {e}")
# Server continues without telemetry
else:
print("No telemetry configured (set MCPCAT_PROJECT_ID or exporter credentials)")
# Initialize MCP server
server = Server("production-mcp")
# ... configure server tools ...
# Setup telemetry with error handling
setup_telemetry(server)
This production setup gracefully handles missing configuration, validates credentials, and provides clear feedback about which telemetry platforms are active.
Development Setup with Local Collectors
For development environments, configure MCPcat to send telemetry to local collectors:
import * as mcpcat from "mcpcat";
// Development configuration with local collectors
const isDevelopment = process.env.NODE_ENV === "development";
if (isDevelopment) {
mcpcat.track(server, null, {
exporters: {
// Local Jaeger for trace visualization
otlp: {
type: "otlp",
endpoint: "http://localhost:4318/v1/traces",
protocol: "http/protobuf"
}
}
});
console.log("Development telemetry enabled: http://localhost:16686");
} else {
// Production configuration
mcpcat.track(server, process.env.MCPCAT_PROJECT_ID, {
exporters: {
sentry: {
type: "sentry",
dsn: process.env.SENTRY_DSN,
environment: "production"
}
}
});
}
This configuration automatically switches between local development telemetry and production monitoring based on the environment, simplifying the development workflow while maintaining production observability.
Related Guides
Monitor MCP Server Performance with OpenTelemetry
Connect MCP servers to any OpenTelemetry-compatible platform for distributed tracing and performance monitoring.
Send MCP Server Errors to Sentry for Real-Time Alerting
Forward MCP server errors to Sentry using MCPcat telemetry. Track errors, performance metrics, and debug production issues in real-time.
Stream MCP Server Logs to Datadog for Observability
Forward MCP server logs and metrics to Datadog using MCPcat's native integration for complete observability.