context-book

context-book

Provides AI agents with a persistent, searchable knowledge library via MCP tools, allowing them to create books, manage pages, perform semantic search, and retrieve usage guides.

Category
Visit Server

README

<p align="center"> <img src="banner.png" alt="ContextBook" width="100%"> </p>

smithery badge License: MIT

<a href="https://www.producthunt.com/products/contextbook?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-contextbook" target="_blank" rel="noopener noreferrer"><img alt="ContextBook - Stop re-explaining. Give agents the right context | Product Hunt" width="250" height="54" src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1152644&theme=light&t=1779372437431"></a>

Stop re-explaining yourself to Agents. Give it the right context, right when needed.

LLMs are stateless โ€” each conversation starts from scratch. ContextBook gives your AI tools a persistent, searchable knowledge library to draw the right context when they need it. No bloatware, no pre-loaded junk. Just the right information, at the right time.

How It Works

flowchart LR
    AI["๐Ÿค– AI Clients\nClaude ยท Cursor ยท Windsurf"]
    Browser["๐ŸŒ Browser Dashboard"]
    MCP["๐Ÿ”Œ MCP Server :8081\n8 Bearer-authenticated tools"]
    API["โš™๏ธ REST API :8080\nOAuth 2.0 ยท Books ยท Pages ยท Search"]
    DB["๐Ÿ—„๏ธ PostgreSQL\npgvector ยท pg_trgm"]
    VOYAGE["๐Ÿง  Voyage AI\nvoyage-4 (1024-dim)"]

    AI -- "MCP ยท Bearer Token" --> MCP
    Browser -- "Session ยท HTTP JSON" --> API
    MCP --- DB
    API --- DB
    API -- "OAuth 2.0 PKCE" --> AI
    DB --- VOYAGE

Two Go binaries share a PostgreSQL database:

  • API server (cmd/api) โ€” the control plane: user login, OAuth 2.0, dashboard, book/page CRUD
  • MCP server (cmd/mcp) โ€” the data plane: 8 MCP tools for AI agents, protected by Bearer tokens

MCP Tools

All tools require a valid Bearer token and are scoped to the authenticated user.

Tool Description
book_create_or_update Create a Book or update its metadata
book_list Paginated list of Book metadata
book_get Retrieve all pages of a Book
page_insert Push an atomic page into a Book; embeds immediately
page_update Replace a page's content; re-embeds
page_delete Remove a page (indices not re-numbered)
page_search Semantic search across all Books
readme Returns the usage guide (call once per session)

Quick Start

Prerequisites

1. Set up the database

CREATE DATABASE contextbook_db;
\c contextbook_db
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS pg_trgm;

Migrations run automatically on API server startup.

2. Configure environment

cp .env.example backend/.env
# Edit backend/.env โ€” set DATABASE_URL, API_KEY_SALT, VOYAGE_API_KEY

3. Run the backend

cd backend
go run ./cmd/api/main.go    # API + dashboard (:8080)
go run ./cmd/mcp/main.go     # MCP server (:8081)

4. Run the frontend (optional)

cd frontend
npm install && npm run dev    # Vite dev server on :5173

5. Connect an AI client

For Cursor (.cursor/mcp.json):

{
  "mcpServers": {
    "contextbook": {
      "url": "http://localhost:8081/mcp"
    }
  }
}

For any MCP-compatible client, point the server URL to http://localhost:8081/mcp.

Documentation

  • Backend README โ€” API routes, auth flows, database schema, MCP tools, configuration
  • Frontend README โ€” components, routing, design system, development setup
  • Architecture โ€” full system overview with Mermaid diagrams

Project Structure

context-book/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ cmd/api/main.go          REST API + auth server
โ”‚   โ”œโ”€โ”€ cmd/mcp/main.go          MCP tool server
โ”‚   โ””โ”€โ”€ internal/
โ”‚       โ”œโ”€โ”€ api/                  REST handlers + routes
โ”‚       โ”œโ”€โ”€ auth/                 OAuth 2.0 PKCE, sessions, SSO
โ”‚       โ”œโ”€โ”€ context/              Book/Page business logic
โ”‚       โ”œโ”€โ”€ db/                  pgx queries + migrations
โ”‚       โ”œโ”€โ”€ embedding/            Voyage AI client
โ”‚       โ”œโ”€โ”€ logger/               slog + HTTP access logging
โ”‚       โ””โ”€โ”€ mcp/                  8 MCP tool handlers
โ”œโ”€โ”€ frontend/                     React 19 + Vite + TypeScript SPA
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ App.tsx               Router + app shell
โ”‚       โ”œโ”€โ”€ lib/api.ts            HTTP client
โ”‚       โ””โ”€โ”€ components/           UI components
โ”œโ”€โ”€ Dockerfile                    API server container
โ”œโ”€โ”€ Dockerfile.mcp                MCP server container
โ””โ”€โ”€ go.work                       Go workspace

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Make your changes
  4. Ensure the backend compiles (cd backend && go build ./cmd/api ./cmd/mcp)
  5. Ensure the frontend builds (cd frontend && npm run build)
  6. Commit and push
  7. Open a Pull Request

License

MIT โ€” see the LICENSE file for details.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured