For Developers

Build with Trevec

The memory layer for autonomous AI agents. Use the SDK to build AI apps with persistent memory, or use MCP to give your IDE deep codebase understanding.

Overview

Trevec is the memory layer for autonomous AI agents. It gives any AI app persistent, user-scoped memory with sub-50ms retrieval — and gives coding agents structural understanding of your entire codebase.

Trevec has two main interfaces:

Trevec SDK

Python and npm packages for building AI apps with persistent memory. Chatbots, tutors, advisors, support agents — any app that needs to remember.

pip install trevecornpm install trevec

Trevec MCP

CLI and MCP server for your daily coding. Gives Claude Code, Cursor, Windsurf, and Codex deep structural understanding of your codebase.

curl -fsSL dl.trevec.dev/install.sh | sh

Installation

Install Trevec with a single command:

macOS (Apple Silicon & Intel) and Linux (x64 & arm64). Windows via PowerShell: irm dl.trevec.dev/install.ps1 | iex

$pip install trevec

Then get started:

1trevec mcp setupOne-time: configure all your AI tools
2cd your-project && trevec initPer repo: index, write rules, done

That’s it. Your AI tools now have structural understanding of your entire codebase.

Trevec SDK

The Python and npm SDK for building AI apps with persistent memory. Use it in your FastAPI, Django, Express, or any backend.

pip install trevecnpm install trevec

Memory — add, search, manage

Give your AI agent persistent, user-scoped memory. Each user’s data is isolated. Works without any API key, cloud service, or external database.

Zero-config initialization
from trevec import Trevec

tv = Trevec()                    # ephemeral (in-memory)
tv = Trevec("my-app")            # persistent (~/.trevec/my-app/)
Add memories with user scoping
tv.add("I love hiking in Denver", user_id="alex")
tv.add("Allergic to peanuts", user_id="alex")
tv.add("Prefers Python over JavaScript", user_id="bob")
Search (isolated per user)
results = tv.search("hobbies", user_id="alex")
# → [{"memory": "I love hiking in Denver", "score": 3.0}]

# bob can't see alex's data:
tv.search("hiking", user_id="bob")  # → []
Conversation format
tv.add([
    {"role": "user", "content": "What is calculus?"},
    {"role": "assistant", "content": "The study of change..."},
], user_id="student_01")
Manage memories
tv.get_all("alex")           # all memories for a user
tv.delete("memory_id_123")   # delete specific memory
tv.delete_all("alex")        # GDPR: delete all user data

Code Context — index and query

Index a codebase with Tree-sitter, then query it with hybrid search. Use this in your coding agents or any tool that needs to understand code.

Index a repository
tv = Trevec.for_repo("/path/to/repo")
stats = tv.index()
print(f"Indexed {stats['nodes_extracted']} nodes in {stats['total_ms']}ms")
Query with context
result = tv.query("How does authentication work?")

print(result["context"])       # formatted source code
print(result["total_tokens"])   # token count
print(result["retrieval_ms"])   # latency

for node in result["nodes"]:
    print(f"{node['file_path']}:{node['start_line']} {node['name']}")

Framework Integrations

Trevec integrates with popular AI frameworks. Here’s the pattern for FastAPI — the same approach works with Django, Flask, Express, or any backend.

FastAPI integration (complete example)
from fastapi import FastAPI
from trevec import Trevec

app = FastAPI()
tv = Trevec("my-app")

@app.post("/chat")
async def chat(user_id: str, message: str):
    # Retrieve relevant context for this user
    memories = tv.search(message, user_id=user_id, limit=5)
    context = "\n".join([m["memory"] for m in memories])

    # Build prompt with context (send to your LLM)
    prompt = f"Context:\n{context}\n\nUser: {message}"

    # Save the interaction
    tv.add(message, user_id=user_id)

    return {"prompt": prompt, "memories_used": len(memories)}

Trevec MCP

The CLI and MCP server for your daily coding. Gives Claude Code, Cursor, Windsurf, Zed, and Codex deep structural understanding of your codebase.

curl -fsSL dl.trevec.dev/install.sh | sh

Setup in Action

Three commands. Works with Claude Code, Cursor, Codex, and Claude Desktop.

claude code - ~/my-project
CursorAfter setup, enable Trevec in Settings → MCP and approve tools.
DesktopRestart Claude Desktop after running mcp setup.

Commands

trevec mcp setup

One-time global setup. Configures MCP for Claude Code, Cursor, Claude Desktop, and Codex. No per-project wiring needed.

trevec init

Set up Trevec in your project. Indexes your codebase, writes IDE rules, and registers the project. One command, ready to go.

trevec index

Re-index your codebase. Rebuilds the semantic graph and stores everything locally. Usually handled by init.

trevec mcp doctor

Run health checks on your setup. Verifies binary, index, MCP wiring, and memory configuration.

trevec ask <query>

Query your codebase from the terminal. Returns structurally relevant code context with file paths and spans.

trevec inspect <file>

View the topology of a file. All functions, classes, and their relationships (callers, callees, imports).

trevec mcp remove

Remove Trevec MCP configuration from all AI tools. Clean uninstall.

Live Demo

See how context flows automatically between tools. Plan in Claude Code, continue in Cursor. Trevec remembers everything.

Claude Code
claude code - ~/my-project
Cursor - 2 hours later
cursor - ~/my-project

Automatically. No copy-pasting. No repeating yourself. The context follows you from one tool to the next.

Total Recall

Every debugging session, design discussion, and refactor across every tool is captured. Ask about months of work and get a complete, code-linked summary.

Total Recall

Months of context. One question.

Every debugging session, design discussion, and refactor across every tool is captured in one place. Ask Trevec about months of work and get a complete, code-linked summary in seconds.

Stop wasting tokens and time re-explaining your codebase. Trevec remembers it for you.

>

Can you summarize everything I worked on since November? I need it for my performance review. Key projects, architectural decisions, and impact.

MCP Tools

These tools are automatically available to your AI agents after running trevec mcp setup and trevec init in your project.

get_context

Primary tool for understanding code. Ask a natural-language question, get structurally relevant code with file paths, line ranges, and related functions.

search_code

Hybrid search over your indexed codebase. Find specific functions, classes, or patterns by name or keyword.

read_file_topology

Inspect the structure of a file. All code nodes and their relationships. Use before modifying a file to understand dependencies.

remember_turn

Save important context to episodic memory. Debugging sessions, architecture decisions, and code reviews persist across sessions.

recall_history

Search episodic memory for past discussions. Recover context from previous sessions about any topic.

get_file_history

Retrieve discussion history for a specific file. See what was previously discussed: prior bugs, design decisions, review comments.

summarize_period

Generate a bullet-point summary of work within a time range. Perfect for daily standups or weekly recaps.

repo_summary

High-level overview of your repository: languages, file counts, entry points, hotspots, and detected conventions. Great for onboarding.

neighbor_signatures

Given a list of files, returns the external API surface they depend on. Imported symbols with signatures. Use before modifying a file.

batch_context

Run multiple get_context queries in a single call. Each query gets its own budget. Reduces round-trips for related questions.

Data Model

1

Structural Layer

Tree-sitter parses every file into ASTs. Functions, classes, modules become nodes. Imports, calls, inheritance become edges.

2

Retrieval Layer

Hybrid search combining full-text and semantic matching. Ranked by structural relevance, not just keywords.

3

Assembly Layer

Results are enriched with related code automatically. Context is assembled to fit your model's token limit and streamed via MCP.

Security Guardrails

Source code never leaves your machine
No telemetry, no analytics, no phone-home
Zero network calls during indexing and retrieval
Air-gap compatible deployment
Configurable exclude patterns for sensitive files
All data stored locally in .trevec/, fully portable

Ready to build?

Install Trevec and give your AI agents persistent memory.

Download Now