> ## 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`.

# Security

> How to report a security problem, what counts, and what to know before you run Magpie.

## Report a problem

Please do not open a public issue for a security problem.

Use GitHub's private report: the "Security" tab of this repository, then "Report a vulnerability". Say what you did, what you saw and what you expected. A small set of commands that shows the problem helps most.

We answer as soon as we can. Magpie is a small project with no paid support, so there is no promised time.

## What counts

* Data of one tenant that another tenant can read or change (`magpie-server --tenants-dir`).
* A request that runs without a valid API key when keys are on, or that does more than the rights of its key.
* A request, a span or a file that makes the server or the library crash, hang or use memory without limit.
* Accepted writes that are lost or changed.
* Deleted data that is still readable after `purge_deleted` reports that it is gone.

## What to know before you run it

* Without `--auth keys` the server has no authentication. It then listens on `127.0.0.1` only by default. Do not put it on a public address without keys and TLS.
* `--auth trusted-header` trusts the `x-magpie-tenant` header. Use it only behind a proxy that authenticates the caller.
* API keys are stored as hashes in the key file. The key itself is shown once, by `keygen`.
* The store is not encrypted on disk. Use an encrypted disk or bucket if you need that.
* Prompts and replies are stored as they arrive, unless a mask policy (`--mask`) replaces private data first ([Server reference, "Masking"](https://docs.magpiedb.com/reference/server.md)).
* A store is one folder. Anyone who can read the folder can read all of its data.
* The server serves a read-only web viewer at `/` on its HTTP port (`--no-ui` turns it off). Its files are public and hold no data; the API it calls keeps the same keys. It shows every value as text and sends a strict Content-Security-Policy with Trusted Types (`crates/server/README.md`, "Viewer"). Its code is in `web/viewer/`; the built files in `crates/server/viewer/` are checked against it by `cargo test -p magpie-server`. A script that breaks out of that would count as a security problem.

## What the server does with requests from outside

* A page of another site cannot make a browser send a write (`403`), on the HTTP port and on the gRPC port; the routes that write take `application/json` only, and the gRPC port `application/grpc` only (`crates/server/README.md`, "Query API").
* With no keys on a loopback address (the default), or with no keys and `--allowed-host`, the server answers only to `localhost`, IP addresses and the names of `--allowed-host`: a page of a host name that its owner points at `127.0.0.1` (DNS rebinding) is refused (README "Host names"). With keys there is no host check: a rebound page has no key.
* An error never quotes the request: no value, number, name, key or header comes back, also not in the report of an `import`. A message whose shape the server does not know gives a fixed reason. A hash and a length of what was left out do come back.
* A write takes one of 16 places before its body is read (64 more wait; then `429`). With keys, the key is checked first, on both ports.
* The decode of an OTLP request or a score write is counted from its bytes before it is made (protobuf by its schema, JSON by every value in it; not below the real decode for any body shape measured in `crates/server/tests/budget_alloc.rs`, but an estimate, not a proof); one that would cost more than `--ingest-memory-mb` is refused (`413`), and the ones in flight share that budget. The spans of a request are counted before the decode too, and an OTLP/JSON body with an array directly in an array (the array form of a struct, which no encoder writes and the count would not follow) is refused (`400`). One OTLP request may not map to more than `--max-spans-per-request` spans or `--max-mapped-bytes` bytes (`413`).
* Slow and idle clients have deadlines (`--header-timeout`, `--body-timeout`, `--grpc-max-connection-age`, which closes gracefully), and each port has at most `--max-connections` connections (README "Slow clients").
* One list of a request (attributes, events, links, values, a JSON array, the words of a search) has at most `--max-list-items` items, counted before the decode (`413`), and a protobuf field of one message may come only once (`400`; the decoder would join the lists of its copies): on macOS the allocator keeps the memory of a decoded very long list, and this cap is what stops that (`docs/FINDINGS.md` F78; not measured on Linux).
* With TLS, a server certificate that is not valid now stops the start (another certificate of the file only warns), one that ends within 30 days gets a warning, and failed handshakes are logged (at most one line a minute per port, no client address): an expired certificate is not a silent loss of every span (D-ur-5).
* Not bounded yet: queries, deletes and purges take no place, and queries have no work budget. The spans that one OTLP request maps to (each span with a copy of its resource, at most `--max-mapped-bytes`, default 128 MiB) are not in the ingest memory budget: 16 small requests that copy a resource of 100 KB into each span took the server to 5.6 GB (2.8 GB with the old cap of 64 MiB; `docs/FINDINGS.md` F99). On a small machine, lower `--max-mapped-bytes`.

## Versions

Magpie is not released yet. Until the first release, fixes go to `main` only.


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