The Problem
AI coding agents (Claude, Cursor, Copilot) hallucinate API signatures, use deprecated endpoints, and forget what they learned between sessions. You paste docs into chat, but they get lost in context. Your teammates paste different docs. Nobody's on the same page.
The Solution
Chub is a CLI + MCP server that serves curated, versioned API documentation directly to your AI agents. Think of it as a package manager for AI context: you pin the docs you need, your agents fetch them on demand, and your whole team shares the same source of truth — tracked in git.
You type: chub get openai/chat --lang python
Agent sees: The complete, accurate OpenAI Chat API reference for Python
+ any bugs, fixes, and best practices your team has discovered
Built on Context Hub by Andrew Ng — Chub is a high-performance Rust rewrite that extends the original with team features: shared doc pinning, git-tracked annotations, context profiles, agent config sync, content integrity verification, and self-learning agents that write back what they discover.
How It Works
┌──────────────┐ ┌─────────────┐ ┌──────────────────┐
│ AI Agent │────▶│ Chub MCP │────▶│ Doc Registry │
│ (Claude, │ │ Server │ │ (CDN / local) │
│ Cursor) │◀────│ │◀────│ │
└──────────────┘ └─────────────┘ └──────────────────┘
Gets accurate Searches, 1,500+ curated
API docs on caches, and docs covering
demand verifies docs major APIs
- Agent needs API docs — asks Chub via MCP (or you run
chub get) - Chub searches the registry — BM25 search with lexical boosting, 19x faster than the JS version
- Returns the right version — respects your team's pins, language preference, and version locks
- Appends team knowledge — annotations, project context, and profile rules travel with the doc
Quick Start
Install
Or download a prebuilt binary from GitHub Releases — single 10 MB binary, no runtime dependencies.
Use
Connect to Your AI Agent
Add to .mcp.json (Claude Code) or .cursor/mcp.json (Cursor):
Your agent now has access to chub_search, chub_get, chub_list, chub_annotate, chub_context, chub_pins, and chub_feedback tools.
Team Sharing
This is where Chub goes beyond Context Hub. Initialize a .chub/ directory in your repo and commit it — every developer and every AI agent gets the same versioned context, automatically.
my-project/
├── .chub/ # committed to git
│ ├── config.yaml # project-level config
│ ├── pins.yaml # locked doc versions
│ ├── annotations/ # team knowledge (e.g., "use streaming API for this endpoint")
│ ├── context/ # your own docs: architecture, conventions, runbooks
│ └── profiles/ # role-scoped context (backend.yaml, frontend.yaml)
Pin docs to specific versions
Build a self-learning knowledge base
Agents can write back what they discover — structured by kind so the knowledge is findable, not just buried in a notes field:
# Human adds a note
# Agent discovers a bug and records it (kind=issue + kind=fix)
# Agent validates a best practice
When any agent fetches these docs, all annotations appear alongside the official content — grouped by kind, clearly marked as team-contributed. Every debugging session becomes permanent team knowledge.
Add to .chub/config.yaml to automatically instruct agents to annotate:
agent_rules:
include_annotation_policy: true # adds Annotation Policy section to CLAUDE.md / AGENTS.md
Scope context by role
Keep versions fresh
Sync agent config files
CLI Reference
Search and Fetch
Doc Pinning
Context Profiles
Team Annotations
Dependency Detection
Supports: package.json, requirements.txt, pyproject.toml, Cargo.toml, go.mod, Gemfile, Pipfile, pom.xml, build.gradle.
Agent Config Sync
Snapshots and Freshness
Cache Management
MCP Server
To scope the session to a profile, activate it first: chub profile use backend && chub mcp.
Available tools
| Tool | Description |
|---|---|
chub_search |
Search docs by query, tags, or language |
chub_get |
Fetch a doc by ID (supports match_env for auto version detection) |
chub_list |
List all available docs and skills |
chub_annotate |
Read, write, or list annotations |
chub_context |
Get optimal context for a task (pins + annotations + profile) |
chub_pins |
List, add, or remove pinned docs |
chub_feedback |
Submit quality feedback for a doc |
Registry resource: chub://registry
Works with any MCP-compatible agent: Claude Code, Cursor, Windsurf, and others. The transport is stdio.
Security
Chub includes several security measures for safe use in team environments:
- Content integrity verification —
chub buildcomputes SHA-256 hashes of all doc content, stored in the registry. Fetched content is verified against these hashes to detect CDN tampering. - Annotation trust framing — User-contributed annotations are clearly marked as non-official content when served to agents, mitigating prompt injection risks.
- Annotation length limits — Notes are capped at 4,000 characters to prevent context flooding.
- Path traversal protection — File path parameters are validated and normalized.
- Graceful process lifecycle — The MCP server handles signals cleanly to prevent orphan processes.
Benchmarks
Measured on the production corpus (1,553 docs, 7 skills). Median of 5 runs on Windows 11, Node.js v22, Rust release build.
Performance
| Operation | Context Hub (JS) | Chub (Rust) | Speedup |
|---|---|---|---|
search "stripe payments" |
1,060 ms | 56 ms | 19x |
build --validate-only |
1,920 ms | 380 ms | 5x |
build (1,560 entries) |
3,460 ms | 1,770 ms | 2x |
get stripe/api |
148 ms | 63 ms | 2.3x |
Cold start (--help) |
131 ms | 44 ms | 3x |
Resources
| Metric | Context Hub (JS) | Chub (Rust) |
|---|---|---|
| Package size | ~22 MB (node_modules) |
10 MB (single binary) |
| Runtime dependency | Node.js 20+ | None |
| Peak memory (build) | ~122 MB | ~23 MB (5.3x less) |
Feature comparison
| Context Hub (JS) | Context7 | Chub (Rust) | |
|---|---|---|---|
| CLI commands | 7 | — | 20 |
| MCP tools | 5 | 2 | 7 |
| Team features (pins, profiles, snapshots) | — | — | Yes |
| Self-learning agents (structured annotations) | — | — | Yes |
| Annotation policy in CLAUDE.md / AGENTS.md | — | — | Yes |
| Content integrity verification | — | — | Yes |
Auto version detection (--match-env) |
— | — | Yes |
| Self-hosted registry | Yes | — | Yes |
| Registry format compatibility | — | — | Identical to Context Hub |
Content Registry
Build your own docs
Content format
content/
<author>/
docs/<entry-name>/
<lang>/DOC.md # YAML frontmatter + markdown
<lang>/<version>/DOC.md # versioned variant
skills/<entry-name>/
SKILL.md
Self-host
Add your private registry as an additional source in ~/.chub/config.yaml — no cloud required. See Private Content for details.
Test Suite
117 tests covering behavioral parity with Context Hub and all team features:
| Suite | Tests | Coverage |
|---|---|---|
| Tokenizer | 6 | Stop words, punctuation, edge cases |
| BM25 search | 7 | Scoring, ranking, limits, field weights |
| Inverted index | 1 | Parity with linear scan |
| Frontmatter parser | 9 | YAML, CRLF, BOM, empty, numeric |
| Language normalization | 4 | Aliases, case, unknown |
| Build integration | 15 | Output format, validation, structure |
| Search parity | 20 | Multi-word, tags, descriptions |
| Team features | 51 | Pins, profiles, annotations (3 tiers), snapshots, detect, freshness |
Documentation
Full documentation at chub.nrl.ai:
- Getting Started — install and first commands
- Installation — all platforms and package managers
- Why Chub — comparison with Context Hub
- Doc Pinning — lock doc versions
- Context Profiles — role-scoped context
- Team Annotations — shared knowledge
- Project Context — custom docs
- CLI Reference — all commands and flags
- Configuration — config file format
- MCP Server — agent integration
- Showcases — real-world usage examples
Contributing
License
MIT