sourcebook

sourcebook

MCP server that gives AI coding agents a git-backed markdown wiki to read and update, enabling search, read, write, verify, ingest, promote, and lint operations on versioned knowledge documents with schema validation, staleness tracking, and contradiction detection.

Category
访问服务器

README

Sourcebook

Sourcebook is a git-backed markdown wiki that AI coding agents read and update over MCP.

I built it because project knowledge kept getting lost between agent sessions. How a service actually works, why we picked one approach over another, what our internal terms mean, what broke last month and why: that lived in design docs, incident writeups, old chat logs, and people's heads. Every session started cold and I re-explained the same things.

Sourcebook gives that knowledge one structured place. Agents search it before starting work, update pages when they learn something, and add pages when nothing covers the topic. Documents are validated against schemas, every change is a git commit with an author, and the tooling flags pages that have gone stale or started contradicting each other.

It is aimed at a small team on a long-running project that uses coding agents daily. The wiki is a curated, bounded set of pages that someone keeps current, not an index over every file you have.

Status: an experiment, published to see whether the approach is useful to anyone else. If you would run this, or something is missing that stops you, open a Discussion.

What a session looks like

You paste last week's incident postmortem into an ingestion session. Sourcebook proposes a plan: add the new failure mode to the affected service's system card, add a step to the incident-response process doc, define one new glossary term. Each change cites the postmortem. Nothing else is touched, because the prompts treat "already covered" as a correct answer. You apply it, and each change lands as a git commit attributed to you.

Three weeks later a teammate asks their agent how that service's retry logic works. The agent reads the system card, which arrives with a notice that its last_verified date has aged. The work the agent just did confirms the doc is still accurate, so it calls verify_document once and the clock resets, committed under the teammate's name. Nobody scheduled a documentation review.

What it stores

Six document types, each with required frontmatter and required sections:

Type Holds
System card How one system or service works: purpose, stack, patterns, gotchas
Process A procedure someone follows, step by step
Decision record An ADR: what was decided, what was rejected, the consequences
API reference The parts of a library or framework API your team actually uses
Knowledge page A synthesized answer worth keeping, usually promoted from a conversation
Source summary What an ingested source said, and which pages it changed

Alongside those: a glossary (terminology as data rather than prose), conventions (hard rules agents must not break), and context bundles (a named set of pages an agent loads in one call, trimmed to a token budget).

How you interact with it

  • Agents use the MCP server to search, read, write, verify, ingest, promote, and lint.
  • Humans use the web UI to browse, edit, and review, with dashboards for staleness, lint findings, and recent activity.
  • The CLI (sourcebook) handles setup, validation, lint, bundles, and running the servers.

All three call the same modules, so search ranking and bundle assembly cannot drift between them (ADR-002).

Try it locally

This repo ships with its own wiki, so you can browse a populated instance before building anything:

git clone <this-repo> sourcebook && cd sourcebook
pip install -e .
sourcebook serve         # this repo's own wiki at http://localhost:5000

Not on PyPI yet, so installing from a clone is the supported path. The sourcebook CLI then works from any directory.

To start your own, run this inside your project's git repository, so doc changes get history and attribution:

cd ~/code/your-project
sourcebook init          # scaffolds docs/ai/ with schemas, seed examples, glossary
sourcebook serve         # web UI on :5000
sourcebook serve-mcp     # MCP server on :8000 (second terminal)

Then point an agent at it:

claude mcp add --scope user sourcebook --transport http http://localhost:8000/mcp

Docker runs both servers under one supervisor:

docker compose up --build -d

The seed content demonstrates each document type using a small fictional product. Replace it with your own. CLAUDE.md in this repo shows the kind of agent instructions that get the wiki consulted and maintained as part of normal work.

How it avoids going stale

An LLM-maintained wiki rots if nothing pushes back: duplicate pages, silent rewrites that drop hard-won detail, claims nobody re-checks. Most of Sourcebook is the machinery that resists that. It does not eliminate the problem, but it makes it visible and cheap to correct.

  • Schemas are enforced as errors. An unknown type: is rejected rather than warned about, so a frontmatter typo cannot produce a document that silently skips every other check (ADR-001).
  • Writing identical content does nothing. No log entry, no commit. Sources are SHA-256 tracked, so re-ingesting unchanged material is free and re-running a batch is idempotent.
  • Creating a page requires ruling out the existing ones. The write path asks for evidence that the nearest pages were considered first.
  • Stale pages recruit their readers. Every doc carries last_verified. When a stale one is served over MCP it comes with a note asking the reading agent to confirm it with a single verify_document call, or to fix it. Types whose lifecycle is not date-based, such as decision records, are exempt instead of being flagged forever (ADR-004).
  • Lint runs structurally and semantically. Orphan pages, dependency mismatches, and tag drift come from static checks. Contradictions and stale claims across documents come from an LLM pass.
  • Git is the database. Every change is a commit attributed to the human who triggered it, so history, diff, blame, rollback, and review are ordinary git operations. There is nothing else to run alongside it, with the trade-offs that implies.

Running it for a team

Run one shared instance rather than a copy per person. That gives you one live state, no push races between personal clones, and one staleness dashboard that means the same thing for everyone. Deploy the Docker setup on a server inside your network and have everyone point their agent at it.

Sourcebook has no authentication, so do not expose it to the internet. Port bindings, the SOURCEBOOK_ALLOWED_HOSTS allowlist, and reverse-proxy details are in the deployment guide.

Trust model: read this before deploying

Sourcebook ships without authentication. It is designed for a private, trusted network, where write friction would kill the contribution rate that keeps a wiki alive. Every mutating request is audit-logged (IP, user agent, timestamp; see ADR-003), and git history attributes every change, but nothing stops a request.

Do not expose this to the public internet. Deploy it inside a network boundary you trust, or put your own auth proxy in front of it. If there is real interest, an auth story is the first thing on the roadmap. Browser-driven attacks are covered separately in SECURITY.md.

Limitations

Things Sourcebook does not do, so you do not have to discover them the hard way:

  • Search is keyword-based. A weighted scorer over names, tags, headings, and body text. It works well when documents have good names and tags, which the schemas push you toward, but it matches words rather than meaning: a vague description of a page will not find it. Fine at hundreds of documents, unproven beyond that.
  • It expects a curated corpus. Sourcebook holds pages someone is willing to keep current. It does not index an arbitrary pile of files, and it has no answer for a corpus nobody maintains.
  • No authentication, by design. See the trust model above. If you cannot provide a trusted network boundary, this is not deployable for you yet.
  • The LLM-backed features need an LLM. Semantic lint and the chat tab require an OpenAI-compatible endpoint and an API key you provide. Everything else runs without one: schemas, validation, structural lint, staleness, search, and the whole MCP surface.
  • Fan-out ingestion is not atomic. Actions apply sequentially, so if one fails mid-batch, earlier actions are already committed. Git history is the recovery path, and the source's completion marker is only set when everything succeeded, but you can end up in a partially applied state.
  • sourcebook serve is Flask's development server. Fine on your own machine. Use the Docker setup, or your own WSGI server behind a reverse proxy, for anything shared.
  • Scale is unvalidated. The design targets a small team and a corpus of tens to hundreds of documents. Nothing has been tested on thousands of documents or high write concurrency.
  • It is an experiment. Prompts, tool contracts, and schemas may change between versions without a deprecation path.

The repo documents itself

docs/ai/ is a live Sourcebook wiki documenting Sourcebook: a system card for the tool, its design decisions as decision records, a glossary, conventions, and a context bundle that packs it all for an agent. Run sourcebook --root docs/ai bundle design to see exactly what an agent would load. ADR-004 is the one I would read first, since it is my answer to how an LLM-maintained corpus avoids rotting.

Configuration

Variable Purpose Default
SOURCEBOOK_ROOT Path to the docs/ai/ tree auto-discovered
SOURCEBOOK_MCP_URL Public MCP URL shown in setup instructions port-swap fallback
SOURCEBOOK_ALLOWED_HOSTS Comma-separated hostnames this instance answers for; blocks DNS rebinding. * disables the check loopback only
SOURCEBOOK_GIT_AUTHOR_NAME / _EMAIL Git identity for AI-authored commits sourcebook-bot / sourcebook-bot@sourcebook.local
SOURCEBOOK_DEPLOY_KEY SSH key path for git push unset
SOURCEBOOK_LLM_API_KEY Bearer token for LLM-backed features (semantic lint) unset
SOURCEBOOK_LLM_BASE_URL OpenAI-compatible endpoint for the chat tab http://localhost:8000/v1
SOURCEBOOK_LLM_MODEL Model name served by that endpoint local-model
SOURCEBOOK_CHAT_URL Optional upstream for the secondary chat tab unset

Python 3.10+ for the MCP server, which is an MCP SDK constraint. The CLI and web UI run on 3.9+.

Development

pip install -r requirements.txt -r requirements-dev.txt
python -m pytest tests/ -m "not docker"
ruff check .

437 tests at the time of writing. CI runs ruff and the same suite on Python 3.10 and 3.12. See CONTRIBUTING.md for code layout and PR expectations.

Credits

The pattern this implements was articulated in Andrej Karpathy's LLM wiki gist: rather than re-deriving understanding from raw sources on every query, an LLM compiles them into a structured wiki once and then maintains it. Sourcebook is an independent take on that idea, focused on the maintenance half.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选