# logfire-mcp

> MCP Server

This repository hosts a Model Context Protocol (MCP) server that allows LLMs to access and analyze OpenTelemetry traces and metrics sent to Logfire, enabling analysis of distributed traces and custom SQL queries.

## Overview

- **Category:** System Tools
- **Language:** Python
- **Stars:** 162
- **Forks:** 0
- **Owner:** pydantic
- **GitHub:** https://github.com/pydantic/logfire-mcp
- **Created:** 2025-03-06T12:26:11+00:00
- **Updated:** 2025-03-28T02:35:21+00:00
- **Source:** https://model-context-protocol.com/servers/logfire-mcp-opentelemetry-trace-analysis

## Setup

## Setup

1.  Install `uv` following the instructions in the [`uv` installation docs](https://docs.astral.sh/uv/getting-started/installation/), updating if necessary with `uv self update`.
2.  Obtain a Logfire read token from the "Read Tokens" section of your project settings in Logfire: https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens.
3.  Manually run the server using `uvx` with the `LOGFIRE_READ_TOKEN` environment variable or the `--read-token` flag: `LOGFIRE_READ_TOKEN=YOUR_READ_TOKEN uvx logfire-mcp` or `uvx logfire-mcp --read-token=YOUR_READ_TOKEN`.
4.  Alternatively, configure your MCP client (Cursor, Claude Desktop, or Cline) using the provided configuration examples.
5.  Customize the base URL for the Logfire API using the `--base-url` argument or the `LOGFIRE_BASE_URL` environment variable.

## Tools

## Available Tools

1.  `find_exceptions` - Get exception counts from traces grouped by file.
2.  `find_exceptions_in_file` - Get detailed trace information about exceptions in a specific file.
3.  `arbitrary_query` - Run custom SQL queries on your OpenTelemetry traces and metrics.
4.  `get_logfire_records_schema` - Get the OpenTelemetry schema to help with custom queries.
