The Pydantic Logfire MCP server provides tools to access and analyze OpenTelemetry traces and metrics from your Pydantic Logfire account. It enables LLMs to retrieve telemetry data, analyze distributed traces, and execute SQL queries using the Pydantic Logfire APIs.
find_exceptions_in_file - Get detailed trace information about exceptions in a specific file
filepath
(string): Path to the file to analyzeage
(int): Number of minutes to look back (max 7 days)arbitrary_query - Run custom SQL queries on your OpenTelemetry traces and metrics
query
(string): SQL query to executeage
(int): Number of minutes to look back (max 7 days)get_logfire_records_schema - Get the OpenTelemetry schema to help with custom queries
First, ensure you have uv
installed, as it's required 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:
uv self update
The server requires a "read token" to access your Pydantic Logfire data:
Once you have uv
installed and a read token, run the MCP server using:
LOGFIRE_READ_TOKEN=YOUR_READ_TOKEN uvx logfire-mcp@latest
Alternatively, you can provide the token via:
.env
file:LOGFIRE_READ_TOKEN=pylf_v1_us_...
--read-token
flag:uvx logfire-mcp@latest --read-token=YOUR_READ_TOKEN
Create a .cursor/mcp.json
file in your project root:
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": ["logfire-mcp@latest", "--read-token=YOUR-TOKEN"]
}
}
}
Add to your Claude settings:
{
"command": ["uvx"],
"args": ["logfire-mcp@latest"],
"type": "stdio",
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN"
}
}
Add to your cline_mcp_settings.json
:
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": ["logfire-mcp@latest"],
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN"
},
"disabled": false,
"autoApprove": []
}
}
}
Create a .vscode/mcp.json
file in your project's root:
{
"servers": {
"logfire": {
"type": "stdio",
"command": "uvx",
"args": ["logfire-mcp@latest"],
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN"
}
}
}
}
Create a .zed/settings.json
file:
{
"context_servers": {
"logfire": {
"source": "custom",
"command": "uvx",
"args": ["logfire-mcp@latest"],
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN"
},
"enabled": true
}
}
}
Run the following command:
claude mcp add logfire -- uvx logfire-mcp@latest --read-token=YOUR_TOKEN
Request:
{
"name": "find_exceptions_in_file",
"arguments": {
"filepath": "app/api.py",
"age": 1440
}
}
Response:
[
{
"created_at": "2024-03-20T10:30:00Z",
"message": "Failed to process request",
"exception_type": "ValueError",
"exception_message": "Invalid input format",
"function_name": "process_request",
"line_number": "42",
"attributes": {
"service.name": "api-service",
"code.filepath": "app/api.py"
},
"trace_id": "1234567890abcdef"
}
]
Request:
{
"name": "arbitrary_query",
"arguments": {
"query": "SELECT trace_id, message, created_at, attributes->>'service.name' as service FROM records WHERE severity_text = 'ERROR' ORDER BY created_at DESC LIMIT 10",
"age": 1440
}
}
You can ask your AI assistant questions like:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "logfire" '{"command":"uvx","args":["logfire-mcp@latest","--read-token=YOUR-TOKEN"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": [
"logfire-mcp@latest",
"--read-token=YOUR-TOKEN"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": [
"logfire-mcp@latest",
"--read-token=YOUR-TOKEN"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect