Kubesense

MCP Server

The KubeSense MCP (Model Context Protocol) Server enables AI assistants like Claude, ChatGPT, and other MCP-compatible clients to query and analyze your Kubernetes telemetry and infrastructure — logs, traces, metrics, workloads, issues, and alerts — using natural language.

Overview

The MCP server exposes a set of read-only tools over the MCP protocol that let AI assistants discover available fields, search raw data, run aggregated analyses, inspect the cluster inventory, and review issues and alerts across your entire observability stack. It is available over HTTP at /mcp on your KubeSense host.

Key capabilities:

  • Search and filter logs and traces with a SQL-style WHERE clause
  • Run aggregated analyses with grouping, percentiles, and time-series breakdowns
  • Execute PromQL queries against your metrics
  • Combine multiple datasources (logs, traces, metrics) in a single query with formula support
  • Browse the live system inventory — clusters, nodes, pods, and workloads with health and golden-signal summaries
  • Review platform-detected application issues, recent deploys/scaling changes, and infrastructure failures
  • Inspect firing alerts, alert rules, and alert history
  • Discover available fields, metrics, and labels dynamically

Authentication

Connect to the MCP server with a KubeSense API key, passed in the x-api-key header:

x-api-key: <your-kubesense-api-key>

Each request is scoped to the permissions of the API key. A tool will return a permission error if the key does not have access to the corresponding data (logs, traces, infrastructure, workloads, or alerts).

Generating an API Key

To connect an AI client to the MCP server, you need a KubeSense API key. Navigate to Settings > API Key Management and click Generate API Key.

API Key Management

Copy the generated key and use it as the x-api-key header value when configuring your AI client.

Available Tools

Tools are grouped by intent. All tools are read-only.

Discovery Tools

Call these first to understand what data is available before querying.

get-trace-or-log-fields

Discovers valid fields for filtering logs or traces in a time window — including dynamic attributes — along with each field's type, allowed operators, and a copy-pasteable example filter. Always call this before writing a WHERE clause, using the same time window you plan to query. Field names in your filters must be the catalog labels this tool returns (raw storage column names are rejected).

Parameters:

ParameterTypeDescription
signal"logs" | "traces"Required. The telemetry surface to describe
from_timestringRequired. Window start (RFC3339, e.g. 2026-05-01T00:00:00Z)
to_timestringRequired. Window end (RFC3339)
clustersarray (optional)Restrict attribute discovery to specific clusters
searchstring (optional)Case-insensitive substring filter on field names (e.g. http)
limitint (optional)Cap the number of returned fields (0 = no cap)

get-available-metrics

Searches for available metric names for PromQL queries. Keywords are AND-matched as case-insensitive substrings.

Parameters:

ParameterTypeDescription
search_keywordsarray (optional)Substring keywords to AND-filter metric names
from_timestring (optional)Window start (RFC3339). Defaults to now-1h
to_timestring (optional)Window end (RFC3339). Defaults to now
limitint (optional)Cap the returned metric count (0 = no cap)

get-metric-labels

Fetches available label names for a specific metric, useful for building PromQL queries.

Parameters:

ParameterTypeDescription
namestringRequired. The metric to get labels for
from_timestring (optional)Window start (RFC3339). Defaults to now-1h
to_timestring (optional)Window end (RFC3339). Defaults to now

Search Tools

Search tools return raw records (a small page of rows) and accept a SQL-style WHERE clause filter.

search-logs

Browse raw log records with filtering and field selection. Queries stored logs only.

search-traces

Browse raw trace/span records with filtering and field selection. Queries stored traces only.

Parameters (both tools):

ParameterTypeDescription
from_timestringStart time (RFC3339)
to_timestringEnd time (RFC3339)
wherestring (optional)SQL-style WHERE clause. Empty = match everything in the window
clustersarray (optional)Restrict to specific clusters
required_fieldsarray (optional)Fields to include in results
page_sizeint (optional)Number of rows to return

Analysis Tools

Analysis tools run aggregated queries and return summarized results. They support both range (time-series) and instant (single point-in-time) query types.

analyze-logs

Run aggregated analysis over logs — count, avg, sum, min, max, percentiles — with optional group-by.

analyze-traces

Run aggregated analysis over traces, useful for latency statistics (p95/p99), error rates, and status-code breakdowns.

Parameters (both tools):

ParameterTypeDescription
from_timestringStart time (RFC3339)
to_timestringEnd time (RFC3339)
query_type"range" | "instant"Type of query
wherestring (optional)SQL-style WHERE clause
value_operationstringAggregation function (e.g. row_count, avg, sum, min, max, p95, p99)
fieldsarray (optional)Fields to aggregate over, e.g. [{field: "duration"}]
group_by_fieldsarray (optional)Fields to group results by, e.g. [{field: "service"}]
sort_direction"ASC" | "DESC" (optional)Sort direction (defaults to ASC)
limitint (optional)Top-N series cap for range queries (server default 20)

analyze-metrics

Execute a PromQL query against your metrics with summary statistics.

Parameters:

ParameterTypeDescription
from_timestringStart time (RFC3339)
to_timestringEnd time (RFC3339)
query_type"range" | "instant"Type of query
promqlstringPromQL expression

analyze-telemetry

The most powerful analysis tool — combines multiple datasources (logs, traces, metrics) in a single request with formula composition.

Parameters:

ParameterTypeDescription
from_timestringStart time (RFC3339)
to_timestringEnd time (RFC3339)
query_type"range" | "instant"Type of query
queriesobjectMap of query labels (A, B, C...) to datasource queries

Each query in the queries map is a logs, traces, metrics, or formula query. Formulas reference other queries by label, e.g., (A/B)*100.


System Inventory Tools

Browse the live cluster inventory — what exists, its health, and its resource pressure.

ToolPurposeKey parameters
list-clustersList the Kubernetes clusters this deployment monitors(none)
list-nodesList nodes with health and resource pressureclusters, sort_by, sort_direction, page, page_size, time window
get-node-detailFull detail for one node — addresses, conditions, taints, capacity/usage, versionsname (required), clusters
list-podsList pods with phase, restart counts, and usage — the primary tool for crash-loop / OOM / pending-pod triageclusters, namespace, status, sort_by, page, page_size, time window
get-pod-detailFull detail for one pod — container statuses, restart reason, exit code, conditions, QoS, IPs, requests/limitsname, namespace, cluster (all required)
list-workloadsList workloads (Deployments, StatefulSets, DaemonSets, …) with health and golden-signal summariesclusters, namespace, kind, sort_by (rps, p95, errors, error_rate, restarts), time window
get-workload-detailDetail for one workload — replicas, restarts, 4xx/5xx counts, RPS, protocolsworkload, namespace (required), cluster, time window

Issues & Changes Tools

Surface problems and recent changes for incident triage.

ToolPurposeKey parameters
list-issuesProblems KubeSense has already detected — errors, latency, connectivity issues between workloadsclusters, page, page_size, limit, time window
get-recent-changesRecent deploys and scaling affecting a workload — image updates and replica changes (from Kubernetes events)namespace, workload, cluster, kind (image_update | scaling), time window, limit
get-infra-issuesInfrastructure failures for a workload — crashes (with exit code), OOM kills, restart backoffs, probe failures, scheduling/mount failures, image-pull errors, node problems (from Kubernetes events)namespace, workload, cluster, reason (e.g. OOMKilling, BackOff, ImagePullBackOff), time window, limit

Alert Tools

Inspect firing alerts and alert rule definitions.

ToolPurposeKey parameters
list-alertsCurrently-firing alerts from your Prometheus Alertmanager integration (when enabled)state, include_silences
list-active-alertsCurrently-firing KubeSense alerts across all rulesfingerprint, acknowledged, assignee, include_resolved, time window, limit, offset
list-alert-rulesBrowse alert rule definitions (the parent rules)enabled, state (firing | normal), severity, query_type, search, limit, offset
get-alert-detailsFull definition and current firing state of a rulealert_rule_id (required), fingerprint
get-alert-historyRecent firing/resolved event history of a rulealert_rule_id (required), fingerprint, limit

Filter Syntax

The log and trace tools (search-logs, search-traces, analyze-logs, analyze-traces) accept a SQL-style WHERE clause in their where argument:

namespace = default AND type = ERROR
protocol = HTTP OR status = error
instance IN ("service-a", "service-b")
body ILIKE "%timeout%"

Supported operators: =, !=, <, >, <=, >=, LIKE, ILIKE, SUBSTR_ILIKE, IN — combined with AND, OR, NOT and parentheses.

Field names: Use the catalog labels returned by get-trace-or-log-fields verbatim. Raw storage column names (e.g. level, pod_name, return_code, app_service) are rejected in favor of their catalog labels (e.g. type, instance, status_code, service). For trace app identity, prefer service (the cross-platform identifier) over workload (K8s-specific).

Values: Strings without special characters can be bare (type = ERROR); strings with spaces or punctuation use double quotes (body ILIKE "%timeout%"). Enum values are case-sensitive — check the example snippet returned by discovery for the exact casing.

Custom attributes: Prefix dynamic attribute keys with @@http.method = GET, @db.system = postgres. Trace attributes use the same syntax.

Connecting AI Clients

Claude Desktop

Add the following to your Claude Desktop MCP configuration:

{
  "mcpServers": {
    "kubesense": {
      "url": "https://<kubesense-host>/mcp",
      "headers": {
        "x-api-key": "<your-kubesense-api-key>"
      }
    }
  }
}

Claude Code

Add the MCP server to your Claude Code configuration:

claude mcp add --transport http kubesense-mcp "https://<kubesense-host>/mcp" --header "x-api-key: <your-kubesense-api-key>" --scope user

See MCP installation scopes for more on the --scope option.

Cursor

Add the MCP server in Cursor via Settings > Tools & Integrations > MCP Tools > Add new global MCP server, or add it directly to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "kubesense-mcp": {
      "url": "https://<kubesense-host>/mcp",
      "headers": {
        "x-api-key": "<your-kubesense-api-key>"
      }
    }
  }
}

Other MCP Clients

Any MCP-compatible client can connect to the endpoint at /mcp using MCP's Streamable HTTP transport. Send your KubeSense API key in the x-api-key header.

Example Queries

Once connected, you can ask your AI assistant natural language questions like:

  • "Show me all error logs from the payments namespace in the last hour"
  • "What's the p99 latency for the checkout service over the past 24 hours?"
  • "Which pods are crash-looping right now, and why?"
  • "Compare error rates between the canary and stable deployments"
  • "Find traces where duration is over 5 seconds and group by service"
  • "Show me the ratio of 5xx errors to total requests as a percentage"
  • "What changed for the orders workload before this alert started firing?"
  • "List the alert rules that are currently firing and their history"

MCP Skills

KubeSense provides a set of pre-built MCP skills that extend your AI assistant with ready-to-use Kubernetes troubleshooting and analysis workflows. These skills act as prompt templates that guide the AI through common operational tasks using the MCP tools described above.

Explore the available skills and installation instructions in the kubesense-mcp-skills repository.