GitHub - last9/last9-mcp-server: Last9 MCP Server (original) (raw)

Last9 MCP Server

last9 mcp demo

A Model Context Protocol server implementation for Last9 that enables AI agents to seamlessly bring real-time production context — logs, metrics, and traces — into your local environment to auto-fix code faster.

Status

Works with Claude desktop app, or Cursor, Windsurf, and VSCode (Github Copilot) IDEs. Implements the following MCPtools:

Observability & APM Tools:

Prometheus/PromQL Tools:

Logs Management:

Traces Management:

Change Events:

Alert Management:

Tools Documentation

get_exceptions

Retrieves server-side exceptions over a specified time range.

Parameters:

get_service_summary

Get service summary over a given time range. Includes service name, environment, throughput, error rate, and response time. All values are p95 quantiles over the time range.

Parameters:

get_service_environments

Get available environments for services. Returns an array of environments that can be used with other APM tools.

Parameters:

Note: All other APM tools that retrieve service information (like get_service_performance_details, get_service_dependency_graph, get_service_operations_summary, get_service_summary) require an env parameter. This parameter must be one of the environments returned by this tool. If this tool returns an empty array, use an empty string "" for the env parameter.

get_service_performance_details

Get detailed performance metrics for a specific service over a given time range.

Parameters:

get_service_operations_summary

Get a summary of operations inside a service over a given time range. Returns operations like HTTP endpoints, database queries, messaging producer and HTTP client calls.

Parameters:

get_service_dependency_graph

Get details of the throughput, response times and error rates of incoming, outgoing and infrastructure components of a service. Useful for analyzing cascading effects of errors and performance issues.

Parameters:

prometheus_range_query

Perform a Prometheus range query to get metrics data over a specified time range. Recommended to check available labels first using prometheus_labels tool.

Parameters:

prometheus_instant_query

Perform a Prometheus instant query to get metrics data at a specific point in time. Typically should use rollup functions like sum_over_time, avg_over_time, quantile_over_time over a time window.

Parameters:

prometheus_label_values

Return the label values for a particular label and PromQL filter query. Similar to Prometheus /label_values call.

Parameters:

prometheus_labels

Return the labels for a given PromQL match query. Similar to Prometheus /labels call.

Parameters:

get_logs

Gets logs filtered by service name and/or severity level within a specified time range. This tool now uses the advanced v2 logs API with physical index optimization for better performance.

Note: This tool now requires a service_name parameter and internally uses the same advanced infrastructure as get_service_logs.

Parameters:

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 atLast9 Control Plane

Parameters:

get_alert_config

Get alert configurations (alert rules) from Last9. Returns all configured alert rules including their conditions, labels, and annotations.

Parameters:

None - This tool retrieves all available alert configurations.

Returns information about:

get_alerts

Get currently active alerts from Last9 monitoring system. Returns all alerts that are currently firing or have fired recently within the specified time window.

Parameters:

Returns information about:

get_service_logs

Get raw log entries for a specific service over a time range. This tool retrieves actual log entries including log messages, timestamps, severity levels, and other metadata. Useful for debugging issues, monitoring service behavior, and analyzing specific log patterns.

Parameters:

Filtering behavior:

Examples:

get_log_attributes

Get available log attributes (labels) for a specified time window. This tool retrieves all attribute names that exist in logs during the specified time range, which can be used for filtering and querying logs.

Parameters:

Returns:

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.

Parameters:

This tool supports complex queries with multiple filter conditions, aggregations, and custom processing pipelines for advanced trace analysis.

get_service_traces

Retrieve traces from Last9 by trace ID or service name. This tool allows you to 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.

Parameters:

Usage rules:

Examples:

Returns trace data including trace IDs, spans, duration, timestamps, and status information.

get_trace_attributes

Get available trace attributes (series) for a specified time window. This tool retrieves all attribute names that exist in traces during the specified time range, which can be used for filtering and querying traces.

Parameters:

Returns:

get_change_events

Get change events from the last9_change_events prometheus metric over a given time range. Returns change events that occurred in the specified time window, including deployments, configuration changes, and other system modifications.

Parameters:

Returns:

Each change event includes:

Common event types include: deployment, config_change, rollback, scale_up/scale_down, restart, upgrade/downgrade, maintenance, backup/restore, health_check, certificate, database.

Best practices:

  1. First call without event_name to get available_event_names
  2. Use exact event name from available_event_names for the event_name parameter
  3. Combine with other filters (service, environment, time) for precise results

Installation

You can install and run the Last9 Observability MCP server in several ways:

Local Installation

For local development and traditional STDIO usage:

Homebrew

Add the Last9 tap

brew tap last9/tap

Install the Last9 MCP CLI

brew install last9-mcp

NPM

Install globally

npm install -g @last9/mcp-server

Or run directly with npx

npx @last9/mcp-server

Configuration

Environment Variables

The Last9 MCP server requires the following environment variables:

Usage

Usage with Claude Desktop

Configure the Claude app to use the MCP server:

  1. Open the Claude Desktop app, go to Settings, then Developer
  2. Click Edit Config
  3. Open the claude_desktop_config.json file
  4. Copy and paste the server config to your existing file, then save
  5. Restart Claude

If installed via Homebrew:

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

If installed via NPM:

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

Usage with Cursor

Configure Cursor to use the MCP server:

  1. Open Cursor, go to Settings, then Cursor Settings
  2. Select MCP on the left
  3. Click Add "New Global MCP Server" at the top right
  4. Copy and paste the server config to your existing file, then save
  5. Restart Cursor

If installed via Homebrew:

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

If installed via NPM:

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

Usage with Windsurf

Configure Windsurf to use the MCP server:

  1. Open Windsurf, go to Settings, then Developer
  2. Click Edit Config
  3. Open the windsurf_config.json file
  4. Copy and paste the server config to your existing file, then save
  5. Restart Windsurf

If installed via Homebrew:

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

If installed via NPM:

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

Usage with VS Code

Note: MCP support in VS Code is available starting v1.99 and is currently in preview. For advanced configuration options and alternative setup methods,view the VS Code MCP documentation.

  1. Open VS Code, go to Settings, select the User tab, then Features, then Chat
  2. Click "Edit settings.json"
  3. Copy and paste the server config to your existing file, then save
  4. Restart VS Code

If installed via Homebrew:

{ "mcp": { "servers": { "last9": { "type": "stdio", "command": "/opt/homebrew/bin/last9-mcp", "env": { "LAST9_BASE_URL": "", "LAST9_AUTH_TOKEN": "", "LAST9_REFRESH_TOKEN": "", "OTEL_EXPORTER_OTLP_ENDPOINT": "", "OTEL_EXPORTER_OTLP_HEADERS": "" } } } } }

If installed via NPM:

{ "mcp": { "servers": { "last9": { "type": "stdio", "command": "npx", "args": ["-y", "@last9/mcp-server"], "env": { "LAST9_BASE_URL": "", "LAST9_AUTH_TOKEN": "", "LAST9_REFRESH_TOKEN": "", "OTEL_EXPORTER_OTLP_ENDPOINT": "", "OTEL_EXPORTER_OTLP_HEADERS": "" } } } } }

Development

For local development and testing, you can run the MCP server in HTTP mode which makes it easier to debug requests and responses.

Running in HTTP Mode

Set the HTTP_MODE environment variable to enable HTTP server mode:

Export required environment variables

export LAST9_API_TOKEN="your_api_token" export LAST9_BASE_URL="https://your-last9-endpoint" # Your Last9 endpoint export OTEL_EXPORTER_OTLP_ENDPOINT="" export OTEL_EXPORTER_OTLP_HEADERS="" export HTTP_MODE=true export HTTP_PORT=8080 # Optional, defaults to 8080

Run the server

./last9-mcp-server

The server will start on http://localhost:8080/mcp and you can test it with curl:

Testing with curl

Test get_service_logs

curl -X POST http://localhost:8080/mcp
-H "Content-Type: application/json"
-H "Mcp-Session-Id: session_$(date +%s)000000000"
-d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "get_service_logs", "arguments": { "service_name": "your-service-name", "lookback_minutes": 30, "limit": 10 } } }'

Test get_service_traces

curl -X POST http://localhost:8080/mcp
-H "Content-Type: application/json"
-H "Mcp-Session-Id: session_$(date +%s)000000000"
-d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "get_service_traces", "arguments": { "service_name": "your-service-name", "lookback_minutes": 60, "limit": 5 } } }'

List available tools

curl -X POST http://localhost:8080/mcp
-H "Content-Type: application/json"
-H "Mcp-Session-Id: session_$(date +%s)000000000"
-d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/list", "params": {} }'

Building from Source

Clone the repository

git clone https://github.com/last9/last9-mcp-server.git cd last9-mcp-server

Build the binary

go build -o last9-mcp-server

Run in development mode

HTTP_MODE=true ./last9-mcp-server

Note: HTTP mode is for development and testing only. When integrating with Claude Desktop or other MCP clients, use the default STDIO mode (without HTTP_MODE=true).

Badges

MseeP.ai Security Assessment Badge