The Logfire MCP Server allows LLMs to retrieve and analyze OpenTelemetry traces and metrics data, providing insights into application telemetry. You can:
- Find Exceptions: Retrieve exception counts grouped by file using
find_exceptions
- Get Exception Details: Access detailed trace information about exceptions in specific files with
find_exceptions_in_file
- Run Custom Queries: Execute arbitrary SQL queries on your OpenTelemetry data via
arbitrary_query
- Access Schema: View the OpenTelemetry schema to help with query construction using
get_logfire_records_schema
The server supports analysis of distributed traces and metrics for time periods up to 7 days.
Enables access and analysis of OpenTelemetry traces and metrics data stored in Logfire, with tools for finding exceptions, retrieving trace information, and executing SQL queries against telemetry data.
Integrates with Logfire, a Pydantic service, to retrieve and analyze application telemetry data through the Logfire APIs using read tokens from the Logfire project settings.
Pydantic Logfire MCP Server
This repository contains a Model Context Protocol (MCP) server with tools that can access the OpenTelemetry traces and metrics you've sent to Pydantic Logfire.
This MCP server enables LLMs to retrieve your application's telemetry data, analyze distributed traces, and make use of the results of arbitrary SQL queries executed using the Pydantic Logfire APIs.
Available Tools
find_exceptions_in_file
- Get detailed trace information about exceptions in a specific file- Required arguments:
filepath
(string): Path to the file to analyzeage
(int): Number of minutes to look back (max 7 days)
- Required arguments:
arbitrary_query
- Run custom SQL queries on your OpenTelemetry traces and metrics- Required arguments:
query
(string): SQL query to executeage
(int): Number of minutes to look back (max 7 days)
- Required arguments:
get_logfire_records_schema
- Get the OpenTelemetry schema to help with custom queries- No required arguments
logfire_link
- Get a link to the trace in Pydantic Logfire- Required arguments:
trace_id
(string): The trace ID to link to
- Required arguments:
Setup
Install uv
The first thing to do is make sure uv
is installed, as uv
is used to run the MCP server.
For installation instructions, see the uv
installation docs.
If you already have an older version of uv
installed, you might need to update it with uv self update
.
Obtain a Pydantic Logfire read token
In order to make requests to the Pydantic Logfire APIs, the Pydantic Logfire MCP server requires a "read token".
You can create one under the "Read Tokens" section of your project settings in Pydantic Logfire: https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens
Important
Pydantic Logfire read tokens are project-specific, so you need to create one for the specific project you want to expose to the Pydantic Logfire MCP server.
Manually run the server
Once you have uv
installed and have a Pydantic Logfire read token, you can manually run the MCP server using uvx
(which is provided by uv
).
You can specify your read token using the LOGFIRE_READ_TOKEN
environment variable:
You can also set LOGFIRE_READ_TOKEN
in a .env
file:
NOTE: for this to work, the MCP server needs to run with the directory containing the .env
file in its working directory.
or using the --read-token
flag:
Note
If you are using Cursor, Claude Desktop, Cline, or other MCP clients that manage your MCP servers for you, you do NOT need to manually run the server yourself. The next section will show you how to configure these clients to make use of the Pydantic Logfire MCP server.
Base URL
If you are running Logfire in a self hosted environment, you need to specify the base URL.
This can be done using the LOGFIRE_BASE_URL
environment variable:
You can also use the --base-url
argument:
Configuration with well-known MCP clients
Configure for Cursor
Create a .cursor/mcp.json
file in your project root:
The Cursor doesn't accept the env
field, so you need to use the --read-token
flag instead.
Configure for Claude code
Run the following command:
Configure for Claude Desktop
Add to your Claude settings:
Configure for Cline
Add to your Cline settings in cline_mcp_settings.json
:
Configure for VS Code
Make sure you enabled MCP support in VS Code.
Create a .vscode/mcp.json
file in your project's root directory:
Configure for Zed
Create a .zed/settings.json
file in your project's root directory:
Example Interactions
- Get details about exceptions from traces in a specific file:
Response:
- Run a custom query on traces:
Examples of Questions for Claude
- "What exceptions occurred in traces from the last hour across all services?"
- "Show me the recent errors in the file 'app/api.py' with their trace context"
- "How many errors were there in the last 24 hours per service?"
- "What are the most common exception types in my traces, grouped by service name?"
- "Get me the OpenTelemetry schema for traces and metrics"
- "Find all errors from yesterday and show their trace contexts"
Getting Started
- First, obtain a Pydantic Logfire read token from: https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens
- Run the MCP server:
- Configure your preferred client (Cursor, Claude Desktop, or Cline) using the configuration examples above
- Start using the MCP server to analyze your OpenTelemetry traces and metrics!
Contributing
We welcome contributions to help improve the Pydantic Logfire MCP server. Whether you want to add new trace analysis tools, enhance metrics querying functionality, or improve documentation, your input is valuable.
For examples of other MCP servers and implementation patterns, see the Model Context Protocol servers repository.
License
Pydantic Logfire MCP is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A Model Context Protocol server that enables LLMs to retrieve and analyze OpenTelemetry traces and metrics from Logfire, supporting exception tracking and custom SQL queries against telemetry data.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to interact with Salesforce data through SOQL queries, SOSL searches, and various API operations including record management.Last updated -10131PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.Last updated -6823JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -1361TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -136MIT License