LL

last9/last9-mcp-server

Developer toolsOfficial
63 stars 13 forks Quality 88 Trend 20Apache-2.0

Your AI agent doesn't know what's broken in production. This fixes that.

Overview

Your AI agent doesn't know what's broken in production. This fixes that.

README

Last9 MCP Server

Your AI agent doesn’t know what’s broken in production. This fixes that.

Last9 MCP Server connects Claude, Cursor, Windsurf, and any other MCP-capable AI assistant directly to your production observability data — logs, metrics, traces, exceptions, database queries, alerts, and deployments. The agent stops guessing and starts reading the actual signal.


Start in 30 seconds (Hosted)

No binary to install. No tokens to manage. One URL, OAuth in your browser, done.

Find your org slug in your Last9 URL: app.last9.io//...

Claude Code

claude mcp add --transport http last9 https://app.last9.io/api/v4/organizations//mcp

Type /mcp, select last9, authenticate. That’s it.

Cursor

Settings > MCP > Add New MCP Server:

{
  "mcpServers": {
    "last9": {
      "type": "http",
      "url": "https://app.last9.io/api/v4/organizations//mcp"
    }
  }
}

Click Connect, complete OAuth.

VS Code

Requires v1.99+. Open Command Palette → MCP: Add Server, paste the URL, authenticate.

Or directly in settings.json:

{
  "mcp": {
    "servers": {
      "last9": {
        "type": "http",
        "url": "https://app.last9.io/api/v4/organizations//mcp"
      }
    }
  }
}

Windsurf

Settings > Cascade > Open MCP Marketplace > gear icon (mcp_config.json):

{
  "mcpServers": {
    "last9": {
      "serverUrl": "https://app.last9.io/api/v4/organizations//mcp"
    }
  }
}

Claude Web/Desktop

Settings > Connectors > Add custom connector. Name it last9, paste the URL, authenticate.

Requires admin access to your Claude organization.


Self-Hosted (STDIO)

Use this when your MCP client doesn’t support HTTP transport, or when you need the server running locally.

Install

Homebrew:

brew install last9/tap/last9-mcp

NPM:

Requires Node.js 22.23.4+, 24.22.1+ or 26.12.1+: earlier releases accept TLS certificates from the compromised eMudhra intermediates when the installer downloads the binary.

npm install -g @last9/mcp-server@latest
# or directly:
npx -y @last9/mcp-server@latest

Binary releases (Windows / manual):

Download from GitHub Releases:

Platform Archive
Windows (x64) last9-mcp-server_Windows_x86_64.zip
Windows (ARM64) last9-mcp-server_Windows_arm64.zip
Linux (x64) last9-mcp-server_Linux_x86_64.tar.gz
Linux (ARM64) last9-mcp-server_Linux_arm64.tar.gz
macOS (x64) last9-mcp-server_Darwin_x86_64.tar.gz
macOS (ARM64) last9-mcp-server_Darwin_arm64.tar.gz

Get a Refresh Token

Only admins can create tokens.

  1. Go to API Access
  2. Click Generate Token with Write permissions
  3. Copy it

Client Configuration

Homebrew:

{
  "mcpServers": {
    "last9": {
      "command": "/opt/homebrew/bin/last9-mcp",
      "env": {
        "LAST9_REFRESH_TOKEN": ""
      }
    }
  }
}

NPM:

{
  "mcpServers": {
    "last9": {
      "command": "npx",
      "args": ["-y", "@last9/mcp-server@latest"],
      "env": {
        "LAST9_REFRESH_TOKEN": ""
      }
    }
  }
}

Where to paste this:

Client Location
Claude Web/Desktop Settings > Developer > Edit Config (claude_desktop_config.json)
Cursor Settings > Cursor Settings > MCP > Add New Global MCP Server
Windsurf Settings > Cascade > MCP Marketplace > gear icon (mcp_config.json)
VS Code Wrap in { "mcp": { "servers": { ... } } } in settings.json — details

Environment Variables

Variable Default Description
LAST9_REFRESH_TOKEN (required) Refresh token from API Access
LAST9_DATASOURCE org default Datasource/cluster name — useful when you have multiple Levitate clusters
LAST9_FAKE_NOW_ISO (unset) For evals/replays only; never set in production. RFC3339 instant (e.g. 2026-01-02T15:04:05Z) that replaces the current time when resolving relative windows such as lookback_minutes, so runs are reproducible. An invalid value is a startup error. Timeouts, caches and token expiry keep using real time
LAST9_API_HOST app.last9.io Override the API host
LAST9_TOOLSETS all tools Comma-separated toolsets to expose (logs, traces, metrics, alerts, dashboards, profiles, grafana, investigate, all). Alias: LAST9_MCP_TOOLSETS
LAST9_MCP_READ_ONLY false Set true to serve only read-only tools; see Read-only mode. A value that is not a boolean is a startup error. Alias: LAST9_READ_ONLY
LAST9_MCP_ALLOW_WRITE_TOOLS — Comma-separated write tools still served in read-only mode. Alias: LAST9_ALLOW_WRITE_TOOLS
LAST9_MAX_GET_LOGS_ENTRIES 5000 Max entries for chunked get_logs requests
LAST9_USE_LOG_SEARCH_API false Set true to answer get_logs and get_service_logs with one server-side search call instead of client-side chunking. Each call gets 90 seconds, then returns advice to narrow the window; a 502 or 503 is retried once within it
LAST9_DEBUG_CHUNKING false Set true to log chunk-planning details for get_logs, get_service_logs, get_traces
LAST9_DISABLE_TELEMETRY true Set false to enable internal OTel tracing
OTEL_SDK_DISABLED — Standard OTel env var. Overrides LAST9_DISABLE_TELEMETRY
OTEL_EXPORTER_OTLP_ENDPOINT — OTLP collector endpoint (only when telemetry is enabled)
OTEL_EXPORTER_OTLP_HEADERS — OTLP auth headers (only when telemetry is enabled)

Tool phase timing

With internal telemetry enabled, tool spans carry last9.phase..duration_ms (real elapsed milliseconds) and last9.phase..failed (whether that phase returned an error). The same fields are emitted as tool phase completed debug logs, with tool and phase, when the configured logger accepts debug records. Inputs, query text, credentials and error bodies are not added by these timings.

Tool Phases
get_log_patterns sample: fetch and decode the sample; mine: pattern mining; deep_link: resolve the optional index and build the link
get_logs fetch: fetch, decode and merge results, including retries and optional count sanity checks; count_sanity: the nested optional check; post_process: guidance, summary and JSON formatting; deep_link: index resolution and link construction
get_service_profile request: prepare and send the request through the shared API client and read its complete response, before brief formatting

Only executed phases are recorded, including failed fetches. Optional helpers that suppress errors retain that behavior; failed: false does not certify that an optional link or count check was available. The nested count_sanity duration is already included in fetch; do not add it twice. Fetch time includes client work, so it is not a measurement of backend execution alone. Compare these phases on equivalent windows and search paths before tuning sampling or caching.

For a latency investigation, replay the same service, datasource, index, window, and limits on the baseline and candidate builds. Record the build SHA, tool total, phase durations, last9.logs.search_path, retry attributes when present, and coverage flags. Compare slow calls as well as typical calls. A slow fetch or profile request identifies a network/API phase to investigate; backend execution needs its own correlated evidence before assigning the tail to the backend. These diagnostics alone do not establish a latency improvement.

Read-only mode

--read-only (or LAST9_MCP_READ_ONLY=true) serves only tools annotated readOnlyHint: true, so no tool can create, change or delete alert rules, notification channels, dashboards or drop rules, acknowledge or reassign alerts, or mute groups. A tool without annotations counts as a write tool and is hidden.

To keep a few write tools, list them with --allow-write-tools (or LAST9_MCP_ALLOW_WRITE_TOOLS):

last9-mcp --read-only --allow-write-tools=acknowledge_alert,mute_alert_group
  • The server refuses to start if an allowed name is not a write tool (a typo, or a read tool’s name); the error lists the valid write tools.
  • --allow-write-tools without --read-only is a startup error, because every write tool is already served.
  • Read-only combines with --toolsets: a tool is served only when it passes both. --toolsets=alerts --read-only --allow-write-tools=mute_alert_group serves the alerts read tools plus mute_alert_group; an allowed write tool outside the chosen toolsets stays hidden.
  • --http mode and dump-tools honor the same flags and env vars: go run . dump-tools --read-only prints the read-only surface, with the server instructions it serves in instructions.
  • Read tools’ descriptions, schemas and results, and the server instructions, never name a hidden write tool. An allowed write tool can still name its hidden siblings (create_alert creates a disabled rule that patch_alert enables), so allow such pairs together.

What It Can Do

Orientation

  • get_workspace_overview — Recommended first call when a request names no service or tool (one that does goes straight to its tool): environments, which signals (logs, traces, metrics) were seen in the last hour, service and alert-group counts, firing alerts, and the current time in one cheap call. A signal not seen in that hour can still have older data, so it stays queryable. A failed sub-call leaves its field null and adds an errors[] entry. Served under every toolset
  • get_current_time — Current time, plus absolute bounds for last 2h, yesterday or since yesterday 9am IST, in any IANA zone or common abbreviation. Served under every toolset
  • send_feedback — Lets the agent report a clear MCP server defect or missing capability straight to the Last9 team after checking the tool’s inputs and guidance; routine query errors, empty results and usage uncertainty are not reported. The server version and, when the client reports it, the client’s name and version are attached (over --http, from per-request _meta clientInfo or the Mcp-Session-Id returned by initialize). Served under every named toolset and in --read-only mode; left out of investigate

Service Health

  • get_service_summary — Ranked fleet (service, env) rows: interval request_count, throughput_rpm, HTTP 4xx/5xx counts, and gRPC error counts
  • get_service_environments — Available environments for your services. Run this first — other APM tools need env from here
  • get_service_performance_details — Full breakdown: throughput, error rate, p50/p90/p95/avg/max, apdex, availability (summarized by default; full series with include_series)
  • get_service_operations_summary — Operations grouped by HTTP endpoints, DB calls, messaging, HTTP clients
  • get_service_dependency_graph — Dependency map with throughput, latency, and error rates for upstream/downstream/infra
  • get_apm_service_deviations — Compare a current window against an equal-duration baseline: regressions/improvements, Apdex reconciliation, and a terminal outcome (fleet or single service)
  • get_exceptions — Server-side exceptions with service and span filters

Database Observability

Four tools that go directly at your database performance, derived from OpenTelemetry trace spans and, where traces are absent, infrastructure metrics such as CloudWatch. No extra instrumentation needed if you’re already using OTel.

  • get_databases — Discover all databases across your infrastructure: DB type, host, throughput (queries/min), p95 latency, error rate, number of dependent services. Also discovers databases from infrastructure metrics such as CloudWatch, with no trace instrumentation needed — those rows carry an activity value instead of trace metrics
  • get_database_slow_queries — The actual slowest query executions, ordered by duration, with trace IDs for drilling into full traces
  • get_database_queries — Query patterns and aggregates: how often a query runs, average/p95 duration, error rate
  • get_database_server_metrics — Server-side metrics from the DB host itself (CPU, connections, buffer hit rates — depends on your DB system)

Supports PostgreSQL, MySQL, MongoDB, Redis, Aerospike, and anything else OTel traces with a db_system attribute — plus databases discovered from infrastructure metrics such as CloudWatch, whose rows carry an activity value instead of trace metrics.

Prometheus / PromQL

  • prometheus_range_query — PromQL range queries over any metric
  • prometheus_instant_query — Instant queries; use rollup functions like avg_over_time, sum_over_time
  • prometheus_label_values — Label values for a given series
  • prometheus_labels — All labels available for a series

Point these at a different datasource/cluster than the default by setting LAST9_DATASOURCE, or per call with datasource. An omitted datasource uses the default; a unique near miss that the matcher considers safe (such as a case variant) uses its closest match. A missing, extra or transposed letter is not guaranteed to resolve automatically: even one candidate can require confirmation when the edit could affect a region or environment code. Looser or ambiguous matches return candidates and run no query (not an error); unknown names return an error. An additional content block names the datasource used whenever you did not name it exactly. get_metric_status, get_service_profile, and get_apm_service_deviations resolve datasource the same way.

Logs

  • get_logs — Full JSON pipeline log queries (aggregations, filters, field extraction)
  • get_service_logs — Log lines for a service, filterable by severity and body content; summarized over 20 lines unless response_mode is raw
  • get_log_patterns — A service’s log lines in a window clustered into message templates, with count, first/last seen, severity mix and a sample
  • get_emerging_log_patterns — Log templates that are new, increased, decreased or disappeared against a baseline window, with counts from both
  • get_log_attributes — Global catalog of attributes in the log schema for a time window
  • get_log_attributes_for_pipeline — Log fields actually present for an in-progress pipeline (scoped discovery), each with its exact filter_field
  • get_drop_rules — Log drop rules from Last9 Control Plane
  • add_drop_rule — Create a new drop rule to cut log volume at the source
  • get_remapping_rules — Remapping rules (logs_extract, logs_map, traces_map) from Last9 Control Plane
  • add_remapping_rule — Create a remapping rule that extracts or maps log and trace attributes at ingestion

Traces

  • get_traces — JSON pipeline trace queries for broad searches and aggregations
  • get_service_traces — Traces by exact trace ID or service name. Use this when you have a trace ID — it’s faster
  • get_trace_attributes — Global catalog of attributes in the trace schema
  • get_trace_attributes_for_pipeline — Attributes actually present for an in-progress pipeline (scoped discovery), each with its exact filter_field
  • get_trace_attribute_values — Distinct values for a trace attribute, optionally scoped to a pipeline
  • get_trace_attribute_deviations — Ranks attribute values that differ between two bounded span cohorts (slow vs fast, error vs non-error, or two time windows). Correlation, not cause
  • get_trace_waterfall — One exact trace as a parent/child waterfall with interval-union self-time, slowest spans, and graph warnings

Change Events & Alerts

  • get_change_events — Deployments, config changes, rollbacks. Correlate incidents with what changed
  • analyze_change_impact — Did a change break anything? Compares a service and its direct callers before and after a change: golden signals, APM and trace-attribute deviations, new firing alerts, and a verdict (regression likely / no significant change / insufficient data)
  • get_alert_groups — Configured Compass alert groups with metadata labels, team, tier, and rule counts — including groups with zero rules and groups that are not firing
  • get_alert_coverage — What you are not alerting on: uncovered golden signals, fully disabled or unrouted alert groups, and rules muted too long, each with a suggested fix tool. Read-only.
  • get_alert_config — Alert rule configurations — searchable by name, severity, type, tags
  • get_entity_kpis — Every KPI (id, name, PromQL, unit) on one alert group, including KPIs no rule uses yet — the ids create_alert and validate_alert_expression need
  • create_kpi — Create a KPI (PromQL + unit) on an alert group when no existing KPI fits. Create once and keep the returned id
  • get_alerts — Currently firing alerts within a time window
  • get_alert_rule_state — Historical firing state (1/0) per alert rule over a time range, grouped by rule_id. Filterable by alert group, rule name, label filters, and state.
  • get_notification_channels — Configured notification channels (Slack, PagerDuty, email, etc.). scope=channels lists the channels themselves (ids for attaching); the default attached lists per-alert-group attachments
  • recommend_alert_config — Read-only design guidance (lifecycle, validation gates, responder context) before creating an alert rule
  • validate_alert_expression — Dry-run an alert expression against an alert group’s KPIs without saving anything
  • describe_alert_chart — Read-only: the alertable signals (key, unit) on a Discover chart (discover-service, discover-exceptions)
  • create_alert — Create an alert rule (static, or adaptive via adaptive_std_cmp) in an existing alert group; always created disabled as a draft. Create once; refine with update_alert / patch_alert
  • create_alert_from_chart — Create a static-threshold alert rule from a Discover chart in one call. Like create_alert, the rule is created disabled as a draft
  • update_alert — Full replacement of a rule’s evaluation config (may return a replacement rule ID)
  • patch_alert — Partial change to a rule: enable/pause, mute_until, responder properties, weekly recurring_mute_schedule (or clear_recurring_mute_schedule)
  • delete_alert — Permanently delete an alert rule
  • mute_alert_group — Mute (or unmute) every rule in an alert group until a deadline
  • acknowledge_alert — Take ownership of a firing alert, or release it
  • reassign_alert — Hand an already-acknowledged alert to another user
  • create_notification_channel — Create a Slack, PagerDuty, Opsgenie, email, or generic webhook channel
  • attach_notification_channel — Route an existing channel to an alert group for breach, threat, or both
  • detach_notification_channel — Remove one channel-to-alert-group attachment
  • delete_notification_channel — Permanently delete a channel that has no attachments

The alert write tools (create_kpi, create_alert, update_alert, patch_alert, delete_alert, create_alert_from_chart, mute_alert_group, acknowledge_alert, reassign_alert, create_notification_channel, attach_notification_channel, detach_notification_channel, delete_notification_channel) need a token with write scope; delete_alert, detach_notification_channel and delete_notification_channel need delete scope instead. They are exposed only in the alerts toolset.

Rules, channels and attachments these tools create are marked created_via: last9-mcp together with the MCP client’s name and version (on rules, the _l9_created_via_ and _l9_created_via_client_ annotations, which patch_alert and update_alert keep and callers cannot set). get_entity_alert_rules and get_notification_channels show the marker, and delete_alert, detach_notification_channel and delete_notification_channel tell agents to clean up only marked resources unless the user names one.

Custom Dashboards

  • list_dashboards — Custom dashboards filtered by name and paged under 32 KB: IDs, names, last-updated times, authors and lock state
  • get_dashboard — Full dashboard definition by ID, including panels and queries
  • preview_dashboard — Read-only preview of an unsaved dashboard or patch: resolved queries, bounded per-panel results and a net panel diff; never saves
  • validate_dashboard — Read-only lint + execute + classify for a saved dashboard id or an inline dashboard_definition over a ≤24h window. Never creates or updates dashboards
  • create_dashboard — Create a net-new custom dashboard once (panels, queries, metadata). After the id is returned, edit panels with patch_dashboard.
  • update_dashboard — Restructure most of an existing dashboard by ID (full replacement; readonly system dashboards return an error). For individual panel edits use patch_dashboard
  • patch_dashboard — Targeted edits to an existing dashboard by ID (add/update/remove/move panel, set title, set variable); returns a compact diff, not the full dashboard
  • delete_dashboard — Delete a custom dashboard by ID
  • set_dashboard_lock — Lock or unlock a custom dashboard by ID (author or org admin only); a locked dashboard refuses update, patch and delete
  • list_dashboard_snapshots — Frozen point-in-time snapshots for a dashboard (metadata only)
  • get_dashboard_snapshot — Full frozen snapshot including panel data for RCA / shareable views
  • delete_dashboard_snapshot — Delete a frozen snapshot by ID

Dashboard authoring is available through MCP prompts/list and prompts/get, without installing a skill. All three prompts take no arguments:

  • create_dashboard_guide — Discovery, layout and panel selection; validate the complete candidate and run each panel’s query before approval, create once, patch targeted edits, then read back.
  • dashboard_examples — A complete example covering service RED, endpoint latency, status classes, host health, log counts and trace panels, with dependent variables.
  • query_guide — Counter/gauge/histogram and derived trace metric semantics, instant versus range, rate windows, percentage bounds, and logjson/tracejson rules.

The same content is readable at last9://reference/create_dashboard_guide, last9://reference/dashboard_examples, and last9://reference/query_guide. Prompts and resources remain discoverable under every toolset; executing the workflow needs the relevant tools (for mixed-signal authoring, use --toolsets=dashboards,investigate, which also serves list_datasources). Read-only sessions can prepare and validate but cannot save. Check tool availability before following a step.

Panel checks currently use prometheus_range_query, prometheus_instant_query, get_logs and get_traces alongside validate_dashboard. The validator’s unsupported query types and simplified defaults do not establish rendering parity. The separate query-check step will switch to query_panel after #475 lands.

Continuous Profiling

Requires continuous profiling enabled for the org. Discover services first with get_profile_services, then pull a flamegraph or ranked functions.

  • get_profile_services — Services that have profiling data in the window (index before querying)
  • get_flamegraph — Nested flamegraph tree for one service (cpu default; also alloc, wall)
  • get_top_functions — Self-sample ranking of hottest functions for one service
  • get_profile_summary — Short natural-language triage of the profile for one service

Grafana Dashboards

Read-only tools against the org’s Grafana instance (via Last9’s Grafana proxy). Credential fields are never returned to the model. Enable with LAST9_TOOLSETS=grafana (or leave toolsets unset for all tools).

  • grafana_search_dashboards — Search dashboards by title substring (paginated; truncated: true when the cap is hit)
  • grafana_get_dashboard — Dashboard summary by uid (panels, variables, PromQL targets); full_json=true for raw Grafana JSON
  • grafana_list_folders — Folder tree
  • grafana_list_folder_dashboards — Dashboards in one folder (paginated)
  • grafana_list_datasources — Datasource inventory without credentials

Fuzzy Name Resolution

  • did_you_mean — When the agent isn’t sure about an entity name, this returns the closest matches from your catalog (services, environments, hosts, databases, K8s deployments/namespaces, jobs). Up to 3 suggestions with similarity scores. The server calls this automatically before most tools when a name lookup returns empty.

Service Profile

  • get_service_profile — What a service’s telemetry actually looks like, before you query it: which signals exist, language and runtime, deployment environments, the shape of its logs, and a recommended ingest fix where one applies. Lets the agent skip trace tools when a service has no traces, and parse severity from the log body when SeverityText is empty instead of filtering on it and finding nothing.

How It Works

Deep links on every response. Every tool returns a deep_link field — a direct URL into the Last9 dashboard for that exact query and time range. The agent can hand you the link; you click it; you’re there.

Toolsets. By default the server exposes every tool. Automation hosts that only need investigation (logs/traces/metrics/profiles) can set LAST9_TOOLSETS=investigate (or pass --toolsets=investigate) so tools/list stays small without client-side mass-disable. Named packs: logs, traces, metrics, alerts, dashboards, profiles, grafana, investigate, all. Unknown names fail fast. get_current_time and get_workspace_overview are served under every toolset. In HTTP mode a request can narrow this further with the X-Last9-Toolsets header (see Per-request toolsets). The alerts pack also serves the read-only prometheus_range_query and get_dashboard, which the author-alert prompt calls. The metrics pack alone does not include list_datasources or did_you_mean — use investigate (or combine toolsets) when you need those discovery helpers.

Tool reference resources. Long logjson/tracejson/service-logs/metrics manuals are MCP resources (last9://reference/logjson, last9://reference/tracejson, last9://reference/service_logs, last9://reference/metrics, last9://reference/investigation, last9://reference/alerting), not always-on tool description text. The alerting manual covers the alert expression grammar, static vs adaptive fields, units, what validate_alert_expression checks, and latency / error-rate / saturation rule templates. Critical query rules stay on the tool description so agents that never call resources/read still get correct construction guidance. Discover org-specific fields with get_log_attributes / get_log_attributes_for_pipeline (and the trace equivalents)—they are not injected into descriptions.

Chunked large results. get_logs and get_traces handle large result sets through chunking rather than truncating. The default limit is 5000 entries for logs; configurable via LAST9_MAX_GET_LOGS_ENTRIES.


Development


Tool Reference


Testing

Run the test goroutine analyzer without executing the application tests:

make lint-test

This runs Go’s testinggoroutine analyzer over all packages, including their *_test.go files, and checks it against unsafe and safe fixtures. Both CI test workflows run go vet -testinggoroutine ./... as a separate step, so cached package test results cannot bypass lint enforcement.

The root package also runs the analyzer as a test. Use go test -count=1 ./... for the full suite with that check uncached: Go’s test cache does not track internal package source files read by the analyzer subprocess. A plain go test ./... can reuse the root test’s passing result after those files change.

Fatal, Fatalf, and FailNow on testing.T or testing.B must run in the parent test goroutine. Workers should send errors back for the parent to assert:

errs := make(chan error, 1)
go func() { errs <- doWork() }()
if err := <-errs; err != nil {
    t.Fatal(err)
}

The analyzer catches direct calls in go func closures; it is not a general interprocedural check for assertions hidden behind arbitrary helper calls. Integration tests skip unless TEST_REFRESH_TOKEN is set.


View the full README on GitHub

Install

npx -y @last9/mcp-server@latest
New to MCP? Start with the mcpskill.org guide →

Configuration

{ "mcpServers": { "last9": { "type": "http", "url": "https://app.last9.io/api/v4/organizations/<org_slug>/mcp" } } }