MCP-Bastion Documentation
OpenTelemetry (optional)
MCP-Bastion can export spans to an OTLP endpoint for tracing.
Setup
Set the OTLP endpoint:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
Install the optional OTEL dependencies:
pip install mcp-bastion-python[otel]
## or
pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-grpc
Behavior
- When
OTEL_EXPORTER_OTLP_ENDPOINTis set, every tool call is recorded as a span (mcp_bastion.tool_call) with attributes:mcp.tool,mcp.action,mcp.latency_ms, andmcp.errorwhen blocked. - The audit export callback (used when audit is enabled and metrics are wired) calls
record_tool_spanso no extra wiring is needed if you usebuild_middleware_from_config()ormake_audit_export_callback().
Metrics
Dashboard Prometheus endpoint (GET /metrics) is the primary way to scrape metrics. For OTLP metrics export you can run a collector that scrapes the dashboard or forwards from your existing pipeline.