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.
Remote MCP Server (Recommended)¶
Pydantic Logfire provides a hosted remote MCP server that you can use without installing anything locally. This is the easiest way to get started with the Logfire MCP server.
To use the remote MCP server, add the following configuration to your MCP client.
Choose the endpoint that matches your Logfire data region:
For US region (logfire-us.pydantic.dev):
{
"mcpServers": {
"logfire": {
"type": "http",
"url": "https://logfire-us.pydantic.dev/mcp"
}
}
}
For EU region (logfire-eu.pydantic.dev):
{
"mcpServers": {
"logfire": {
"type": "http",
"url": "https://logfire-eu.pydantic.dev/mcp"
}
}
}
Note
The remote MCP server handles authentication automatically through your browser. When you first connect, you'll be prompted to authenticate with your Pydantic Logfire account.
Note
If you are running a self-hosted Logfire instance, replace the URL above with your own Logfire instance URL
(e.g., https://logfire.my-company.com/mcp), as the remote MCP server is hosted alongside your Logfire deployment.
Running Locally (Deprecated)¶
Warning
Running the MCP server locally is deprecated. Please use the Remote MCP Server instead. The local server will continue to work, but we recommend migrating to the remote server for a better experience.
If you prefer to run the MCP server locally, you can use the logfire-mcp package instead.
Installation¶
You'll need a read token to use the MCP server locally. 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@latest
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.
Claude Code¶
Claude Code is a coding tool that is used via CLI.
You can run the following command to add the Logfire MCP server to your Claude Code:
claude mcp add logfire -e LOGFIRE_READ_TOKEN="your-token" -- uvx logfire-mcp@latest
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:
-
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)
-
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 analyzeage: Number of minutes to look back (max 7 days)
-
arbitrary_query(query: str, age: int)- Run custom SQL queries on your OpenTelemetry traces and metrics.Required arguments:
query: SQL query to executeage: Number of minutes to look back (max 7 days)
-
get_logfire_records_schema()- Get the OpenTelemetry schema to help with custom queries.