Skip to content

Add Logfire MCP server documentation #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions docs/how-to-guides/mcp-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Logfire MCP Server

An [MCP (Model Context Protocol) server](https://modelcontextprotocol.io/introduction) 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](https://github.com/pydantic/logfire-mcp) repository
for more information.

## Usage

The MCP server is a CLI tool that you can run from the command line.

You'll need a read token to use the MCP server. See
[Create Read Token](./query-api.md#how-to-create-a-read-token) for more information.

You can then start the MCP server with the following command:

```bash
LOGFIRE_READ_TOKEN=<your-token> uvx logfire-mcp
```

!!! note
The `uvx` command will download the PyPI package [`logfire-mcp`](https://pypi.org/project/logfire-mcp/),
and run the `logfire-mcp` command.

### Configuration

The way to configure the MCP server depends on the software you're using.

#### Cursor

[Cursor](https://www.cursor.com/) is a popular IDE that supports MCP servers. You can configure
it by creating a `.cursor/mcp.json` file in your project root:

```json
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": ["logfire-mcp", "--logfire-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](https://docs.cursor.com/context/model-context-protocol).

### Claude Desktop

[Claude Desktop](https://claude.ai/download) 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:

```json
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": [
"logfire-mcp",
],
"env": {
"LOGFIRE_READ_TOKEN": "your_token"
}
}
}
}
```

Check out the [MCP quickstart](https://modelcontextprotocol.io/quickstart/user)
for more information.

### Cline

[Cline](https://docs.cline.bot/) 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:

```json
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": [
"logfire-mcp",
],
"env": {
"LOGFIRE_READ_TOKEN": "your_token"
},
"disabled": false,
"autoApprove": []
}
}
}
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ nav:
- Detect Service is Down: how-to-guides/detect-service-is-down.md
- Suppress Spans and Metrics: how-to-guides/suppress.md
- OpenTelemetry Collector: how-to-guides/otel-collector.md
- Connect to the MCP Server: how-to-guides/mcp-server.md
- Integrations:
- Integrations: integrations/index.md
- LLMs:
Expand Down