nancy-brain
Nancy's RAG backend and HTTP API/MCP server connectors.
claude mcp add --transport stdio amberlee2427-nancy-brain python -m nancy_brain.connectors.mcp_server \ --env ANTHROPIC_API_KEY="Optional: to enable document-level summaries during builds (set when using --summaries)" \ --env ENABLE_DOC_SUMMARIES="Set to true to enable summaries during builds (default false)"
How to use
Nancy Brain exposes an MCP server that integrates a retrieval-augmented knowledge base with the Model Context Protocol tooling. It loads repository content, documentation, notebooks, and examples from GitHub repositories you specify, builds embeddings, and exposes MCP-compatible tools for search, retrieval, tree navigation, and weighting. This allows AI agents and MCP clients to query code and docs with real repository content, enabling tasks such as extracting code snippets, locating usage examples, and weighting important documentation during conversations. The server is designed to work alongside the HTTP API and the local web admin UI for management and monitoring, making it suitable for rapid prototyping and non-technical collaboration as you curate the knowledge base for agents.
To use the MCP tools, start the server and connect via your MCP client. The server can be fed a set of repositories to index, then exposes MCP tools for search, retrieve, tree navigation, and weight manipulation. You can adjust chunking behavior and embedding models through environment variables and config, and optionally enable article and document-level summaries during builds to improve retrieval quality. The end result is a performant, MCP-enabled knowledge base that your AI agents can query for precise code examples, API usage, and architectural insights directly from your curated repositories.
How to install
Prerequisites:
- Python 3.8+ and pip
- Internet access to install dependencies from PyPI
- Optional: Anthropic API key if you plan to use document summaries
Step-by-step installation:
-
Create and activate a Python virtual environment (recommended): python3 -m venv venv source venv/bin/activate
-
Install Nancy Brain (which includes the MCP server components): pip install nancy-brain
-
Install optional development tools (if you intend to develop or run tests): pip install -e .[dev] # from a cloned repository, if applicable pytest -q
-
Run the MCP server (example): python -m nancy_brain.connectors.mcp_server
-
Optional: set environment variables for chunking and summaries before starting: export CHUNKY_LINES_PER_CHUNK=80 export CHUNKY_LINE_OVERLAP=10 export CHUNKY_MAX_CHARS=2000 export ANTHROPIC_API_KEY="sk-..." # if using Anthropic summaries export ENABLE_DOC_SUMMARIES=true
-
Verify installation by querying the MCP endpoint with your MCP client or by using the built-in UI (nancy-brain ui).
Notes:
- If you clone the repository locally for development, ensure you install in editable mode and have the necessary dev dependencies installed as described in the README.
- The MCP server is designed to avoid heavy ML imports at import time; tests can mock the embedding search to keep startup fast in minimal environments.
Additional notes
Tips and common issues:
- Ensure your environment variables for chunking and embedding models are set prior to builds to avoid default mismatch issues.
- If you enable doc summaries, expect a dependency on Anthropic (via ANTHROPIC_API_KEY) and understand that summaries are cached to improve performance on reruns.
- For large repositories, monitor build times and consider adjusting CHUNKY_MAX_CHARS or CHUNKY_LINES_PER_CHUNK to balance indexing speed and retrieval quality.
- If you experience issues starting the MCP server, check that the module path in the -m option matches the installed package structure (nancy_brain.connectors.mcp_server is a common layout for this project).
- The MCP tooling supports set_weight and other endpoints; consult the project docs for MCP tool usage and endpoint details.
Related MCP Servers
VectorCode
A code repository indexing tool to supercharge your LLM experience.
mcp-pinecone
Model Context Protocol server to allow for reading and writing from Pinecone. Rudimentary RAG
Archive-Agent
Find your files with natural language and ask questions.
pdf-rag
PDF RAG server for cursor.
code-memory
MCP server with local vector search for your codebase. Smart indexing, semantic search, Git history — all offline.
srag
Semantic code search and RAG system written in Rust with tree-sitter chunking, MCP server for IDE integration, prompt injection detection, and secret redaction