Metadata-Version: 2.4
Name: logfire-cli
Version: 0.1.4
Summary: The command-line interface for Pydantic Logfire.
Home-page: https://pydantic.dev/logfire
Project-URL: Documentation, https://pydantic.dev/docs/logfire/
Project-URL: Source, https://github.com/pydantic/logfire-cli
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8

# Logfire CLI

The Rust command-line interface for [Pydantic Logfire](https://pydantic.dev/logfire).
Sign in, query your traces and logs, manage projects and tokens, and connect your
coding agent to Logfire from the terminal.

This package installs the native CLI, not the Python instrumentation SDK.
Install an application SDK separately to send telemetry; see the
[Logfire documentation](https://pydantic.dev/docs/logfire/).

## Install

Try it with [uv](https://docs.astral.sh/uv/):

```bash
uvx logfire-cli --help
```

Install it as an isolated command-line tool:

```bash
uv tool install logfire-cli
logfire --help
```

Or use `pipx install logfire-cli`. In an activated virtual environment, you can
also run `python -m pip install logfire-cli`.

The package provides both `logfire` and `logfire-cli`. If another package already
provides a `logfire` command, use `logfire-cli` or `uvx logfire-cli` to select this
CLI explicitly.

Python 3.9 or newer is required for the launcher. Wheels include the matching
prebuilt binary for macOS (Apple Silicon and Intel), GNU/Linux (ARM64 and x86-64),
and Windows (x86-64). You do not need Rust installed. Alpine/musl and Windows ARM64
do not currently have native wheels.

## Sign in and query

Use your real organization name in place of `acme`, and `eu` instead of `us` if
your data is in the EU region:

```bash
logfire --region us --org acme auth
logfire --org acme mcp projects
```

Complete sign-in and approve access in your browser. OAuth credentials are stored
in the OS credential store, scoped to the Logfire origin and organization.

Choose a project from the list, then query its data through the hosted Model
Context Protocol (MCP) server:

```bash
logfire --org acme mcp query run 'SELECT message FROM records LIMIT 20' --project my-app
```

For scripts, make the target explicit and request non-interactive JSON output:

```bash
logfire --org acme --no-input --output json mcp projects
```

## Connect a local project

From your application's directory, connect an existing project. This creates an
SDK write token and saves it in `.logfire/logfire_credentials.json`:

```bash
logfire --org acme init use --name my-app --permission send
logfire project current
```

OAuth remains in the OS credential store; the SDK token stays with the local
project. Keep credential files out of version control.

To create additional read or write tokens for that project:

```bash
logfire --org acme token read
logfire --org acme token write
```

Each command creates a new token and prints the secret once to standard output.
Store it securely; do not paste it into logs, issues, or chat. These commands do
not replace the project's saved SDK write token.

## Run Python with automatic instrumentation

The CLI selects the active project interpreter and delegates instrumentation to
the Logfire Python SDK installed in that environment:

```bash
logfire run app.py
logfire run -m uvicorn main:app
logfire run pytest tests/
```

Use `--python .venv/bin/python` when interpreter discovery is ambiguous. See
[`logfire run`](commands/run.md) for selection rules and passthrough behavior.

## Set up instrumentation with a coding agent

With Codex or Claude Code installed, run this from your application's directory:

```bash
logfire --region us --org acme setup
```

The CLI detects installed agents and hands off the Logfire setup instructions
bundled with this release. The agent can change your project to add
instrumentation, using its normal permission and approval controls.

Authenticated product links can preserve a known project and setup job:

```bash
logfire --region us --org acme setup --project api --task instrumentation
```

Public and getting-started pages should normally keep using bare `setup`; the
contextual flags are for flows that already know the exact account target.

To inspect the instructions without launching an agent:

```bash
logfire --region us --org acme setup --print-prompt
```

## Help and updates

```bash
logfire help
logfire help mcp
logfire help setup
uv tool upgrade logfire-cli
```

Use the upgrade command for a `uv tool install` installation; otherwise upgrade
with the package manager you used to install it.

See the [Logfire documentation](https://pydantic.dev/docs/logfire/) for application
instrumentation and platform guides. Logfire CLI is licensed under the MIT license.
