Brain

Brain

Self-hosted MCP server for collecting, searching, and sharing agent session history from Claude Code, Codex, and Cursor, with repository scoping and token-based authentication.

Category
访问服务器

README

Brain

Your team already wrote the missing manual. It is sitting in agent chats.

Brain turns Claude Code, Codex, and Cursor sessions into a shared, searchable memory. A new teammate can ask why a system works this way. An agent can find the old investigation instead of repeating it. The useful context can span the whole history of a Git organization, including decisions that never made it into a document.

Deploy Brain once. Put it on your Tailnet. Point any stateless MCP client at /mcp. Search needs no Brain package, token, browser login, or custom client. It works well from Code Mode because the MCP tools are small data operations and the agent can combine them in a REPL.

Brain is open source and cloud-neutral. AWS, another cloud, or one machine all work.

What feels different

  • Tailscale is the default front door. People use the identity they already have on the private network.
  • Search and reading are remote, stateless MCP calls. There is nothing to install on each reader's machine.
  • Sharing stays deliberate. The local exporter shows the repository, source, dates, and session count before upload.
  • Repository scope comes from the saved session directory's Git origin, not its folder name.
  • Claude Code, Codex, Cursor, subagents, archived Codex sessions, and recorded Codex Desktop side chats are supported.
  • Repeated text is stored once with SHA-256 content-addressed storage. Uploads send only missing sessions and bodies.
  • Admins can inspect bounded, redacted request records without storing raw query text or upload bodies.

Run it

uv is the default way to build, test, and run Brain.

git clone https://github.com/sdrshn-nmbr/brain
cd brain
cp .env.example .env
# Edit the repository, Tailnet host, admin login, and app-capability domain.
docker compose up -d
tailscale serve --accept-app-caps=example.com/cap/brain 8788

Then point a remote MCP client at:

https://brain.your-tailnet.ts.net/mcp

Tailscale Serve adds the caller identity and strips spoofed identity headers. Keep Brain's published port on host loopback and do not expose its plain HTTP port. See authentication and deployment.

Search without a client install

The server exposes search, browse, read_session, and stats as normal MCP tools. Add the URL to Claude Code, Codex, Cursor, OpenCode, or another remote MCP client. Code Mode can call those tools from its own REPL; it does not need the Brain Python package.

Publishing is the one local step. The server cannot read ~/.claude, ~/.codex, or Cursor's local databases. Run the publisher once through uv without installing it:

uvx --from git+https://github.com/sdrshn-nmbr/brain@v1.1.0 brain-sync \
  --endpoint https://brain.your-tailnet.ts.net/mcp \
  --repository github.com/example/widget \
  --visibility "Example engineering" \
  --dry-run

The dry run writes a local archive but sends no transcript data. Read the printed scope, then publish that exact archive:

uvx --from git+https://github.com/sdrshn-nmbr/brain@v1.1.0 brain-sync \
  --endpoint https://brain.your-tailnet.ts.net/mcp \
  --archive "$HOME/Downloads/agent-chats-export-<timestamp>.zip"

Brain asks before upload. Use --yes only after a person or approved automation has accepted that exact scope.

Codex Desktop side chats

Codex does not always put complete Desktop side chats in its normal session files. Brain includes a small opt-in proxy that records future side-chat prompts, assistant replies, and tool events under ~/.codex/attachments/sidechats/*.jsonl:

uvx --from git+https://github.com/sdrshn-nmbr/brain@v1.1.0 brain-sidechat-recorder --install-hook
export CODEX_CLI_PATH="$HOME/.codex/bin/brain-sidechat-recorder"

Start Codex Desktop from an environment containing that variable. The hook is local and contains only Python standard library code. Recording failure never blocks Codex. These files can contain sensitive tool data. Brain uploads a recorded side chat only when its saved working directory resolves to an allowed repository and the user confirms the archive. Arbitrary files from ~/.codex/attachments are never uploaded.

Scope and access

Scope is checked by the exporter, upload server, and ingester. Repository IDs include the Git host, such as github.com/acme/api or gitlab.example.com/platform/models/recommender.

Tailnet users get append access by default. Named admins get observability tools. Tagged workloads need a Tailscale app capability and stay read-only. The included policy templates show read, append, and admin grants for fine-grained access. Bearer tokens and trusted proxy headers remain explicit alternatives.

Why SQLite

The current bottlenecks were query shape, archive packaging, and connection reuse. After those fixes, local SQLite FTS search is fast and the single-writer design stays easy to operate. Brain keeps reads online during atomic ingestion and uses a separate append-only object database for deduplicated bodies.

Possible future directions:

  • A Turbopuffer backend for lexical search, vector search, and other indexes, with S3 for session bodies.
  • Hybrid semantic and full-text ranking.
  • Postgres or Turso when a deployment needs several writers or a managed database.
  • Go, Rust, async pipelines, or SIMD JSON parsing if profiles show CPU parsing is the next real limit.

These are options, not required complexity.

Develop

uv sync --frozen
just check

just check runs Ruff, ty, the full test suite, and package build. Brain uses Pydantic models at its MCP boundary and checks them with ty's Pydantic-aware type analysis.

The service uses one writable process and one persistent data directory. See architecture for the storage and consistency rules.

Apache-2.0. See LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选