> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magpiedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Magpie is a trace store for AI agents, used as a library (crate `magpiedb`, npm `magpiedb`, PyPI `magpiedb`) or as `magpie-server`, which takes OpenTelemetry (OTLP over HTTP on 127.0.0.1:4318 and gRPC on 127.0.0.1:4317 by default).
> Use only the commands, flags, routes and JSON shapes that these pages show. Do not guess a flag or a query field: if a page does not show it, say that the docs do not show it.
> Packages and server binaries are not published yet: build from source, as the quick start shows. Check the status note on the introduction page before you suggest `cargo add`, `npm install` or `pip install`.
> Only one process may write to a store folder at a time. For many apps, send traces to one `magpie-server`.

# Quickstart

> Build Magpie, start the server, send a trace and ask questions. Or use the library in Rust, Node or Python.

Magpie stores the traces of AI agents. You can use it in two ways:

* **The server** (`magpie-server`). Your apps send OpenTelemetry traces to it. You ask questions over a JSON API.
* **The library** (`magpiedb`). It runs inside your app, like SQLite. There is no server. Rust, Node and Python.

Both use the same engine and the same store: one folder of files. Not sure which one to pick? Read [library or server](https://docs.magpiedb.com/library-or-server.md).

> [!WARNING]
>
> Magpie is not on crates.io, npm or PyPI yet, and release 0.1.0 is not out. Until it is, you build it from the repo. You need Rust (stable) and `curl`. For Node you also need Node 24; for Python you also need [`uv`](https://docs.astral.sh/uv/).

> [!NOTE]
>
> Every command and every answer in this quickstart was run on 2026-12-04 (macOS, Apple silicon, the code of `main`), except the download commands: they work only after the release (see below).

## Run the server

**1. Get the server**

**Download**

From release 0.1.0 on, every release has `magpie-server` ready to run, and a Docker image. **Release 0.1.0 is not out yet: until it is, these links answer 404, so build it (next part).** The same archives and image, built from the repo the way the release builds them, were run on 2026-12-04 and 2026-12-05: macOS arm64, macOS x64 (with Rosetta 2), Linux arm64 (in CentOS 7) and the arm64 image ([`docs/RELEASE.md`](https://github.com/intojhanurag/magpie/blob/main/docs/RELEASE.md), "What was checked for `magpie-server`"). Linux x64 and the amd64 image are built only by the release workflow.

| your system | `P` |
| - | - |
| macOS, Apple silicon (M1 and newer) | `macos-arm64` |
| macOS, Intel | `macos-x64` |
| Linux, x64 (glibc 2.17 or newer: most systems since 2014; not Alpine) | `linux-x64` |
| Linux, arm64 (glibc 2.17 or newer) | `linux-arm64` |

```sh theme={null}
mkdir -p ~/magpie-try && cd ~/magpie-try    # any empty folder
V=0.1.0 P=macos-arm64                       # the release, and your system from the table
curl -fLO "https://github.com/intojhanurag/magpie/releases/download/v$V/magpie-server-$V-$P.tar.gz"
curl -fLO "https://github.com/intojhanurag/magpie/releases/download/v$V/SHA256SUMS"
grep " magpie-server-$V-$P.tar.gz\$" SHA256SUMS | shasum -a 256 -c    # Linux without shasum: sha256sum -c
tar -xzf "magpie-server-$V-$P.tar.gz"
export PATH="$PWD/magpie-server-$V-$P:$PATH"
```

The check must print `magpie-server-0.1.0-macos-arm64.tar.gz: OK`. The folder holds `magpie-server`, `LICENSE` and a short `README.md`. Then go to step 2.

* macOS: the program is not signed with an Apple Developer ID. A download with `curl` starts as it is. A download with a browser gets a mark, and macOS refuses to start the program: remove the mark with `xattr -dr com.apple.quarantine magpie-server-$V-$P`.
* Every release, with its notes: [github.com/intojhanurag/magpie/releases](https://github.com/intojhanurag/magpie/releases).

**With Docker** (amd64 and arm64). This command takes the place of step 2:

```sh theme={null}
docker run --rm -p 127.0.0.1:4318:4318 -p 127.0.0.1:4317:4317 -v magpie-data:/data ghcr.io/intojhanurag/magpie-server:0.1.0
```

The store is in the volume `magpie-data`; the container runs as a user without rights, and has a health check. The tag `latest` is the newest release. Keys, TLS, Compose and Kubernetes: [the server reference, "Docker"](https://docs.magpiedb.com/reference/server.md#docker).

**Or build it**

Set `REPO` to the folder of the repo. Then build the server and put it on your `PATH`:

```sh theme={null}
export REPO=~/src/magpie                    # the folder of this repo
(cd "$REPO" && cargo build --release -p magpie-server)
export PATH="$REPO/target/release:$PATH"
mkdir -p ~/magpie-try && cd ~/magpie-try    # any empty folder
```

The first build takes some minutes.

**2. Start the server**

```sh theme={null}
magpie-server --dir ./traces
```

It prints one line and waits. Keep it open, and use a second terminal for the next steps.

```text theme={null}
magpie-server: store ./traces, 0 spans; no API keys; no price table; no mask policy. OTLP/HTTP and query API on http://127.0.0.1:4318, OTLP/gRPC on 127.0.0.1:4317. GenAI mapping v2 (semantic-conventions-genai v0.1.0). Viewer: http://127.0.0.1:4318/
```

* `./traces` is the store: one folder that holds all the data. The server makes it.
* Port 4318 takes OTLP over HTTP and the query API. Port 4317 takes OTLP over gRPC.
* By default the server listens on `127.0.0.1` only, and has no API keys. Before you open it to other machines, read [operations](https://docs.magpiedb.com/operations/overview.md).
* The server also serves a read-only viewer at `http://127.0.0.1:4318/` ([the viewer](#the-viewer), below).
* Ctrl-C stops the server. It closes the store. The data stays in `./traces`.

**3. Send a trace**

An app with an OpenTelemetry SDK needs no code change. Set two environment variables (more in [OpenTelemetry](https://docs.magpiedb.com/guides/opentelemetry.md)):

```sh theme={null}
export OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
```

To try it without an app, send OTLP as JSON with `curl`. This trace has two steps: a model call, and a tool call that failed.

```sh theme={null}
cat > trace.json <<'EOF'
{"resourceSpans": [{
  "resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "support-bot"}}]},
  "scopeSpans": [{"spans": [
    {"traceId": "5b8efff798038103d269b633813fc60c", "spanId": "eee19b7ec3c1b174",
     "name": "chat gpt-4o", "startTimeUnixNano": "1764500000000000000", "endTimeUnixNano": "1764500002000000000",
     "attributes": [
       {"key": "gen_ai.operation.name", "value": {"stringValue": "chat"}},
       {"key": "gen_ai.request.model", "value": {"stringValue": "gpt-4o"}},
       {"key": "gen_ai.usage.input_tokens", "value": {"intValue": "120"}},
       {"key": "gen_ai.usage.output_tokens", "value": {"intValue": "40"}},
       {"key": "user.id", "value": {"stringValue": "user-7"}},
       {"key": "gen_ai.prompt", "value": {"stringValue": "What is your refund policy?"}},
       {"key": "gen_ai.completion", "value": {"stringValue": "You can get a refund within 30 days."}}]},
    {"traceId": "5b8efff798038103d269b633813fc60c", "spanId": "eee19b7ec3c1b175", "parentSpanId": "eee19b7ec3c1b174",
     "name": "execute_tool lookup_order", "startTimeUnixNano": "1764500000500000000", "endTimeUnixNano": "1764500001000000000",
     "status": {"code": 2, "message": "order service timeout"},
     "attributes": [
       {"key": "gen_ai.operation.name", "value": {"stringValue": "execute_tool"}},
       {"key": "gen_ai.tool.call.arguments", "value": {"stringValue": "{\"order\": 4411}"}}]}
  ]}]}]}
EOF
curl -s localhost:4318/v1/traces -H 'content-type: application/json' -d @trace.json
sleep 2   # wait for the next commit
```

```json theme={null}
{}
```

`{}` means that every span is stored. A span can be found after the next commit (the `sleep 2`). The server commits every 0.5 s, and a commit takes some time too (in all, 1.1 to 1.2 s on the test machine while other builds ran).

**4. Ask questions**

**Find text.** How many steps have the phrase "refund policy"?

```sh theme={null}
curl -s localhost:4318/v1/count -d '{"filter": {"text": {"phrase": "refund policy"}}}'
```

```json theme={null}
{"count":1}
```

**Ask about whole traces.** Which traces have a tool call that failed?

```sh theme={null}
curl -s localhost:4318/v1/traces/find -d '{"anySpan": [{"kind": "tool_call", "hasError": true}], "limit": 10}'
```

```json theme={null}
{"count":1,"traces":[{"traceId":"5b8efff798038103d269b633813fc60c","rootSpanId":"eee19b7ec3c1b174","startedAt":1764500000000,"endedAt":1764500002000,"name":"chat gpt-4o","userId":"user-7","sessionId":null,"spanCount":2,"errorCount":1,"inputTokens":120,"outputTokens":40,"costNanos":0}],"nextCursor":null}
```

**Add up numbers.** Tokens per model:

```sh theme={null}
curl -s localhost:4318/v1/aggregate -d '{"groupBy": {"field": "model"}, "metrics": ["inputTokens", "outputTokens"]}'
```

```json theme={null}
{"rows":[{"count":1,"key":null,"sums":[0,0]},{"count":1,"key":"gpt-4o","sums":[120,40]}]}
```

The row with `"key": null` is the tool call: it has no model.

**Search the errors.** How many steps failed with the word "timeout" in the error?

```sh theme={null}
curl -s localhost:4318/v1/count -d '{"filter": {"errorText": {"words": "timeout"}}}'
```

```json theme={null}
{"count":1}
```

**Read the trace.** Every step, with its text:

```sh theme={null}
curl -s localhost:4318/v1/traces/5b8efff798038103d269b633813fc60c | head -c 300; echo
```

```text theme={null}
{"spans":[{"traceId":"5b8efff798038103d269b633813fc60c","spanId":"eee19b7ec3c1b174",...
```

Every query type, with examples: [queries](https://docs.magpiedb.com/queries/overview.md).

## The viewer

Open `http://127.0.0.1:4318/` in a browser (the server of step 2). With the trace of step 3:

* The list shows 1 trace, `chat gpt-4o`, with a red dot: one of its steps failed. Above the table, the numbers of the traces in the list: failed, typical time, the slow 1 in 20, tokens, cost, and bars of the traces in time.
* Type `"refund policy"` in the search box and press Enter: "1 match your search", and the phrase is marked yellow. The box also takes `refu*` (a word that starts so), `*fund*` (a piece of a word), `model:gpt-4o`, `user:user-7` and `is:error`. `+ Filter` adds the same as chips; the chip on the left picks a time range.
* Click the trace: its steps as a tree on a time axis (the failed tool call is red), and the selected step: its input and answer (tab Messages), the step as JSON (Raw), every field and attribute (Attributes). The box "Find in this span" marks every hit; Enter goes to the next one.
* "Sessions" at the top lists the conversations. The top right shows the size of the store; the round switch there picks light or dark (default: as your system).

The viewer only reads: it calls the query API. It calls no route that writes. With `--auth keys` it asks for a key with the `read` right and keeps it in that browser tab only. `--no-ui` turns it off. More: [the server reference, "Viewer"](https://docs.magpiedb.com/reference/viewer.md).

## Or: the library in your app

No server here. The store is a folder that your app opens. One process at a time may write to a folder.

> [tab] Node
>
> Build the package from the repo, then install it into your app:
>
> ```sh theme={null}
> (cd "$REPO/bindings/node" && npm ci && npm run build) > /dev/null
> mkdir -p my-node-app && cd my-node-app
> npm init -y > /dev/null && npm install "$REPO/bindings/node" > /dev/null
> cat > app.mjs <<'EOF'
> import { Store } from 'magpiedb'
>
> const store = await Store.open('./traces')
> await store.write([
>   { traceId: 't1', spanId: 's1', kind: 'agent_run', startedAt: Date.now(), input: 'please refund my order' },
>   { traceId: 't1', spanId: 's2', parentSpanId: 's1', kind: 'tool_call', startedAt: Date.now(), error: 'timeout' },
> ])
> await store.commit()
> const found = await store.findTraces({ anySpan: [{ text: { words: 'refund' } }], limit: 10 })
> console.log(found.count, found.traces[0].traceId, found.traces[0].spanCount)
> await store.close()
> EOF
> node app.mjs
> cd ..
> ```
>
> ```text theme={null}
> 1 t1 2
> ```
>
> The API of the package: [Node library](https://docs.magpiedb.com/libraries/node.md).

> [tab] Python
>
> Build the package into a virtual environment, then run your app with it:
>
> ```sh theme={null}
> (cd "$REPO/bindings/python" && uv venv --clear .venv && uv pip install --python .venv/bin/python "maturin>=1.9.4,<2" && .venv/bin/maturin develop --release --uv) > /dev/null 2>&1
> mkdir -p my-python-app && cd my-python-app
> cat > app.py <<'EOF'
> import time
> from magpiedb import Store
>
> now = int(time.time() * 1000)  # times are Unix milliseconds
> with Store.open("./traces") as store:
>     store.write([
>         {"traceId": "t1", "spanId": "s1", "kind": "agent_run", "startedAt": now, "input": "please refund my order"},
>         {"traceId": "t1", "spanId": "s2", "parentSpanId": "s1", "kind": "tool_call", "startedAt": now, "error": "timeout"},
>     ])
>     store.commit()
>     found = store.find_traces({"anySpan": [{"text": {"words": "refund"}}], "limit": 10})
>     print(found["count"], found["traces"][0]["traceId"], found["traces"][0]["spanCount"])
> EOF
> "$REPO/bindings/python/.venv/bin/python" app.py
> cd ..
> ```
>
> ```text theme={null}
> 1 t1 2
> ```
>
> Method names are in snake\_case (`find_traces`); the keys of the dicts are in camelCase (`anySpan`). The API: [Python library](https://docs.magpiedb.com/libraries/python.md).

> [tab] Rust
>
> ```sh theme={null}
> cargo new --quiet my-rust-app && cd my-rust-app
> cargo add --quiet magpiedb --path "$REPO/crates/core"
> cat > src/main.rs <<'EOF'
> use magpiedb::{Filter, Options, Span, Store, Text, TraceQuery};
>
> fn main() -> Result<(), magpiedb::Error> {
>     let store = Store::open("traces", Options::default())?;
>
>     let mut span = Span::new("trace-1", "span-1", "tool_call", 1_700_000_000_000);
>     span.input = "look up the refund policy".into();
>     span.error = Some("timeout".into());
>     store.upsert(vec![span])?; // write it again when the span ends: it replaces this version
>     store.commit()?;           // or wait: the store commits on a timer (0.5 s)
>
>     let hits = store.count(&Filter { text: Some(Text::phrase("refund policy")), ..Default::default() })?;
>     let failed = store.find_traces(&TraceQuery {
>         any_span: vec![Filter { kind: Some("tool_call".into()), has_error: Some(true), ..Default::default() }],
>         limit: 50,
>         ..Default::default()
>     })?;
>     println!("{hits} span with the phrase; failed tool calls in {} trace: {}", failed.count, failed.traces[0].trace_id);
>     store.close()
> }
> EOF
> cargo run --quiet --release
> cd ..
> ```
>
> ```text theme={null}
> 1 span with the phrase; failed tool calls in 1 trace: trace-1
> ```
>
> The first build of the app compiles the engine (some minutes). The docs of the Rust API: `cargo doc -p magpiedb --open` in the repo. More: [Rust library](https://docs.magpiedb.com/libraries/rust.md).

## Next

| You want to | Read |
| - | - |
| Send traces from your app or framework | [OpenTelemetry](https://docs.magpiedb.com/guides/opentelemetry.md) |
| Ask every kind of question | [Queries](https://docs.magpiedb.com/queries/overview.md) |
| Run it for a company: keys, TLS, tenants, retention, deletes, backup, S3 | [Operations](https://docs.magpiedb.com/operations/overview.md) |
| Know what it cannot do yet | [Limits](https://docs.magpiedb.com/limits.md) |
| Show it to someone in 10 minutes | [`docs/DEMO.md`](https://github.com/intojhanurag/magpie/blob/main/docs/DEMO.md) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.