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

# Introduction

> Same context. Everywhere.

![UltraContext](https://mintcdn.com/ultracontext/4e3P0FrZRyhGnWMy/images/context-api-hero.svg?fit=max\&auto=format\&n=4e3P0FrZRyhGnWMy\&q=85\&s=6e5be0a62d932aeffa5aaa336ec79301)

**Same context. Everywhere. Open source.**

What Claude Code knows, Codex doesn't. What your teammate is shipping right now? Your agent has no idea.

UltraContext captures every agent's context in realtime and makes it available to all of them. Continue a session in a different agent, or just ask what's happening.

* *"Codex, grab the last plan Claude Code made and implement it."*
* *"What's the team building today?"*
* *"What is Alex working on in Codex right now?"*

## Features

| | |
| - | - |
| **CLI** | Auto-ingest Claude Code, Codex, and OpenClaw sessions with a terminal dashboard. [Learn more](https://ultracontext.ai/docs/fundamentals/cli.md). |
| **MCP Server** | Share context everywhere. Built into the API, or run standalone via stdio. [Learn more](https://ultracontext.ai/docs/fundamentals/mcp-server.md). |
| **Context API** | Git-like context engineering API. Store, version, and retrieve agent context with zero complexity. |

## How it works

1. **Start the daemon.** It captures all your agents' context in realtime.

2. **Add the MCP server.** Any agent gets full awareness of every other agent.

3. **That's it.** Ask questions, continue sessions, fork — your context is everywhere.

***

# Why Context Matters

As LLMs take over as the new operating system, managing AI context becomes more and more valuable.

Context is the **RAM** — it's everything LLMs can see. That's the last interface between humans and AI. It's the lowest level of abstraction we can get to.

![LLM as Operating System (Karpathy)](https://mintcdn.com/ultracontext/kUJZtoB93LdmfW8F/images/karpathy-llm-os.png?fit=max\&auto=format\&n=kUJZtoB93LdmfW8F\&q=85\&s=5419e1f5210892902740b63b8b0a4a06)

Source: Andrej Karpathy (adapted)

Managing what goes in and out of this RAM is **context engineering**. The more we scale these LLM systems (or agents) to do real work, the more it becomes critical.

The catch? Context is finite. As it grows, model attention spreads thin — this is known as **context rot**. We should aim to provide the smallest set of high-signal tokens that get the job done.

> [accordion] Context engineering techniques
>
> **Compaction** — Reversible reduction. Strip info that can be reconstructed from external state. File write? Drop content, keep path. Search? Drop results, keep query. No information lost, just externalized.
>
> **Summarization** — Irreversible reduction. Use only when compaction gains are tiny. Key trick: use structured schemas (fields to fill), not freeform prompts. Keep last few tool calls in full detail so the model knows where it left off.
>
> **Offloading** — Move context outside the window. Dump to files, retrieve on demand via path or ID. Even pre-summary context can be saved as a log file — models can grep it later if needed.
>
> **Isolation** — Two patterns:
>
> * *By communicating*: Subagent gets only an instruction, returns only a result. Use for clear, bounded tasks.
> * *By sharing context*: Subagent sees full history but has its own system prompt. Use when tasks need prior context. Trade-off: larger pre-fill, no KV cache reuse.
>
> **Caching** — Stable context prefixes enable KV cache reuse. Dynamic tool injection breaks the cache. Keep atomic tools fixed; offload extensibility to sandbox utilities or code execution.
>
> The Context API gives you primitives for all of these. See the [guides](https://ultracontext.ai/docs/guides/store-retrieve-contexts.md) for patterns.

> [!NOTE]
>
> The internet before HTTP was a mess of incompatible protocols. Information was spread all over the place. Growth only exploded once we standardized the basic interface layer.
>
> We're at that exact moment with AI.

Right now, we're reinventing the wheel for every car we build. Instead of tackling interesting problems through applications, we catch ourselves spending most of our time gluing context together.

**It's time to simplify.**

***

# Context API

For builders who want to go deeper. Git-like primitives for context engineering.

| | |
| - | - |
| **Simple API** | Five methods. That's it. |
| **Automatic versioning** | Changes create versions automatically. Full history out of the box. |
| **Time-travel** | Jump to any point in your context history. |
| **Fast** | Globally distributed. Low latency. |
| **Schema-free** | Store context in any format. Own your data structure. |
| **Framework-agnostic** | Works with any framework. No vendor lock-in. |

Just plug & play.

***

## How it works

A single idea is all you need.

The Context API consists of **Contexts** holding **Messages**. That's it. Simple yet insanely powerful. Let's dive in.

```typescript Node.js theme={null}
import { UltraContext } from 'ultracontext';
const uc = new UltraContext({ apiKey: 'uc_live_...' });

// create a new context
const ctx = await uc.create();

// append, update and delete messages effortlessly
await uc.append(ctx.id, { role: 'system', content: 'You are a helpful assistant.' }); // v0
await uc.append(ctx.id, { role: 'user', content: 'Hello!' }); // v0
await uc.update(ctx.id, { index: 0, content: 'New system prompt.' }); // v1
await uc.delete(ctx.id, -1); // v2

// context is automatically versioned — fetch with history
const { data, versions } = await uc.get(ctx.id, { history: true });
// → versions: [
//     { version: 0, operation: 'create', affected: null },
//     { version: 1, operation: 'update', affected: ['msg_a'] },
//     { version: 2, operation: 'delete', affected: ['msg_b'] }
// ]

// use it with your favorite LLM framework
const response = await generateText({ model, messages: data });

```

```python Python theme={null}
from ultracontext import UltraContext
uc = UltraContext(api_key="uc_live_...")

# create a new context
ctx = uc.create()

# append, update and delete messages effortlessly
uc.append(ctx["id"], {"role": "system", "content": "You are a helpful assistant."})  # v0
uc.append(ctx["id"], {"role": "user", "content": "Hello!"})  # v0
uc.update(ctx["id"], {"index": 0, "content": "New system prompt."})  # v1
uc.delete(ctx["id"], -1)  # v2

# context is automatically versioned — fetch with history
data, versions = uc.get(ctx["id"], history=True)
# → versions: [
#     {"version": 0, "operation": "create", "affected": None},
#     {"version": 1, "operation": "update", "affected": ["msg_a"]},
#     {"version": 2, "operation": "delete", "affected": ["msg_b"]}
#   ]

# use it with your favorite LLM framework
response = generate_text(model=model, messages=data)
```

**Versioning is automatic.** Nothing is ever lost — everything is preserved out of the box. You don't have to worry about it. Just build your applications knowing you can get time travel with a single line of code:

```
v0 (create)     v1 (update msg1)     v2 (delete msg2)
├── msg1        ├── msg1 ← modified  ├── msg1
├── msg2        ├── msg2
```

```typescript Node.js theme={null}
// go back to version 0 (before system prompt was changed)
const v0 = await uc.get(ctx.id, { version: 0 });
// → {
//     data: [
//       { role: 'system', content: 'You are a helpful assistant.' },
//       { role: 'user', content: 'Hello!' }
//     ],
//     version: 0
//   }
```

```python Python theme={null}
# go back to version 0 (before system prompt was changed)
v0 = uc.get(ctx["id"], version=0)
# → {
#     "data": [
#       {"role": "system", "content": "You are a helpful assistant."},
#       {"role": "user", "content": "Hello!"}
#     ],
#     "version": 0
#   }
```

> [!NOTE]
>
> Only **updates** and **deletes** generate new versions. Appends do not because you can time travel by index. See the [View Context
> History](https://ultracontext.ai/docs/guides/view-context-history.md) guide for more.

## Contexts

**Contexts** are just containers. They can hold any collection of data you want. Conversation threads, user preferences, notes, etc. You name it.

```typescript Node.js theme={null}
import { UltraContext } from 'ultracontext';
const uc = new UltraContext({ apiKey: 'uc_live_...' });

// create new contexts
const ctx = await uc.create();
const ctx2 = await uc.create({ metadata: { user_id: '123' } });

// list all contexts
const { data } = await uc.get();

// retrieve a context (by id, message index, timestamp or version)
const { data } = await uc.get('ctx_abc123');
const { data } = await uc.get('ctx_abc123', { at: 5 });
const { data } = await uc.get('ctx_abc123', { before: '2024-01-01T00:00:00Z' });
const { data } = await uc.get('ctx_abc123', { version: 2 });

// retrieve a context with history
const { data, versions } = await uc.get('ctx_abc123', { history: true });

// fork a context from an existing one
const fork = await uc.create({ from: 'ctx_abc123' });

```

```python Python theme={null}
from ultracontext import UltraContext
uc = UltraContext(api_key="uc_live_...")

# create new contexts
ctx = uc.create()
ctx2 = uc.create(metadata={"user_id": "123"})

# list all contexts
result = uc.get()

# retrieve a context (by id, message index, timestamp or version)
result = uc.get("ctx_abc123")
result = uc.get("ctx_abc123", at=5)
result = uc.get("ctx_abc123", before="2024-01-01T00:00:00Z")
result = uc.get("ctx_abc123", version=2)

# retrieve a context with history
result = uc.get("ctx_abc123", history=True)

# fork a context from an existing one
fork = uc.create(from_="ctx_abc123")
```

> [!TIP]
>
> Forks are a powerful way to easily explore different scenarios without losing a single bit of data.

## Messages

**Messages** are the building blocks of a context. They're **schema-free** JSON objects, so you define the shape. Append, update, and delete with a single API call.

```typescript Node.js theme={null}
import { UltraContext } from 'ultracontext';
const uc = new UltraContext({ apiKey: 'uc_live_...' });
const ctx = await uc.create();

// append a single message
await uc.append(ctx.id, { role: 'user', content: 'Hello!' });

// append multiple messages at once (messages are schema-free)
await uc.append(ctx.id, [
    { role: 'user', content: 'Hi' },
    { role: 'assistant', content: 'Hello!' },
    { foo: 'bar' }
]);

// update message by id or index (creates new version automatically)
await uc.update(ctx.id, { id: 'msg_xyz', content: 'Fixed!' });
await uc.update(ctx.id, { index: 0, content: 'New system prompt' });

// multiple updates at once
await uc.update(ctx.id, [
    { id: 'msg_xyz', content: 'Fixed!' },
    { index: 0, content: 'New system prompt' },
    { index: -1, content: 'Fix last message' }
]);

// delete by id or index (creates new version)
await uc.delete(ctx.id, 'msg_xyz');
await uc.delete(ctx.id, -1); // delete last message

```

```python Python theme={null}
from ultracontext import UltraContext
uc = UltraContext(api_key="uc_live_...")
ctx = uc.create()

# append a single message
uc.append(ctx["id"], {"role": "user", "content": "Hello!"})

# append multiple messages at once (messages are schema-free)
uc.append(ctx["id"], [
    {"role": "user", "content": "Hi"},
    {"role": "assistant", "content": "Hello!"},
    {"foo": "bar"}
])

# update message by id or index (creates new version automatically)
uc.update(ctx["id"], {"id": "msg_xyz", "content": "Fixed!"})
uc.update(ctx["id"], {"index": 0, "content": "New system prompt"})

# multiple updates at once
uc.update(ctx["id"], [
    {"id": "msg_xyz", "content": "Fixed!"},
    {"index": 0, "content": "New system prompt"},
    {"index": -1, "content": "Fix last message"}
])

# delete by id or index (creates new version)
uc.delete(ctx["id"], "msg_xyz")
uc.delete(ctx["id"], -1)  # delete last message
```

Everything is a message. Think of messages as atoms in a molecule.

> [!NOTE]
>
> **metadata** and **index** keys are reserved for internal use.

That's the entire API.

***

## Quick links

> [card] [Quickstart](https://ultracontext.ai/docs/quickstart.md)
>
> Get running in 2 minutes.

> [card] [Guides](https://ultracontext.ai/docs/guides/store-retrieve-contexts.md)
>
> Practical patterns for common use cases.

> [card] [CLI](https://ultracontext.ai/docs/fundamentals/cli.md)
>
> Sync agent sessions automatically.

> [card] [MCP Server](https://ultracontext.ai/docs/fundamentals/mcp-server.md)
>
> Share context between agents.


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