Skip to content
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

Add Logfire MCP server documentation #925

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
70 changes: 70 additions & 0 deletions docs/how-to-guides/mcp-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Logfire MCP Server

**Logfire** has its own [MCP server](https://modelcontextprotocol.io/introduction), which
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like there should be a link to https://github.com/pydantic/logfire-mcp. Note that https://pypi.org/project/logfire-mcp/ doesn't link there either. And there should be a mention of the package. It's just sort of implied below that you're using uvx logfire-mcp or otherwise installing logfire-mcp. Initially I didn't look closely and thought that command came with the logfire package.

About the docs and the command:

https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens doesn't work well. For me it links to a random project that I was invited to recentlyish but isn't mine and which I haven't looked at in ages. Rather link to the docs about read tokens. Also include that link here.

--logfire-read-token is very long for a required argument. I suggest --token/-t or at least --read-token.

logfire-mcp: error: Logfire read token must be provided either via --logfire-read-token argument or LOGFIRE_READ_TOKEN environment variable

this should also link to docs about read tokens.

When I run the command successfully it doesn't say anything so I can't tell if it's working properly. I have to press Ctrl+C three times to make it stop. And doing that makes it look like something bad happened:

KeyboardInterrupt
^CException ignored in: <module 'threading' from '/Users/alex/.pyenv/versions/3.12.6/lib/python3.12/threading.py'>
Traceback (most recent call last):
  File "/Users/alex/.pyenv/versions/3.12.6/lib/python3.12/threading.py", line 1624, in _shutdown
    lock.acquire()
KeyboardInterrupt: 
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x0000000100ef1770)

Current thread 0x00000001ea2e8840 (most recent call first):
  <no Python frame>
[1]    1700 abort      logfire-mcp --logfire-read-token 

you can use on [Claude Desktop](https://www.anthropic.com/news/claude-desktop),
[Cursor](https://www.cursor.com/), and any other software that supports MCP Servers.

## Connect to the MCP server

Here's how to connect different clients to the MCP server:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page doesn't tell me what MCP is, what Cursor/Cline/Claude Desktop is, or why I should care about any of this. Opening https://modelcontextprotocol.io/introduction starts with:

MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.

which doesn't really help. This page is linked at the top of the how-to guides which makes it seem really important so this needs to be clearer. Even someone who knows about MCP and Cursor and uses those things has to guess what this particular server does. Needs to say something like "Let your AI IDE query your logs and find bugs for you".


### Cursor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to start with an example that doesn't require setting up a whole IDE for people who are mcp-curious. Like a simple CLI command that I can easily install and run in my project directory. Something where we can show a screenshot or something of the output fairly easily for people who want to see results without running any steps themselves.


You can configure Cursor 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 `--logfire-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

In Claude Desktop, go to Settings → Advanced and add the following MCP configuration:
```json
{
"command": ["logfire-mcp"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing uvx or any mention of installation.

"type": "stdio",
"env": {
"LOGFIRE_READ_TOKEN": "your_token"
}
}
```

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

### Cline

When using [Cline](https://docs.cline.bot/), you can configure the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says

Cline Documentation
Welcome to the Cline documentation - your comprehensive guide to using and extending Cline's capabilities. Here you'll find resources to help you get started, improve your skills, and contribute to the project.

I still don't know what Cline is.

`cline_mcp_settings.json` file to connect to the MCP server:

```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 @@ -84,6 +84,7 @@ nav:
- Alerts (Beta): guides/web-ui/alerts.md
- SQL Explorer: guides/web-ui/explore.md
- How To - Guides:
- Connect to the MCP Server: how-to-guides/mcp-server.md
- Create Write Tokens: how-to-guides/create-write-tokens.md
- Use different environments: how-to-guides/environments.md
- Link to Code Source: how-to-guides/link-to-code-source.md
Expand Down