The Pydantic Logfire MCP server allows LLMs to retrieve and analyze your application's telemetry data from Pydantic Logfire, including distributed traces, exceptions, and custom SQL query results.
First, make sure uv is installed as it's required to run the MCP server:
# Follow uv installation instructions at:
# https://docs.astral.sh/uv/getting-started/installation/
If you already have uv, you may need to update it:
uv self update
You'll need a read token to access the Pydantic Logfire APIs:
Run the server using uvx (provided by uv) with your read token:
LOGFIRE_READ_TOKEN=YOUR_READ_TOKEN uvx logfire-mcp@latest
Alternatively, specify the token as a command-line argument:
uvx logfire-mcp@latest --read-token=YOUR_READ_TOKEN
Or use a .env file in your working directory:
LOGFIRE_READ_TOKEN=pylf_v1_us_...
If using a self-hosted Logfire installation, specify the base URL:
LOGFIRE_BASE_URL=https://logfire.my-company.com 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"]
}
}
}
Run this command:
claude mcp add logfire -e LOGFIRE_READ_TOKEN=YOUR_TOKEN -- uvx logfire-mcp@latest
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:
{
"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
}
}
}
Retrieve details about recent exceptions in a specific file:
{
"name": "find_exceptions_in_file",
"arguments": {
"filepath": "app/api.py",
"age": 1440
}
}
Execute custom SQL queries against the Logfire database:
{
"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
}
}
Create links to view traces in the Logfire UI:
{
"name": "logfire_link",
"arguments": {
"trace_id": "1234567890abcdef"
}
}
Get the database schema for the Logfire DataFusion database:
{
"name": "schema_reference"
}
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.json2. 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