closed-book-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@closed-book-mcp Answer this based only on the PDFs provided."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Zero-Hallucination, Closed-Book Retrieval Engine via Model Context Protocol (MCP)
A lightning-fast, local Retrieval-Augmented Generation (RAG) system built on the Model Context Protocol (MCP). ClosedBook enforces authoritative, ground-truth retrieval over your local documents (PDFs, manuals, SOPs, study materials) using Hybrid Search (Dense Semantic + BM25Okapi)—completely cutting out hallucinations and overriding unverified model assumptions.
This software is provided for educational, research, and audit purposes only. The creator assumes no responsibility for misuse of this software, including academic dishonesty or unauthorized use during proctored examinations. Always use responsibly.
Features
Hybrid Search Architecture: Combines
BAAI/bge-small-en-v1.5(semantic understanding) withBM25Okapi(exact keyword matching) to catch tricky legal or technical phrasing.Strict Closed-Book Mode: Forces the AI to rely entirely on the provided PDFs, ignoring conflicting pretrained knowledge (perfect for exams where the textbook has specific/outdated answers).
100% Local Privacy: Runs embedding and vector searches locally on your CPU using
faiss-cpu. No cloud API required.Agent Integration: Plugs directly into the Antigravity AI agent framework or any MCP-compatible client.
Related MCP server: PDF RAG MCP Server
Prerequisites
Before you begin, ensure you have met the following requirements:
You have installed Python 3.12+.
You have installed uv (an extremely fast Python package installer and resolver).
Getting Started
1. Install Dependencies
Clone the repository, navigate to the folder, and run:
uv sync2. Add Your Study Materials
Place your exam study materials (PDFs) into the resources/ directory.
mkdir -p resources
# copy your PDFs here (e.g., cp ~/Downloads/lecture_slides.pdf resources/)3. Build the Search Index
Run the ingestion script to chunk your PDFs and generate the vector embeddings.
uv run ingest.pyOn the first run, it will automatically download a ~130MB embedding model from Hugging Face.
4. Configure Antigravity (or your MCP Client)
Open your Antigravity MCP configuration file (typically ~/.gemini/config/mcp_config.json) and add this server block. Make sure to update the absolute path to point to your cloned repository:
{
"mcpServers": {
"mcp_closed_book": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/ExamMCP",
"run",
"server.py"
]
}
}
}Usage
Once the MCP server is configured and your AI Agent is restarted, it will automatically detect the rules in GEMINI.md.
Simply batch paste your multiple-choice questions into the chat:
1. According to the act, no suit or prosecution shall lie against whom?
A) The contractor
B) Any person acting in good faith
C) The court
D) The victimThe AI will run parallel background searches against your PDF index and immediately output the correct option based only on the text.
Customizing
If you are forking this repo for your own exams, here is what you need to change:
The PDFs (
resources/): Delete the existing PDFs and replace them with your own study guides, lecture slides, or textbooks.Chunking Size (
ingest.py): By default, the system uses 1000-character chunks with a 200-character overlap. If your exam requires extreme precision (like math formulas), you may want to decrease chunk size.The System Prompt (
GEMINI.md): The rootGEMINI.mdfile contains the strict rules for the AI. If your exam requires essay-style answers instead of Multiple Choice (MCQ), editGEMINI.mdand change the instructions to output detailed paragraphs instead of just "Option A".Rebuild the Index: Whenever you change your PDFs, you must run
uv run ingest.pyagain!
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Available Tools
3 toolsclosed_book_searchA
Search the authoritative study materials using Hybrid Search. The returned content comes directly from the user's PDFs. This is the primary knowledge retrieval tool for closed-book questions.
Inputs: query (required), top_k. Returns: result
list_indexed_documentsA
Return all indexed PDFs and their page counts.
Inputs: no named parameters. Returns: result
read_document_pageB
Return the complete extracted text of a specific page from a document.
Inputs: page (required), document (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clear, non-overlapping purpose: search across documents, read a specific page, and list available documents. There is no ambiguity about which tool to use for a given task.
All tool names follow a consistent verb_noun pattern (closed_book_search, read_document_page, list_indexed_documents) using lowercase with underscores. The naming is uniform and predictable.
With exactly three tools, the server is well-scoped for its purpose of closed-book document retrieval. Each tool serves a distinct necessary function without redundancy or bloat.
The tool set covers the full workflow: discover available documents, search their contents, and read specific pages. This is sufficient for the stated domain of closed-book question answering over PDFs.
Maintenance
Related MCP Connectors
Private, multimodal knowledge store for agents: hybrid search with cited, provenance-backed results.
Search your knowledge bases from any AI assistant using hybrid RAG.
Ingest, manage, and retrieve documents for RAG-powered AI applications
Query your own PDFs and documents from any MCP client. Every answer cites the page it came from.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to search and query PDF documents through a local RAG system with vector embeddings. Provides semantic document search capabilities while keeping all data stored locally without external dependencies.-
- AlicenseNot gradedqualityDmaintenanceEnables intelligent search and question-answering over PDF documents using semantic similarity and keyword search. Supports OCR for scanned PDFs, persistent vector storage with ChromaDB, and maintains source tracking with page numbers.6MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI-powered querying of PDF documents using hybrid retrieval (BM25 + vector search) and retrieval-augmented generation, returning structured answers with source citations and confidence scores.-
- FlicenseNot gradedqualityDmaintenanceEnables intelligent ingestion and querying of PDF, Markdown, and text files using hybrid search that combines keyword matching and semantic embeddings with citations.2-