跳到正文
GitHub·· 5 天前AI 评分60

CompanyBrain 发布自托管记忆后端,支持 MCP 与混合检索

aayambansal/companybrain

AI 导读

CompanyBrain 是一个 MIT 许可的自托管记忆后端,可接入 Obsidian、Google Docs、Slack、Notion、GitHub 等 40 多个连接器,把文档切块后同时建立向量与全文索引,通过 reciprocal rank fusion 做混合检索,RAG 问答返回带引用的答案。

正文

CompanyBrain is a self-hosted memory backend. Point it at your knowledge (Obsidian vaults, Google Docs, Slack, Notion, GitHub, web pages, RSS, plain files) and it becomes one private, searchable brain that answers questions with citations. Your agents talk to it over MCP. Your apps talk to it over a typed SDK. Your data never leaves your Postgres.

It is a from-scratch, MIT-licensed alternative to closed, hosted memory services. No per-seat pricing, no vendor holding your knowledge hostage.

Run it

One command. It clones (if needed), asks two questions, and starts everything with Docker.

npx companybrain

Then open http://localhost:3000. That is the whole install. The default embedding model runs locally with no API key, so you can index and search in the first minute.

Prefer to drive it yourself:

git clone https://github.com/aayambansal/companybrain.git
cd companybrain
cp .env.example .env      # defaults work with zero keys
docker compose up -d      # postgres + pgvector, api, dashboard

Or on the metal, no Docker:

pnpm install
docker compose up -d db   # just postgres
pnpm db:migrate
pnpm dev                  # api :3333, dashboard :3000

No sign-in

By default CompanyBrain runs in single-user mode: no login wall, one workspace, you are in. That is the frictionless self-host experience. Flip AUTH_MODE=multi for full auth (register, login, sessions, API keys, many workspaces), or set ACCESS_TOKEN to gate an exposed instance.

Bring your own keys

Runs zero-config on a local embedding model. Want real semantic search or grounded chat? Open Settings > Providers in the dashboard and paste an OpenAI, Anthropic, Google, or Ollama key. It reconfigures the running engine on the spot. Nothing is required to start.

What you get

  ingest -- chunk -- embed -- index -- search -- cite
     |                                            |
  connectors                                  agents . apps . you
  • One store for everything. Files, notes, chat logs, docs, and web pages land as documents, split into retrievable chunks with a vector and a full-text index side by side.
  • Hybrid retrieval. Vector similarity and Postgres full-text search, fused with reciprocal rank fusion, so you get both meaning and exact keywords.
  • Multimodal ingest. OCR on images, Whisper transcripts on audio, extracted PDF text, and video transcripts all land as searchable text.
  • Answers with receipts. RAG chat returns citations that point back at the source chunk.
  • Agent-native. A built-in Model Context Protocol server lets Claude, Cursor, or any agent read and write the brain as a tool.
  • Yours to run. Bring your own Postgres. Nothing phones home.

Benchmarks

Retrieval quality, measured on the public BEIR benchmark and scored with pytrec_eval (the standard TREC evaluator). CompanyBrain's pipeline (text-embedding-3-large + HyDE + reranking) tops nDCG@10 above published BM25 and dense-retriever baselines:

dataset CompanyBrain nDCG@10 BM25 (published) dense (published)
NFCorpus 0.439 0.325 ~0.37
SciFact 0.816 0.665 ~0.72

Full leaderboard and methodology: companybrain benchmarks. Reproduce every number with the harness in bench/ — see bench/BEIR.md.

How it fits together

  dashboard        chrome ext        mcp server        sdk (ts / py)        cli
  (next.js)                          (agents)
      \                 \                |                 /                 /
       `------------------\-------------+----------------/-----------------'
                           \            |
                        +------------------------+
                        |    companybrain api     |   hono + node
                        |  auth . spaces . search |
                        +-----------+-------------+
                        +------------------------+
                        |     memory engine      |   ingest -> chunk ->
                        |  embed . rank . fuse   |   embed -> index -> search
                        +-----------+-------------+
                        +------------------------+
                        |   postgres + pgvector  |   your database
                        +------------------------+

Design notes: docs/architecture.md.

Repo layout

path what it is
apps/api the HTTP API (Hono)
apps/web the dashboard (Next.js)
apps/mcp Model Context Protocol server for agents
apps/cli the companybrain / cb command-line interface
apps/extension Chrome extension
packages/core ingestion, chunking, embeddings, hybrid search
packages/db Drizzle schema + migrations (Postgres / pgvector)
packages/connectors source integrations + sync runner
packages/sdk TypeScript SDK
packages/ai-sdk Vercel AI SDK tools (searchMemory / askMemory / addMemory)
packages/langchain LangChain / LangGraph CompanyBrainRetriever
packages/openai OpenAI-compatible function-calling tools
packages/n8n-nodes-companybrain n8n Search / Ask / Add node
packages/launcher the npx companybrain installer
sdks/python Python SDK
examples runnable TS / Python / curl examples

Connectors

Configure and sync any of these from the dashboard under Connections.

Raw text / API Web page / URL Sitemap crawl Markdown / files / PDF
Obsidian vault RSS / Atom Notion Slack
GitHub Google Docs Google Drive OneDrive
Dropbox Box Linear Jira
Asana Trello ClickUp Todoist
Confluence GitBook Coda Airtable
Gmail Discord Telegram Reddit
YouTube Hacker News Readwise Raindrop.io
Zendesk Intercom Freshdesk Front
HubSpot Pipedrive GitLab Bitbucket
Sentry Wispr Flow Granola Fathom
Raycast

Forty-plus connectors and counting. See docs/connectors.md to write your own.

Clients

  • TypeScript SDK: npm install @companybrain/sdk
  • Python SDK: pip install companybrain
  • CLI: companybrain add, search, ask, spaces
  • MCP: point Claude Desktop / Cursor at the server (npx companybrain mcp prints the config)
  • Chrome extension: save any page or selection to your brain

Framework integrations

Drop your company memory into the tools you already use:

  • LangChain / LangGraph: @companybrain/langchain — a CompanyBrainRetriever
  • Vercel AI SDK: @companybrain/ai-sdk — searchMemory / askMemory / addMemory tools
  • n8n: n8n-nodes-companybrain — a Search / Ask / Add node for no-code workflows
  • OpenAI-compatible: @companybrain/openai — function-calling tools for the OpenAI Agents SDK, Assistants, or raw function calling

Deploy

docker compose up or npx companybrain locally; or one-click to a cloud with the included blueprints. See docs/deploy.md for Render, Railway, Fly.io, bring-your-own Postgres, and the GHCR images.

Docs

Contributing

Built in the open, moving fast. Every change ships as a pull request. See CONTRIBUTING.md.

License

MIT. Take it, run it, ship it.

来源:GitHub · github.com