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

# Pi

> Give the Pi coding agent persistent memory with the community pi-cognee extension.

Add persistent, queryable knowledge-graph memory to [Pi](https://github.com/earendil-works/pi) with the community **pi-cognee** extension. Your agent can remember facts, recall them in later sessions, forget what's outdated, and manage datasets — all from inside Pi.

<Info>
  pi-cognee is a **community extension** built and maintained by [Kerry Hatcher](https://github.com/kerryhatcher) (MIT licensed). It is not maintained by the Cognee team — report issues on the [pi-cognee repository](https://github.com/kerryhatcher/pi-cognee/issues).
</Info>

The extension offers two backends behind one interface:

| Mode              | How it runs                                                               | Best for                                        |
| ----------------- | ------------------------------------------------------------------------- | ----------------------------------------------- |
| **SDK** (default) | In-process via the [`@cognee/cognee-ts`](/typescript/getting-started) SDK | Zero infrastructure — works out of the box      |
| **MCP**           | Connects to a remote [Cognee MCP server](/cognee-mcp/mcp-overview)        | Shared memory across agents, self-hosted setups |

All memory tools work identically in both modes, so you can start with SDK mode and switch to a shared MCP server later without changing how you use the agent.

## Install

```bash theme={null}
pi install npm:@kerryhatcher/pi-cognee
```

## Quick Start (SDK mode)

SDK mode runs Cognee in-process — no server needed. Set your LLM API key inside Pi:

```bash theme={null}
/cognee-config llmApiKey sk-...
/cognee-config llmModel gpt-5-mini
```

Then start using memory in conversation:

```
> Remember this: our staging environment runs in eu-central-1
```

Later — even in a new session — ask for it back:

```
> Which region does staging run in? Check your cognee memory.
```

Recall isn't automatic — Pi decides when to call `cognee_recall`, and for questions it can answer from project files, a coding agent will usually read the files instead. Test with facts that aren't in your codebase, or nudge it with "check your cognee memory". Memory is also stored per working directory in SDK mode, so recall it from the directory where you stored it.

<Note>
  In SDK mode, Cognee's own LLM calls (entity extraction, embeddings, search-time completions) run against the provider you configure with `llmApiKey` / `llmModel` and are billed by that provider — they don't go through Pi's model.
</Note>

## MCP Mode

To share memory across agents or use a self-hosted Cognee deployment, point the extension at a running [Cognee MCP server](/cognee-mcp/mcp-quickstart) (HTTP transport):

```bash theme={null}
/cognee-mode mcp
/cognee-config mcpUrl http://localhost:8001/mcp
```

In MCP mode, LLM and database configuration lives on the server — only `mcpUrl` is needed locally.

## Commands

| Command                        | Description                             |
| ------------------------------ | --------------------------------------- |
| `/cognee-mode [sdk\|mcp]`      | Switch backend mode                     |
| `/cognee-config`               | Show all config (API keys are redacted) |
| `/cognee-config <key>`         | Show one config value                   |
| `/cognee-config <key> <value>` | Set a config value                      |

## Tools

The extension registers these tools with Pi; they behave the same in both modes:

| Tool                    | Description                   |
| ----------------------- | ----------------------------- |
| `cognee_health`         | Check connectivity            |
| `cognee_remember`       | Store text in memory          |
| `cognee_recall`         | Search memory                 |
| `cognee_forget`         | Delete datasets or all memory |
| `cognee_datasets`       | List datasets                 |
| `cognee_dataset_data`   | List items in a dataset       |
| `cognee_create_dataset` | Create a new dataset          |
| `cognee_client_info`    | Show client identity and mode |
| `cognee_cognify_file`   | Ingest a file (base64)        |

## Configuration Reference

Set values with `/cognee-config <key> <value>`:

| Key                 | Default                     | Description                   |
| ------------------- | --------------------------- | ----------------------------- |
| `mode`              | `sdk`                       | Backend mode: `sdk` or `mcp`  |
| `mcpUrl`            | `http://localhost:8001/mcp` | MCP server URL (MCP mode)     |
| `llmModel`          | —                           | LLM model (SDK mode)          |
| `llmApiKey`         | —                           | LLM API key (SDK mode)        |
| `embeddingProvider` | —                           | Embedding provider (SDK mode) |
| `embeddingModel`    | —                           | Embedding model (SDK mode)    |
| `vectorDbProvider`  | —                           | Vector DB provider (SDK mode) |
| `graphDbProvider`   | —                           | Graph DB provider (SDK mode)  |

The SDK-mode keys map to the [`@cognee/cognee-ts` constructor options](/typescript/getting-started) — see that page for supported providers and models.

***

<CardGroup cols={3}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/kerryhatcher/pi-cognee">
    View the pi-cognee source code
  </Card>

  <Card title="npm Package" icon="box" href="https://www.npmjs.com/package/@kerryhatcher/pi-cognee">
    @kerryhatcher/pi-cognee on npm
  </Card>

  <Card title="TypeScript SDK" icon="square-js" href="/typescript/getting-started">
    The @cognee/cognee-ts SDK powering SDK mode
  </Card>
</CardGroup>
