Skip to content

Logfire MCP Server

An MCP (Model Context Protocol) server that provides access to OpenTelemetry traces and metrics through Logfire. This server enables LLMs to query your application's telemetry data, analyze distributed traces, and perform custom queries using Logfire's OpenTelemetry-native API.

You can check the Logfire MCP server repository for more information.

Installation

The MCP server is a CLI tool that you can run from the command line.

You'll need a read token to use the MCP server. See Create Read Token for more information.

You can then start the MCP server with the following command:

LOGFIRE_READ_TOKEN=<your-token> uvx logfire-mcp

Note

The uvx command will download the PyPI package logfire-mcp, and run the logfire-mcp command.

Configuration

The way to configure the MCP server depends on the software you're using.

Note

If you are in the EU region, you need to set the LOGFIRE_BASE_URL environment variable to https://api-eu.pydantic.dev. You can also use the --base-url flag to set the base URL.

Cursor

Cursor is a popular IDE that supports MCP servers. You can configure it by creating a .cursor/mcp.json file in your project root:

{
  "mcpServers": {
    "logfire": {
      "command": "uvx",
      "args": ["logfire-mcp", "--read-token=YOUR-TOKEN"],
    }
  }
}

Note

You need to pass the token via the --read-token flag, because Cursor doesn't support the env field in the MCP configuration.

For more detailed information, you can check the Cursor documentation.

Claude Desktop

Claude Desktop is a desktop application for the popular LLM Claude.

You can configure it to use the MCP server by adding the following configuration to the ~/claude_desktop_config.json file:

{
  "mcpServers": {
    "logfire": {
      "command": "uvx",
      "args": [
        "logfire-mcp",
      ],
      "env": {
        "LOGFIRE_READ_TOKEN": "your_token"
      }
    }
  }
}

Check out the MCP quickstart for more information.

Cline

Cline is a popular chatbot platform that supports MCP servers.

You can configure it to use the MCP server by adding the following configuration to the cline_mcp_settings.json file:

{
  "mcpServers": {
    "logfire": {
      "command": "uvx",
      "args": [
        "logfire-mcp",
      ],
      "env": {
        "LOGFIRE_READ_TOKEN": "your_token"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Tools

There are four tools available in the MCP server:

  1. find_exceptions(age: int) - Get exception counts from traces grouped by file.

    Required arguments:

    • age: Number of minutes to look back (e.g., 30 for last 30 minutes, max 7 days)
  2. find_exceptions_in_file(filepath: str, age: int) - Get detailed trace information about exceptions in a specific file.

    Required arguments:

    • filepath: Path to the file to analyze
    • age: Number of minutes to look back (max 7 days)
  3. arbitrary_query(query: str, age: int) - Run custom SQL queries on your OpenTelemetry traces and metrics.

    Required arguments:

    • query: SQL query to execute
    • age: Number of minutes to look back (max 7 days)
  4. get_logfire_records_schema() - Get the OpenTelemetry schema to help with custom queries.