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

# Tool Attribution

> How Memanto knows which AI tool is talking to it, and how that drives the live Connections view.

# Tool Attribution

A Memanto session belongs to an *agent*, but the calls inside it come from a *tool* —
Claude Code, Cursor, Codex CLI, an MCP client, or a plain shell. Attribution is what
records which tool made each call, so a session can show who took part in it and the
dashboard can show which tools are connected right now.

This is machine-facing plumbing. Nothing here changes what a person types by hand.

## How Memanto identifies the caller

Identity is resolved in this order, best first:

1. **The tool names itself.** `--tool` on reads, `--source` on writes, or the
   `X-Memanto-Client` header over HTTP. Exact.
2. **`MEMANTO_CLIENT` in the environment.** Set by a wrapper that knows who it is.
3. **MCP `clientInfo`.** Read from the `initialize` handshake, so an MCP client is
   identified without any flag.
4. **Environment markers.** Variables a tool happens to leave behind (`CLAUDECODE`,
   `CURSOR_TRACE_ID`, and similar). Reliable when present, absent for some tools.
5. **Unidentified.** Recorded as `unknown` rather than guessed at.

Detection is deliberately conservative: a marker has to be specific to one tool before
Memanto maps it. Attributing a call to the wrong tool is worse than attributing it to
nobody, because the Connections view reads these labels back as fact.

## Declaring the tool

<Tabs>
  <Tab title="Reads">
    `recall` and `answer` carry no `--source`, so they take `--tool`:

    ```bash theme={null}
    memanto recall "auth approach" --limit 10 --tool cursor
    memanto recall --recent --limit 10 --tool cursor
    memanto answer "What did we decide about auth?" --tool cursor
    ```
  </Tab>

  <Tab title="Writes">
    `remember` already names the writer with `--source`, and that doubles as the
    calling tool. There is no `--tool` on `remember`:

    ```bash theme={null}
    memanto remember "Chose Postgres for the metadata store" \
      --type decision --confidence 0.95 --provenance inferred \
      --source cursor
    ```

    `--source user`, `agent`, and `human` name a person rather than a tool, so they do
    not claim a connection. Memanto falls back to environment detection for those.
  </Tab>

  <Tab title="HTTP">
    REST callers identify themselves with headers:

    ```
    X-Memanto-Client: cursor
    X-Memanto-Project: /path/to/repo   # optional
    ```

    The session comes from the session token, not from a header. A request with no
    `X-Memanto-Client` is recorded as `unknown` — it is never attributed to whatever
    process happens to be running the server.
  </Tab>
</Tabs>

`--tool` is hidden from `--help` because it exists for agents, not people. It accepts any
slug; values are normalized to lowercase (`Claude Code` becomes `claude-code`), and the
[connect](/cli/connect/connect) slugs are the canonical set.

<Note>
  Running `memanto connect <agent>` writes a skill and instruction file that already
  carry that agent's own slug on every example command, so a connected tool identifies
  itself without any extra setup. If you connected before this shipped, re-run
  `memanto connect <agent>` to pick it up.
</Note>

## What gets recorded

Each memory operation appends one line to a local activity log at
`~/.memanto/activity/events-YYYY-MM-DD.jsonl`:

```json theme={null}
{"ts": "2026-09-09T19:47:12+00:00", "tool": "cursor", "display": "Cursor",
 "session": "sess_dc8007cbb863", "agent_id": "my-agent",
 "project_dir": "/path/to/repo", "op": "recall", "n": 5}
```

It records the operation and a count — never memory content. Files older than 30 days are
pruned automatically. Logging is best effort: a failure to write this line never fails the
memory operation behind it.

## Where it shows up

The [dashboard](/cli/core/ui#connections) Connections page reads this log:

* **Connected tools** — a diagram of each tool joined to Memanto. A tool that touched
  memory in the last 5 minutes shows as live.
* **Sessions** — one row per Memanto session, with the logos of every tool that took part,
  plus writes and reads. Opening a row shows the session's full event timeline, so you can
  see one tool write a memory and another read it back later in the same session.

Two localhost-only endpoints back that view:

| Endpoint                                    | Returns                                                         |
| ------------------------------------------- | --------------------------------------------------------------- |
| `GET /api/ui/sessions?days=7`               | Sessions with their participating tools, plus per-tool liveness |
| `GET /api/ui/sessions/{session_id}?days=30` | One session's summary and full event timeline                   |

Both are restricted to loopback callers, like the rest of the dashboard API.

<Note>
  A session with no identified tool shows as *no tool identified* rather than being
  hidden. That usually means the caller was a bare shell, or a tool that has not been
  connected yet.
</Note>
