Last9 MCP
Connect your AI client to Last9 logs, traces, metrics, alerts, and dashboards through MCP.
Last9’s MCP server lets your AI assistant query production telemetry from your IDE. Ask questions such as “What’s causing the recent spike in errors?” or “Show me the slowest endpoints from the last hour”, then open the supporting Last9 data from the response.
Use AI Assistant for chat in Last9 or agent skills for instructions your coding agent can follow. To connect your own bot or investigation service, see Build your own AI SRE.
What is Model Context Protocol?
MCP is an open protocol for connecting AI applications to tools and data sources.
Last9 MCP exposes tools to query telemetry, inspect service dependencies, review alerts, and manage dashboards. Your client chooses which tools to call and uses their results to answer your question.
Why use Last9 MCP?
Connect Last9 MCP to investigate production behavior alongside your code:
- Query the logs and traces for a failing request.
- Compare service latency, errors, and dependencies over a specific time window.
- Give a coding agent evidence to use when proposing a fix.
Start with the service, environment, and incident window. For a complete investigation workflow, see Investigate an incident.
Example use cases
Debug production exceptions
"I'm seeing errors in production. Can you help me understand what's happening?"Agent uses get_exceptions and get_service_performance_details to analyze the issue
Performance investigation
"My API response times seem slow. What's causing the latency?"Agent uses get_service_dependency_graph and prometheus_range_query to identify bottlenecks
Trace waterfall analysis
"I have a slow trace ID. Show me where the time is going."Agent uses get_trace_waterfall to return a bounded parent/child waterfall with millisecond timing, self-time, and the slowest spans
Compare slow vs fast spans
"What attributes differ between slow and fast requests on checkout-service?"Agent uses get_trace_attribute_deviations with comparison_mode: latency to rank attribute values that correlate with slow spans
Detect performance regressions
"What services regressed in the last hour compared to the previous hour?"Agent uses get_apm_service_deviations to compare the current window against an equal-duration baseline and return regressions/improvements leaderboards
Log analysis for issues
"Find error logs from the user-service in the last 30 minutes"The agent can use get_service_logs to read service log lines, or get_logs with a LogJSON pipeline to filter and aggregate them.
Correlate incidents with deployments
"We had performance issues around 2pm. Were there any deployments around that time?"Agent uses get_change_events to check for recent deployments and get_service_performance_details to analyze the correlation
Database performance investigation
"Which databases are my services hitting, and what are the slowest PostgreSQL queries in prod right now?"Agent uses get_databases, get_database_queries, get_database_slow_queries, and get_database_server_metrics to connect database load, slow queries, and exporter-backed server health
Auto-correct typos in entity names
"Can you look up last9-apiii logs"The agent can use did_you_mean to suggest matching entity names. Confirm the intended service before querying its logs.
Prerequisites
Before setting up Last9 MCP, ensure you have:
- Telemetry flowing to your Last9 organization.
- One of the supported clients: Claude Code, Cursor, VS Code, Windsurf, Claude.ai / Claude Desktop, Codex CLI, or ChatGPT
- A Last9 account with access to the organization you want to query. Check your connection settings on the MCP page in Last9.
Setup
-
Find your organization slug
Your org slug is in your Last9 URL when logged in:
https://app.last9.io/v2/organizations/<org_slug>/...For example, if your URL contains
/v2/organizations/acme/, your slug isacme. -
Configure your IDE
Choose your client below, replace
<org_slug>, and complete its OAuth sign-in flow.-
Run the following command to add the Last9 MCP server:
claude mcp add --transport http last9 "https://app.last9.io/api/v4/organizations/<org_slug>/mcp" -
Replace
<org_slug>with your organization slug -
Type
/mcpin Claude Code, select the last9 server, and authenticate -
After authorizing, check the server’s available tools in your session.
-
Open Cursor → Settings → Cursor Settings → MCP
-
Click Add New MCP Server
-
Add the configuration:
{"mcpServers": {"last9": {"type": "http","url": "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"}}} -
Replace
<org_slug>with your organization slug -
Save, then select Connect for the server.
-
Click Connect → a browser window opens → authorize with your Last9 account
See the VS Code MCP documentation for client settings and permissions.
-
Open the Command Palette (
cmd+shift+Pon macOS /ctrl+shift+Pon Windows/Linux) -
Select MCP: Add Server → choose HTTP as the type
-
Paste the server URL with your organization slug:
https://app.last9.io/api/v4/organizations/<org_slug>/mcp -
Enter
last9as the server name -
Choose Global or Workspace scope
-
Complete the OAuth sign-in flow in your browser when VS Code prompts you.
-
Open Windsurf → Settings → Cascade → click Open MCP Marketplace
-
Click the gear icon (⚙) to open
mcp_config.json -
Add the Last9 MCP server configuration:
{"mcpServers": {"last9": {"serverUrl": "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"}}} -
Replace
<org_slug>with your organization slug -
Save the file and follow Windsurf’s authentication prompt.
-
Complete the OAuth flow in your browser to authorize Last9 access
Note: Admin access to your Claude organization is required to add custom connectors. For more details, see the Claude custom connectors guide.
-
Go to Settings → Connectors → click Add custom connector
-
Enter
last9as the Name -
Paste the Remote MCP server URL with your organization slug:
https://app.last9.io/api/v4/organizations/<org_slug>/mcp -
Click Add
-
Go to Customize → Connectors → select last9 under “Not connected”
-
Click Connect and complete the OAuth flow in your browser
Option A: CLI commands
codex mcp add last9 --url "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"codex mcp login last9Option B: manual config in
~/.codex/config.toml:[mcp_servers.last9]url = "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"Replace
<org_slug>with your organization slug. After saving manual configuration, runcodex mcp login last9to authorize access. See the Codex MCP documentation.Use a ChatGPT web workspace that supports custom MCP apps. Your workspace administrator may need to enable developer mode. Check ChatGPT developer mode availability and permissions.
-
Enable Developer Mode
Go to Settings → Apps → Advanced settings and enable Developer mode, where available.
-
Create an app
Go to Settings → Apps and click Create.
-
Enter the app details:
-
Name:
Last9 -
Description:
Query Last9 logs, traces, metrics, alerts, and deployments -
MCP server URL:
https://app.last9.io/api/v4/organizations/<org_slug>/mcp
Replace
<org_slug>with your organization slug. -
-
Select OAuth authentication, complete the Last9 sign-in flow, and use Scan Tools to review the available tools. Finish creating the app.
-
Select the app in the conversation where you want to use it. Try: “What exceptions occurred in the last hour?” Review any tool confirmation requests before proceeding.
-
-
Verify the connection
Once configured, your AI agent will have access to Last9 tools. Try asking: “What exceptions occurred in the last hour?” or “Show me the performance summary for my services.”
Using Last9 MCP with OpenAI’s Responses API
Connect the Responses API to the hosted Last9 MCP endpoint. The example below permits only two read tools and skips approval for those tools. Set OPENAI_MODEL to a model that supports remote MCP, LAST9_ORG_SLUG to your organization slug, and LAST9_MCP_TOKEN to an MCP client token.
import osfrom openai import OpenAI
client = OpenAI()
response = client.responses.create( model=os.environ["OPENAI_MODEL"], tools=[ { "type": "mcp", "server_label": "last9", "server_url": ( "https://app.last9.io/api/v4/organizations/" f"{os.environ['LAST9_ORG_SLUG']}/mcp" ), "authorization": os.environ["LAST9_MCP_TOKEN"], "allowed_tools": ["get_service_profile", "get_service_logs"], "require_approval": "never", } ], input=( "Inspect payment-service errors in production over the last 15 minutes. " "Read its service profile and relevant log lines. " "Summarize the evidence and any missing information." ),)
print(response.output_text)Keep the allowlist specific to your task. To require approval, handle the API’s mcp_approval_request response before continuing the tool call. See the OpenAI remote MCP guide for authentication, tool filters, and approval handling.
Advanced: Self-hosting the MCP server
Run the open-source server locally when you need to manage its process or choose which toolsets it exposes. The server still needs network access to Last9.
Install:
# Homebrew (macOS/Linux)brew tap last9/tap && brew install last9-mcp
# NPM (cross-platform, including Windows)npm install -g @last9/mcp-server@latestYou can also download platform-specific binaries from GitHub Releases.
Get a Refresh Token (admin required) from API Access.
Configure your IDE using the local binary path and LAST9_REFRESH_TOKEN:
{ "mcpServers": { "last9": { "command": "/opt/homebrew/bin/last9-mcp", "env": { "LAST9_REFRESH_TOKEN": "<your_refresh_token>" } } }}For VS Code’s .vscode/mcp.json, use a top-level "servers" object keyed by "last9", with "type": "stdio", "command", and "env" inside it. See the VS Code configuration reference and Last9 MCP server README for configuration options.
Toolsets (optional). By default the server exposes every tool. For automation hosts that only need investigation workflows, set LAST9_TOOLSETS (alias LAST9_MCP_TOOLSETS) or pass --toolsets to limit what appears in tools/list:
{ "mcpServers": { "last9": { "command": "/opt/homebrew/bin/last9-mcp", "env": { "LAST9_REFRESH_TOKEN": "<your_refresh_token>", "LAST9_TOOLSETS": "investigate" } } }}Valid toolset names are logs, traces, metrics, alerts, dashboards, investigate, and all. Use a comma-separated list. An unset or empty value, or all, exposes every tool. Unknown names stop the server at startup. The investigate toolset includes logs, traces, metrics, and the discovery tools did_you_mean, get_service_profile, and list_datasources.
Reference resources. The server provides five resources: last9://reference/logjson, last9://reference/tracejson, last9://reference/service_logs, last9://reference/metrics, and last9://reference/investigation. Clients that support MCP resources can discover and read them through resources/list and resources/read. Tool descriptions include essential query rules. Discover your organization’s field names with get_log_attributes_for_pipeline and get_trace_attributes_for_pipeline.
Clients that support MCP prompts can discover six guided investigation prompts through prompts/list: scoped-log-attribute-discovery, exception-root-cause-investigation, investigate-latency-spike, diagnose-error-rate, analyze-slow-queries, and on-call-runbook. Check the returned prompt definition for its required inputs.
Available tools
The reference below describes Last9 MCP tools. Availability and parameters depend on your connected server version and configuration. Inspect tools/list for its current schemas.
Observability & APM
-
get_exceptions: Get server-side exceptions over a specified time range. For log-heavy services, the tool may continue to logs via aggregate-then-read: aggregate to isolate the hot logger, then read that logger’s lines with alimitto reach the error text.View parameters
limit(integer, optional): Maximum number of exceptions to return. Default: 20lookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60start_time_iso(string, optional): Start time in RFC3339 format. Leave empty to use lookback_minutesend_time_iso(string, optional): End time in RFC3339 format. Leave empty to default to current timeservice_name(string, optional): Filter by service namespan_name(string, optional): Name of the span to filter byenv(string, optional): Filter by environment
-
get_service_summary: Rank services using request counts, requests per minute, and HTTP or gRPC error counts over a time window.View parameters
lookback_minutes(integer, optional): Number of minutes to look back. Default: 60start_time_iso(string, optional): Start time in RFC3339 format. Default: end_time_iso - 1 hourend_time_iso(string, optional): End time in RFC3339 format. Default: Current timeenv(string, optional): Environment regex. Default:.*sort_by(string, optional): Ranking field; use the connected tool schema for supported valueslimit(integer, optional): Maximum number of services to return
-
get_service_environments: Get available service environments within a specified time range.View parameters
service_name(string, optional): Service to find environments forlookback_minutes(integer, optional): Number of minutes to look back. Default: 60start_time_iso(string, optional): Start time in RFC3339 format. Default: now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current time
Returns available environments for use with other APM tools.
-
get_service_performance_details: Get detailed performance metrics for a specific service.View parameters
service_name(string, required): Service namelookback_minutes(integer, optional): Number of minutes to look back. Default: 60top_n(integer, optional): Number of results. Default: 10; maximum: 100start_time_iso(string, optional): Start time in RFC3339 format. Default: Now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current timeenv(string, optional): Environment filter. Default:.*
-
get_service_operations_summary: Get operations summary for a service like HTTP endpoints, database queries, messaging producer, and HTTP client calls.View parameters
service_name(string, required): Service namelookback_minutes(integer, optional): Number of minutes to look back. Default: 60start_time_iso(string, optional): Start time in RFC3339 format. Default: Now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current timeenv(string, optional): Environment filter. Default:.*
-
get_service_dependency_graph: Get service dependency graph showing incoming and outgoing dependencies, including infra. Includes throughput, response times and error rates.View parameters
service_name(string, optional): Name of the servicelookback_minutes(integer, optional): Number of minutes to look back. Default: 60start_time_iso(string, optional): Start time in RFC3339 format. Default: now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current timeenv(string, optional): Environment filter. Default:.*
-
get_change_events: Retrieves change events from thelast9_change_eventsPrometheus metric to help correlate deployments and system modifications with performance issues or incidents.View parameters
start_time_iso(string, optional): Start time in RFC3339 format. Defaults to now - lookback_minutesend_time_iso(string, optional): End time in RFC3339 format. Defaults to current timelookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60service_name(string, optional): Filter by service nameenv(string, optional): Environment filterevent_name(string, optional): Specific event type filter (use available_event_names to see valid values)
Returns:
available_event_names: List of all available event types that can be used for filteringchange_events: Array of timeseries data with metric labels and timestamp-value pairscount: Total number of change events returnedtime_range: Start and end time of the query window
Common event types: deployment, config_change, rollback, scale_up/scale_down, restart, upgrade/downgrade, maintenance, backup/restore, health_check, certificate, database
Best practices:
- First call without event_name to get available_event_names
- Use exact event name from available_event_names for the event_name parameter
- Combine with other filters (service_name, env, time) for precise results
-
get_apm_service_deviations: Compare APM performance across a current window and an equal-duration baseline. Use for regressions/improvements, incident-vs-prior-period comparisons, and fleet deviation discovery.View parameters
service_name(string, optional): Omit for fleet scope; provide for one service and its operation correlationsenv(string, optional): Filter to one deployment environmentlookback_minutes(integer, optional): Current window length ending now. Default: 60start_time_iso/end_time_iso(string, optional): Explicit current windowbaseline_start_time_iso/baseline_end_time_iso(string, optional): Equal-duration baseline window; defaults to the immediately preceding perioddatasource(string, optional): Select one datasource for the comparisonmax_services/max_operations(integer, optional): Default: 10, maximum: 10
Returns:
regressionsandimprovementsleaderboards,evidence_quality, Apdex reconciliation, and a terminaloutcome. Treatstable,no_data, andunsupported_workload_shapeas terminal — answer from the result without automatic follow-up tool calls. V1 supports server-request workloads.
Database investigation
-
get_databases: Discover databases from available telemetry. Trace-derived results include database type, host, throughput, p95 latency, error rate, and service counts. Connected servers that support infrastructure or CloudWatch metric discovery can also return databases found through those signals. Metric-only results may not include trace latency or throughput.View parameters
env(string, optional): Environment regex, such asprod|staginglookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60; current server limits the window to seven daysstart_time_iso(string, optional): Start time in RFC3339 format. Overrides lookback_minutesend_time_iso(string, optional): End time in RFC3339 format
Useful for:
- Discovering which databases your services are talking to
- Ranking database backends by throughput, latency, and error rate
- Identifying shared databases used by many services
-
get_database_slow_queries: Find the slowest database operations from traces and, when available, slow-query logs. Results are sorted by duration descending.View parameters
db_system(string, optional): Database system filter such aspostgresql,mysql,mongodb, orredishost(string, optional): Database host filter usingnet_peer_nameservice_name(string, optional): Calling service name filterenv(string, optional): Deployment environment filtermin_duration_ms(number, optional): Minimum query duration in millisecondslookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60start_time_iso(string, optional): Start time in RFC3339 formatend_time_iso(string, optional): End time in RFC3339 formatlimit(integer, optional): Maximum number of slow queries to return. Default: 20
Returns:
- Query source (
traceorlog) - Trace and span IDs when available
- Service name, database system, query pattern or statement, duration, status, and timestamp
- Slow-query metadata from logs such as plan summaries or rows examined when present
-
get_database_queries: Get the top query patterns for a specific database, aggregated by operation. Helps identify hot, slow, or error-prone query shapes.View parameters
db_system(string, required): Database system such aspostgresql,mysql,mongodb, orredishost(string, optional): Database host filter usingnet_peer_nameenv(string, optional): Deployment environment filterlookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60start_time_iso(string, optional): Start time in RFC3339 formatend_time_iso(string, optional): End time in RFC3339 formatsort_by(string, optional): Sort bythroughput(default),latency, orerrors
Returns:
span_namecalls_per_minavg_latency_msp95_latency_mserror_rate_pct
-
get_database_server_metrics: Discover server-side database metrics from exporters and query key health signals such as connection utilization, cache hit ratios, replication lag, and throughput.View parameters
db_system(string, optional): Focus on a specific database type. Supported values:postgresql,mysql,oracle,redis,mongodb,mssql,elasticsearch,aerospikelookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60start_time_iso(string, optional): Start time in RFC3339 formatend_time_iso(string, optional): End time in RFC3339 format
Notes:
- If
db_systemis omitted, the tool auto-discovers available exporters - Requires database exporters such as
postgres_exporter,mysqld_exporter,redis_exporter, ormongodb_exporterto be scraped into Prometheus or Levitate - Complements client-side trace data with server-side health metrics
Prometheus integration
-
list_datasources: List all available datasources configured for your organization. Use this before Prometheus queries to discover valid datasource names.Returns
- Array of datasource objects, each with:
name: datasource identifier to pass via thedatasourceparameter in Prometheus toolsis_default:truefor the datasource used when nodatasourceis specified
- Array of datasource objects, each with:
-
prometheus_range_query: Execute Prometheus range queries for metrics over a time period.View parameters
query(string, required): Range query to executelookback_minutes(integer, optional): Window ending now when absolute bounds are omitteddatasource(string, optional): Datasource name fromlist_datasourcesstart_time_iso(string, optional): Start time in RFC3339 format. Default: now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current time
-
prometheus_instant_query: Execute Prometheus instant queries for metrics at a specific point in time.View parameters
query(string, required): Instant query to executelookback_minutes(integer, optional): Minutes before now to evaluate whentime_isois omitteddatasource(string, optional): Datasource name fromlist_datasourcestime_iso(string, optional): Time in RFC3339 format. Default: Current time
-
prometheus_label_values: Get all label values for a specific label name.View parameters
match_query(string, required): Valid PromQL filter querylabel(string, required): Label to get values forlookback_minutes(integer, optional): Window ending now when absolute bounds are omitteddatasource(string, optional): Datasource name fromlist_datasourcesstart_time_iso(string, optional): Start time in RFC3339 format. Default: now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current time
-
prometheus_labels: Get all available label names.View parameters
match_query(string, required): Valid PromQL filter querylookback_minutes(integer, optional): Window ending now when absolute bounds are omitteddatasource(string, optional): Datasource name fromlist_datasourcesstart_time_iso(string, optional): Start time in RFC3339 format. Default: now - 60 minutesend_time_iso(string, optional): End time in RFC3339 format. Default: Current time
Log management
-
get_logs: Runs a LogJSON pipeline to filter, transform, or aggregate logs. Useget_service_logsfor raw service log lines.View parameters
logjson_query(array, required): LogJSON pipeline. Readlast9://reference/logjsonfor query syntaxlookback_minutes(integer, optional): Number of minutes to look back from now. Default: 5start_time_iso(string, optional): Start time in RFC3339/ISO 8601 format. Use withend_time_isofor an absolute time rangeend_time_iso(string, optional): End time in RFC3339/ISO 8601 format. Use withstart_time_isofor an absolute time rangelimit(integer, optional): Result limit. Defaults depend on the pipeline shape and the server’s configured capindex(string, optional):physical_index:<name>orrehydration_index:<block_name>
-
get_service_logs: Retrieves raw log entries for a specific service with advanced filtering capabilities. Useful for debugging issues, monitoring service behavior, and analyzing specific log patterns.Additional filters include
http_status_class,http_status_code,http_status_field,attribute_filters, andindex. Use status-class filtering for groups such as 4xx or 5xx; check the connected schema for accepted values.View parameters
service_name(string, required): Name of the service to get logs forlookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60limit(integer, optional): Maximum log entries to return. Default: 20env(string, optional): Environment to filter by. Useget_service_environmentsto get available environmentsseverity_filters(array, optional): Filter by log severity levels (e.g.,["error", "warn"]). Uses OR logicbody_filters(array, optional): Filter by log message content (e.g.,["timeout", "failed"]). Uses OR logicstart_time_iso(string, optional): Start time in RFC3339 formatend_time_iso(string, optional): End time in RFC3339 format
Filtering behavior:
- Multiple filter types are combined with AND logic (service AND severity AND body)
- Each filter array uses OR logic (matches any pattern in the array)
-
get_drop_rules: Gets drop rules for logs, which determine what logs get filtered out from reaching Last9. -
add_drop_rule: Adds a new drop rule to filter out specific logs at Last9 Control PlaneView parameters
name(string, required): Name of the drop rulefilters(array, required): List of filter conditions to apply. Each filter has:key(string, required): The key to filter on. Only attributes and resource.attributes keys are supported. For resource attributes, use format:resource.attributes[key_name]and for log attributes, use format:attributes[key_name]. Double quotes in key names must be escapedvalue(string, required): The value to filter againstoperator(string, required): The operator used for filtering. Valid values: “equals”, “not_equals”conjunction(string, required): The logical conjunction with the other filters. Valid values: “and”
-
get_log_attributes: Returns available log attribute names existing during the specified time window, grouped by category. Useful for discovering what attributes can be used for filtering and querying logs.View parameters
lookback_minutes(integer, optional): Number of minutes to look back from now for the time window. Default: 15start_time_iso(string, optional): Start time in RFC3339 format. Leave empty to use lookback_minutesend_time_iso(string, optional): End time in RFC3339 format. Leave empty to default to current timeregion(string, optional): AWS region to query. Leave empty to use default from configurationindex(string, optional):physical_index:<name>orrehydration_index:<block_name>
Returns: Log attributes grouped into two categories:
- Log Attributes: Standard log fields like service, severity, body, level, etc.
- Resource Attributes: Resource-related fields prefixed with “resource_” like resource_k8s.pod.name, resource_service.name, etc.
-
get_log_attributes_for_pipeline: Returns log fields present after applying a pipeline, each with the exactfilter_fieldforget_logsconditions. Scoped to your pipeline — use after a filter stage and before buildingget_logsqueries.View parameters
pipeline(array, required): In-progress pipeline, such as aServiceNamefilter stagelookback_minutes(integer, optional): Default: 15start_time_iso/end_time_iso(string, optional): RFC3339 time boundsregion(string, optional): Region to queryindex(string, optional):physical_index:<name>orrehydration_index:<block_name>
Returns: Each entry includes
name,filter_field(use directly inget_logs),hint, and optionalsource/sample_coverage. Body-derived fields (source: body) require a parse stage before filtering.
Traces management
-
get_traces: Execute advanced trace queries using JSON pipeline syntax for complex filtering and aggregation. This tool provides powerful querying capabilities for traces using a pipeline-based approach with filters, aggregations, and transformations.View parameters
tracejson_query(array, required): JSON pipeline query for traces. Fetch the full DSL from thelast9://reference/tracejsonresource or discover fields withget_trace_attributes_for_pipelinefirststart_time_iso(string, optional): Start time in RFC3339 formatend_time_iso(string, optional): End time in RFC3339 formatlookback_minutes(integer, optional): Number of minutes to look back from now. Default: 60limit(integer, optional): Maximum number of results to return. Default: 5000
Notes:
- Existence checks use
{"$neq": [field, ""]}—$existsand$notnullare not supported aggregateandwindow_aggregatepipelines run as a single request (not chunked)- A
408response means the window is too wide — narrow the time range and retry
-
get_service_traces: Retrieve traces from Last9 by trace ID or service name. Get specific traces either by providing a trace ID for a single trace, or by providing a service name to get all traces for that service within a time range.View parameters
trace_id(string, optional): Specific trace ID to retrieve. Cannot be used with service_nameservice_name(string, optional): Name of service to get traces for. Cannot be used with trace_idlookback_minutes(integer, optional): Number of minutes to look back from now. Default: 4320 fortrace_id, 60 forservice_namestart_time_iso(string, optional): Start time in RFC3339 format. Leave empty to use lookback_minutesend_time_iso(string, optional): End time in RFC3339 format. Leave empty to default to current timelimit(integer, optional): Maximum number of traces to return. Default: 10env(string, optional): Environment filter. Useget_service_environmentsto get available environments
Usage rules:
- Exactly one of
trace_idorservice_namemust be provided (not both, not neither) - Use
lookback_minutesor ISO time bounds with either lookup. ISO bounds overridelookback_minutes
Returns trace data including trace IDs, spans, duration, timestamps, and status information.
-
get_trace_attributes: Identify all available trace attributes within a specified time window for use in filtering and querying. Returns the global tag catalog.View parameters
lookback_minutes(integer, optional): Number of minutes to look back from now for the time window. Default: 15start_time_iso(string, optional): Start time in RFC3339 format. Leave empty to use lookback_minutesend_time_iso(string, optional): End time in RFC3339 format. Leave empty to default to current timeregion(string, optional): AWS region to query. Leave empty to use default from configuration
-
get_trace_attributes_for_pipeline: Returns trace attributes present after applying a pipeline, each with the exactfilter_fieldforget_tracesconditions. Scoped to your pipeline — use after a filter stage and before filtering on attribute keys.View parameters
pipeline(array, required): In-progress pipeline, such as aServiceNamefilter stagelookback_minutes(integer, optional): Default: 15start_time_iso/end_time_iso(string, optional): RFC3339 time boundsregion(string, optional): Region to query
Returns: Each entry includes
name,semantic_name,type, andfilter_fieldready to use inget_tracesconditions. -
get_trace_attribute_values: Fetch distinct values for a single trace attribute. Use afterget_trace_attributesorget_trace_attributes_for_pipelineto see what values exist (environments, HTTP methods, team names, etc.).View parameters
tag_name(string, required): Trace tag namepipeline(array, optional): Pipeline to filter the spans used for value discoveryregion(string, optional): Region to query
Uses a fixed recent discovery window.
-
get_trace_waterfall: Retrieve one exact trace as a bounded parent/child waterfall with millisecond timing, interval-correct self-time, slowest spans, and largest self-time contributors. Does not compute a critical path or claim root cause.View parameters
trace_id(string, required): Exact trace IDenvironment(string, optional): Exact deployment environmentstart_time_iso/end_time_iso(string, optional): RFC3339 time boundslookback_minutes(integer, optional): Default: 4320 (for exact trace lookup)selected_span_id(string, optional): Include attributes, events, and links for this span onlymax_spans(integer, optional): Default: 500, maximum: 1000
Returns: An
investigation-evidence/v1envelope with the waterfall underdata, plusevidence_quality, truncation warnings, and graph integrity warnings (cycles, orphans, duplicate spans). An empty result hasevidence_quality: insufficient— widen the window or verify the trace ID before concluding the trace does not exist. -
get_trace_attribute_deviations: Compare attribute-value distributions between two bounded span cohorts and rank supported differences. Use for slow vs fast, error vs non-error, or two equal-duration time windows. Results describe correlation, not cause.View parameters
comparison_mode(string, required):latency,errors, ortimeservice_name(string, required): Exact service nameenvironment(string, required): Exactdeployment.environmentvalueoperation(string, optional): Exact operation/span namefilters(array, optional): Trace JSON filter conditions — discover valid fields withget_trace_attributes_for_pipelinefirstcandidate_attributes(array, optional): Up to 8 attribute names; omit for bounded auto-discoverylatency_threshold_ms(number, required forlatencymode): Positive threshold in millisecondsstart_time_iso/end_time_iso(string, optional): Target window in RFC3339lookback_minutes(integer, optional): Alternative target lookback ending now. Default: 15, maximum: 15baseline_start_time_iso/baseline_end_time_iso(string, required fortimemode): Non-overlapping baseline window equal in duration to the target windowminimum_cohort_size(integer, optional): Default: 100, minimum: 20minimum_value_support(integer, optional): Default: 20, minimum: 10limit(integer, optional): Default: 10, maximum: 10
Returns: Full-denominator shares, percentage-point deltas, representative trace IDs, and
evidence_quality. Requires the trace-analysis capability to be enabled for your tenant.
Alert management
Use get_alert_groups to discover alert groups and get_entity_alert_rules to list rules for a selected entity.
-
get_alert_config: Get all configured alert rules from Last9. Supports typed filters and free-text search.View parameters and returns
Optional filters:
rule_id,search_term,rule_name,severity,rule_type(staticoranomaly)alert_group_name,alert_group_type,data_source_name,tagsonly_without_notification_channel: Rules whose alert group has no per-entity channel binding (Alert Studio “Not configured”)notification_channel_types: Rules with a per-entity channel of any listed type (e.g.slack,email,pagerduty)notification_channel_names: Rules with a per-entity channel matching any listed name (AND-combined with othernotification_channel_*filters on the same binding row)notification_channel_severities: Rules with a per-entity channel matching any listed severity (breachorthreat)
Returns per rule:
- Alert rule ID, name, primary indicator, entity ID, state, severity, algorithm
- Alert group
name,data_source, andtagswhen resolved - Notification Channels: configured types in dashboard order, or “Not configured”
- Notification Channel Bindings: each binding row (type, name, severity) with snooze/in_use flags
- Timestamps for creation/updates
-
get_alerts: Get currently active alerts from the Last9 monitoring system.View parameters and returns
Parameters:
time_iso(string, optional): Evaluation time in RFC3339 formattimestamp(integer, optional): Deprecated Unix timestamp aliaswindow(integer, optional): Time window in seconds. Default: 900 seconds, range: 1-3600lookback_minutes(integer, optional): Window in minutes whenwindowis omitted. Range: 1-60
Returns:
- Alert rule details
- Alert state and severity
- Firing timestamps
- Rule configurations
- Metric degradation information
- Group labels and annotations
-
get_notification_channels: Get all notification channel configurations from Last9.Returns
Returns all notification channels as a table with the following columns:id,name,typeservice_fqid: per-entity alert-group binding IDglobal: whether the channel applies to all servicesin_use: whether the channel is actively used in an alert rulesend_resolved: whether resolved alerts trigger a notification (true/false/nullif not set)snoozed_until: UTC timestamp if the channel is snoozed,-otherwiseseverity,priorityservices: comma-separatednamespace/namepairs,-if the channel is global
-
get_alert_rule_state: Get historical firing state (1/0) per alert rule over a time range, grouped byrule_id.View parameters
start_time(integer, required): Unix epoch start of the range (inclusive)end_time(integer, required): Unix epoch end of the range (inclusive)step(integer, required): Resolution in seconds between samplesalert_group_id(string, optional): Filter by alert group IDrule_name(string, optional): Regex filter on rule namealert_group_name(string, optional): Regex filter on alert group namelabel_filters(string, optional): Comma-separatedkey=valuelabel filtersstate(string, optional): Filter by state (e.g.firing)
Returns: JSON map of
rule_id→[{timestamp, is_firing}]. Sample count is capped at 100.
Custom dashboards
-
list_dashboards: List all custom dashboards in your Last9 organization.Returns
- JSON array of dashboard summaries:
id,name, and metadata reference_urlin MCP metadata linking to the dashboards index in the Last9 UI
- JSON array of dashboard summaries:
-
get_dashboard: Get the full definition of a custom dashboard by ID.View parameters and returns
Parameters:
id(string, required): Dashboard UUIDregion(string): Region for panel query population. Optional when a default datasource region is configured
Returns:
- Full dashboard JSON including
name,panels[], andmetadata - Each panel includes
layout,visualization.type, andqueries[] reference_urlin MCP metadata linking directly to the dashboard
-
create_dashboard: Create a new custom dashboard with panels and queries.View parameters
dashboard(object, required): Dashboard definition withnameandpanels[]. Each panel requiresname,layout(x,y,w,h),visualization.type, andqueries[]. A panelversiondefaults to1when omittedmetadata(object, optional): Dashboard metadata —_categoryand_typefields (e.g.{"_category":"custom","_type":"metrics"})
Returns the created dashboard JSON with its assigned
idand areference_urlto open it in the Last9 UI. -
update_dashboard: Update an existing custom dashboard by ID.View parameters
id(string, required): Dashboard UUID to updatedashboard(object, required): Full replacement dashboard body (same shape ascreate_dashboard)metadata(object, optional): Replacement metadata
Readonly system dashboards return a 403 error. Returns updated dashboard JSON with
reference_url. -
delete_dashboard: Delete a custom dashboard by ID.View parameters
id(string, required): Dashboard UUID to delete
Readonly system dashboards cannot be deleted. Returns a
reference_urlto the dashboards index. -
list_dashboard_snapshots: List frozen point-in-time snapshots for a dashboard.View parameters
dashboard_id(string, required): Dashboard UUID
Returns: Snapshot metadata (
id,name,expires_at). Useget_dashboard_snapshotfor full panel data. -
get_dashboard_snapshot: Get a frozen dashboard snapshot by ID, including panel data at capture time.View parameters
id(string, required): Snapshot UUID
Returns: Full frozen snapshot with
dashboard_definition,panel_data,time_range, andvariables. -
delete_dashboard_snapshot: Delete a frozen dashboard snapshot by ID.View parameters
id(string, required): Snapshot UUID to delete
Entity discovery
Use get_service_profile before choosing telemetry tools for a service. It returns the service’s available signals and investigation context. Supply the required service_name and, optionally, a datasource.
-
did_you_mean: Suggests correct entity names when you’re unsure of the exact spelling. Use this proactively before querying with a name that might be a typo, abbreviation, or partial match.View parameters
query(string, required): The name to search for — can be a partial name, misspelling, or abbreviationtype(string, optional): Restrict suggestions to a specific entity type. Supported values:service,environment,host,database,k8s_deployment,k8s_namespace,job
Returns up to 3 closest matches with similarity scores (0–100%) from the Last9 catalog, covering services, environments, hosts, databases, Kubernetes workloads, and more.
When to use:
- Before calling
get_service_logs,get_service_traces,get_service_performance_details, etc. with a service name that might be misspelled (e.g."paymnt-svc","prod-srvice") - When a previous tool call returned empty results for a given entity name
- When the user provides an ambiguous or abbreviated name (e.g.
"the payment thing"or"prod env")
Example results:
query="paymnt-svc"→payment-service (92%, service)query="prod"→production (89%, environment),prod-eu (82%, environment)
Demos
-
Fixing a recent exception
-
Optimizing logs for a service
-
Creating an RCA basis recent issues in the production environment
-
Analyze background worker processes
Best practices
- Name the service and environment. Use
get_service_profileto identify the available telemetry before choosing investigation tools. - Provide the incident window. Prefer absolute UTC start and end times when returning to an earlier incident.
- Discover fields before filtering. Use
get_log_attributes_for_pipelineandget_trace_attributes_for_pipelineto find valid field names. - Choose a trace tool for the question. Use
get_trace_waterfallfor one trace’s timing andget_trace_attribute_deviationsto compare groups of spans. - Limit automation tools. Set a read-tool allowlist in your agent. Self-hosted servers can also use
LAST9_TOOLSETS=investigateto expose investigation tools.
Troubleshooting
- “Last9 tools not available”: Verify your IDE configuration and restart the application
- OAuth flow not completing: Ensure you are logged in to app.last9.io before authorizing. If redirected to a 404, try logging in to the dashboard first and then re-initiating the OAuth flow from your IDE
- “Authentication failed” or “401 Unauthorized”: Reauthorize a hosted OAuth connection. For programmatic access, check the MCP client token. For a local server, check
LAST9_REFRESH_TOKEN. - “No data returned”: Ensure your services are sending telemetry to Last9 and try broader time ranges
- “Connection issues”: Double-check:
- Your organization slug is correct. Find it in
app.last9.io/v2/organizations/<org_slug>/.... - The URL format:
https://app.last9.io/api/v4/organizations/<org_slug>/mcp
- Your organization slug is correct. Find it in
Please get in touch with us on Discord or Email if you have any questions.