CubeAPM MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CubeAPM MCP Server Show me error logs from payment-service in the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CubeAPM MCP Server
A Model Context Protocol (MCP) server for CubeAPM - enabling AI assistants like Claude to query your observability data including traces, metrics, and logs.
What is this?
This MCP server connects AI assistants (like Claude) to your CubeAPM instance, allowing you to:
Query logs using natural language that gets translated to LogsQL
Analyze metrics with PromQL-compatible queries
Search and inspect traces to debug distributed systems
Monitor your services through conversational interfaces
Related MCP server: Cube.js MCP Server
Installation
From NPM (Recommended)
npm install -g cubeapm-mcpFrom Source
git clone https://github.com/TechnicalRhino/cubeapm-mcp.git
cd cubeapm-mcp
npm install
npm run buildQuick Start
1. Configure Claude Code
Add to your Claude Code settings (~/.claude/settings.json):
{
"mcpServers": {
"cubeapm": {
"command": "npx",
"args": ["-y", "cubeapm-mcp"],
"env": {
"CUBEAPM_HOST": "your-cubeapm-server.com"
}
}
}
}2. Restart Claude Code
After updating the settings, restart Claude Code to load the MCP server.
3. Start Querying
You can now ask Claude questions like:
"Show me error logs from the payment-service in the last hour"
"What's the p99 latency for the checkout API?"
"Find traces where duration > 5s in production"
"Get the full trace for trace ID abc123def456"
Configuration
Environment Variable | Default | Description |
| - | Full URL to CubeAPM (e.g., |
|
| CubeAPM server hostname or IP (used if CUBEAPM_URL not set) |
|
| Port for querying APIs (traces, metrics, logs) |
|
| Port for ingestion APIs |
Example Configurations
Local Development:
{
"mcpServers": {
"cubeapm": {
"command": "npx",
"args": ["-y", "cubeapm-mcp"],
"env": {
"CUBEAPM_HOST": "localhost"
}
}
}
}Production (with full URL):
{
"mcpServers": {
"cubeapm": {
"command": "npx",
"args": ["-y", "cubeapm-mcp"],
"env": {
"CUBEAPM_URL": "https://cubeapm.internal.company.com"
}
}
}
}Production (with host/port):
{
"mcpServers": {
"cubeapm": {
"command": "npx",
"args": ["-y", "cubeapm-mcp"],
"env": {
"CUBEAPM_HOST": "cubeapm.internal.company.com",
"CUBEAPM_QUERY_PORT": "3140"
}
}
}
}Available Tools
Logs
Tool | Description |
| Query logs using LogsQL syntax with time range and limit |
Parameters:
query- LogsQL query string (e.g.,{service="api"} error)start- Start time (RFC3339 or Unix timestamp)end- End time (RFC3339 or Unix timestamp)limit- Maximum entries to return (default: 100)
Metrics
Tool | Description |
| Execute a PromQL query at a single point in time |
| Execute a PromQL query over a time range |
Instant Query Parameters:
query- PromQL expressiontime- Evaluation timestampstep- Optional time window in seconds
Range Query Parameters:
query- PromQL expressionstart/end- Time rangestep- Resolution in seconds
Traces
Tool | Description |
| Search traces by service, environment, or custom query |
| Fetch complete trace details by trace ID |
Search Parameters (Required):
query- Search query (default:*for wildcard)env- Environment filter (default:UNSET)service- Service name filter (required, case-sensitive)start/end- Time range (RFC3339 or Unix timestamp)
Search Parameters (Optional):
limit- Maximum results (default: 20)spanKind- Filter by span type:server,client,consumer,producersortBy- Sort by:duration(useful for finding slow traces)
Get Trace Parameters:
trace_id- Hex-encoded trace IDstart/end- Time range to search within
Ingestion
Tool | Description |
| Send metrics in Prometheus text exposition format |
Prompts
Pre-defined templates for common observability tasks:
Prompt | Description |
| Comprehensive service investigation - checks errors, latency, and traces |
| Get P50, P95, P99 latency percentiles for a service |
| Find slowest traces to identify performance bottlenecks |
Usage Example:
Use the investigate-service prompt for Kratos-ProdResources
Readable resources exposing CubeAPM data and configuration:
Resource URI | Description |
| Current CubeAPM connection configuration |
| Query patterns and naming conventions reference |
CubeAPM Query Patterns
Metrics (PromQL / MetricsQL)
CubeAPM uses specific naming conventions that differ from standard OpenTelemetry:
What | CubeAPM Convention |
Metric prefix |
|
Service label |
|
Common labels |
|
Histogram Queries (P50, P90, P95, P99)
CubeAPM uses VictoriaMetrics-style histograms with vmrange labels instead of Prometheus le buckets:
# ✅ Correct - Use histogram_quantiles() with vmrange
histogram_quantiles("phi", 0.95, sum by (vmrange, service) (
increase(cube_apm_latency_bucket{service="MyService", span_kind="server"}[5m])
))
# ❌ Wrong - Standard Prometheus syntax won't work
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_bucket[5m])))Note: Latency values are returned in seconds (0.05 = 50ms)
Logs (LogsQL)
Stream Selectors
Log labels vary by source. Use * query first to discover available labels:
Source | Common Labels |
Lambda functions |
|
Services |
|
# Discover all labels
*
# Lambda function logs
{faas.name="my-lambda-prod"}
# Regex match
{faas.name=~".*-prod"}
# Text filter with boolean operators
{faas.name=~".*"} AND "error" AND NOT "retry"Pipe Operators
Chain after any query with |:
Pipe | Syntax | Description |
|
| Copy field value |
|
| Remove fields from output |
|
| Extract via named capture groups |
|
| Join with subquery results |
|
| Keep only specified fields |
|
| Return at most N results |
|
| Arithmetic (+, -, *, /, %) |
|
| Rename a field |
|
| Substring replacement |
|
| Regex replacement |
|
| Sort results |
|
| Aggregate results |
|
| Extract fields from JSON body |
Stats Functions
Used with the | stats pipe:
Function | Description |
| Arithmetic mean |
| Total matching entries |
| Entries where field is empty |
| Distinct values |
| Maximum value |
| Median (50th percentile) |
| Minimum value |
| p-th quantile (e.g., |
| Sum of values |
Example Log Queries
# Count errors per Lambda function
{faas.name=~".*"} AND "error" | stats count() as errors by (faas.name)
# Top 10 slowest requests
{service_name="my-service"} | sort by (duration) desc | limit 10
# Extract and aggregate from JSON logs
{service_name="api"} | unpack_json | stats avg(response_time) as avg_rt by (endpoint)Traces
Trace queries use the same pipe syntax as logs: {stream_selector} | pipe1 | pipe2
Important notes:
query,env,serviceare REQUIRED parametersDuration is in milliseconds (not seconds like metrics)
p95is NOT a valid stats function — usequantile(0.95, duration)Service names are case-sensitive (e.g.,
"Kratos-Prod"not"kratos")
Example Trace Queries
# P95 latency for a service
{service="Kratos-Prod", span_kind="server"} | stats quantile(0.95, duration) as p95_ms
# Error count by endpoint
{service="Kratos-Prod", status_code="ERROR"} | stats count() as errors by (http_route)
# Slowest spans
{service="Kratos-Prod"} | sort by (duration) desc | limit 20Example Natural Language Queries
Logs
"Show me logs from webhook-lambda-prod"
"Find all logs containing 'timeout' in the last hour"
"Count errors per Lambda function in the last 24h"Metrics
"What's the P95 latency for Kratos-Prod service?"
"Show me error rate for all services"
"List all available services in CubeAPM"Traces
"Find the P95 latency for Kratos-Prod using trace stats"
"Show me traces with errors in the production environment"
"Get the full waterfall for trace ID abc123"Development
# Clone the repository
git clone https://github.com/TechnicalRhino/cubeapm-mcp.git
cd cubeapm-mcp
# Install dependencies
npm install
# Run in development mode (with hot reload)
npm run dev
# Build for production
npm run build
# Test the build
npm startHow It Works
┌─────────────────┐ MCP Protocol ┌─────────────────┐ HTTP API ┌─────────────────┐
│ Claude / AI │◄───────────────────►│ cubeapm-mcp │◄────────────────►│ CubeAPM │
│ Assistant │ (stdio transport) │ MCP Server │ (REST calls) │ Server │
└─────────────────┘ └─────────────────┘ └─────────────────┘The MCP server:
Receives tool calls from the AI assistant via stdio
Translates them to CubeAPM HTTP API requests
Returns formatted results back to the assistant
Requirements
Node.js 18+
CubeAPM instance (self-hosted or cloud)
Claude Code or any MCP-compatible client
Related Links
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Available Tools
6 toolsget_traceA
Fetch a complete trace by its ID from CubeAPM. Returns all spans in the trace with full details.
Inputs: end (required), start (required), trace_id (required).
ingest_metrics_prometheusC
Send metrics to CubeAPM in Prometheus text exposition format.
Inputs: metrics (required).
query_logsA
Query logs from CubeAPM using LogsQL syntax (VictoriaLogs compatible). Returns log entries matching the query.
IMPORTANT - Log Label Discovery:
Labels vary by source! Use "*" query first to discover available labels
Lambda logs use: faas.name, faas.arn, env, aws.lambda_request_id
Service logs may use: service_name, level, host
NOT all sources have "service_name" - check the _stream field in results
LogsQL Query Syntax:
Wildcard (discover labels): *
Stream filters: {faas.name="my-lambda-prod"}
Text search: {faas.name="webhook-lambda-prod"} AND "error"
Regex match: {faas.name=~".*-prod"}
Negation: {faas.name!="unwanted-service"}
Combine filters: {env="UNSET", faas.name=~".-lambda."}
PIPE OPERATORS — chain after query with "|": | copy src_field AS dst_field — copy field value | drop field1, field2 — remove fields from output | extract_regexp "(?Pregex)" — extract fields via named capture groups | join by (field) (...subquery...) — join with subquery results | keep field1, field2 — keep only specified fields | limit N — return at most N results | math result = field1 + field2 — compute derived fields (+, -, *, /, %) | rename src AS dst — rename a field | replace (field, "old", "new") — replace substring in field | replace_regexp (field, "re", "replacement") — regex replacement | sort by (field) [asc|desc] — sort results | stats as alias [by (group_fields)] — aggregate results | unpack_json — extract fields from JSON log body
STATS FUNCTIONS (use with | stats pipe): avg(field) — arithmetic mean count() — total number of matching entries count_empty(field) — count entries where field is empty count_uniq(field) — count distinct values max(field) — maximum value median(field) — median (50th percentile) min(field) — minimum value quantile(p, field) — p-th quantile (e.g., quantile(0.95, duration)) sum(field) — sum of values
Example queries:
All logs (discover structure): *
Lambda logs: {faas.name="webhook-lambda-prod"}
Search errors: {faas.name=~".*"} AND "error"
By environment: {env="production"}
Count errors per function: {faas.name=~".*"} AND "error" | stats count() as error_count by (faas.name)
Top 10 slowest: {service_name="my-service"} | sort by (duration) desc | limit 10
Inputs: end (required), query (required), start (required), limit.
query_metrics_instantA
Execute an instant query against CubeAPM metrics at a single point in time. Uses PromQL-compatible syntax (VictoriaMetrics flavor).
IMPORTANT - CubeAPM Metric Naming Conventions:
Metrics use "cube_apm_" prefix (e.g., cube_apm_calls_total, cube_apm_latency_bucket)
Service label is "service" (NOT "server" or "service_name")
Common labels: env, service, span_kind (server|client|consumer|producer), status_code, http_code
HISTOGRAM QUERIES (P50, P90, P95, P99):
CubeAPM uses VictoriaMetrics-style histograms with "vmrange" label (NOT Prometheus "le" buckets)
Use histogram_quantiles() function instead of histogram_quantile()
Syntax: histogram_quantiles("phi", 0.95, sum by (vmrange) (increase(cube_apm_latency_bucket{...}[5m])))
Latency values are returned in SECONDS (0.05 = 50ms)
Example queries:
P95 latency: histogram_quantiles("phi", 0.95, sum by (vmrange, service) (increase(cube_apm_latency_bucket{service="MyService", span_kind="server"}[5m])))
Error rate: sum by (service) (increase(cube_apm_calls_total{status_code="ERROR"}[1h])) / sum by (service) (increase(cube_apm_calls_total[1h])) * 100
List services: count by (service) (cube_apm_calls_total{env="UNSET"})
Request count: sum by (service) (increase(cube_apm_calls_total{span_kind=~"server|consumer"}[1h]))
Inputs: time (required), query (required), step.
query_metrics_rangeA
Execute a range query against CubeAPM metrics over a time range. Returns time series data. Uses PromQL-compatible syntax (VictoriaMetrics flavor).
IMPORTANT - CubeAPM Metric Naming Conventions:
Metrics use "cube_apm_" prefix (e.g., cube_apm_calls_total, cube_apm_latency_bucket)
Service label is "service" (NOT "server" or "service_name")
Common labels: env, service, span_kind (server|client|consumer|producer), status_code, http_code
HISTOGRAM QUERIES (P50, P90, P95, P99):
CubeAPM uses VictoriaMetrics-style histograms with "vmrange" label (NOT Prometheus "le" buckets)
Use histogram_quantiles() function instead of histogram_quantile()
Syntax: histogram_quantiles("phi", 0.95, sum by (vmrange, service) (increase(cube_apm_latency_bucket{...}[5m])))
Latency values are returned in SECONDS (0.05 = 50ms)
Example range query for P95 over time: histogram_quantiles("phi", 0.95, sum by (vmrange, service) (increase(cube_apm_latency_bucket{service="MyService", span_kind="server"}[5m])))
Inputs: end (required), step (required), query (required), start (required).
search_tracesA
Search for traces in CubeAPM matching the specified criteria. Returns trace snippets with key spans.
IMPORTANT - Required Parameters:
query, env, service, start, end are ALL REQUIRED by CubeAPM API
Use query="*" for wildcard search
Use env="UNSET" if environment is not configured
Service names are case-sensitive (e.g., "Kratos-Prod" not "kratos")
TRACE QUERY SYNTAX: The query parameter supports pipe syntax similar to LogsQL: {stream_selector} | pipe1 | pipe2
Stream selectors filter spans: {service="Kratos-Prod"} {service="Kratos-Prod", span_kind="server"} {http_code=~"5.."}
PIPE OPERATORS — same as LogsQL pipes: | copy, | drop, | extract_regexp, | join, | keep, | limit, | math, | rename, | replace, | replace_regexp, | sort, | stats as alias [by (group_fields)], | unpack_json
STATS FUNCTIONS (for aggregate trace analysis): avg(field) — arithmetic mean count() — total matching spans count_uniq(field) — distinct values max(field) — maximum value median(field) — median value min(field) — minimum value quantile(p, field) — p-th quantile (e.g., quantile(0.95, duration)) sum(field) — sum of values
IMPORTANT: Duration in traces is in MILLISECONDS. IMPORTANT: "p95" is NOT a valid function — use quantile(0.95, duration).
Example queries: Wildcard: query="*" P95 latency: query='{service="Kratos-Prod", span_kind="server"} | stats quantile(0.95, duration) as p95_latency' Error count by endpoint: query='{service="Kratos-Prod", status_code="ERROR"} | stats count() as errors by (http_route)' Slow spans: query='{service="Kratos-Prod"} | sort by (duration) desc | limit 20'
Optional filters (applied in addition to query):
spanKind: server, client, consumer, producer
sortBy: duration (to find slow traces)
To discover available service names, first query metrics: count by (service) (cube_apm_calls_total{env="UNSET"})
Inputs: end (required), start (required), service (required), env, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct telemetry type or operation: logs, trace search, trace fetch, instant metrics, range metrics, and metric ingestion. The only mild overlap is between query_metrics_instant and query_metrics_range, but the temporal distinction is standard and clearly described. search_traces versus get_trace is also well separated by search-vs-fetch semantics.
All names use snake_case and are verb-first, which is highly consistent. The minor deviation is using both 'query_' and 'search_' verbs for similar read operations, plus multi-word qualifiers like '_instant', '_range', and '_prometheus', but the pattern remains easy to predict and read.
Six tools is well-scoped for an APM server covering logs, traces, metrics, and metric ingestion. Each tool has a clear purpose and the surface does not feel bloated or excessively thin.
The core observability workflows are covered: querying logs, searching and fetching traces, querying metrics, and ingesting metrics. Minor gaps include no explicit service/environment discovery tool or log/trace ingestion endpoint, but agents can work around these using wildcard queries and metric label counts as described.
Maintenance
Related MCP Connectors
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
Manage uptime monitors and incidents and search logs, metrics and traces from an AI assistant.
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI agents to query Prometheus metrics and Loki logs for intelligent alert investigation and troubleshooting. Provides service discovery, metric querying, log searching, and correlation tools to help identify root causes of issues.9-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query and analyze data from Cube.js analytics platforms, allowing natural language access to cubes, measures, dimensions, and complex analytics queries.9MIT

SigNoz MCP Serverofficial
AlicenseNot gradedqualityBmaintenanceEnables AI assistants and LLMs to query SigNoz observability data (metrics, traces, logs, alerts, dashboards) using natural language.132Apache 2.0- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact directly with Cube's API, allowing them to list cubes/views and metadata, run queries, and retrieve generated SQL.MIT