SecondBrain MCP Server
Click on "Install 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., "@SecondBrain MCP ServerWhat did I learn about LangGraph last week?"
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.
๐ง SecondBrain AI
Production-Ready AI Personal Knowledge Assistant
An intelligent knowledge management system powered by Agentic RAG, LangGraph, Long-Term Memory, and the Model Context Protocol (MCP).
๐ Overview
SecondBrain AI is a production-ready AI knowledge assistant designed to transform personal documents into a searchable, conversational knowledge base.
Unlike a traditional chatbot, SecondBrain combines Retrieval-Augmented Generation (RAG), LangGraph-based agent orchestration, short-term and long-term memory, and the Model Context Protocol (MCP) to create an extensible AI assistant capable of understanding documents, remembering context across conversations, and exposing its capabilities to external AI clients.
The project follows a modular architecture with asynchronous document ingestion, background processing, vector search using Qdrant, persistent conversational memory through MongoDB, and containerized deployment using Docker Compose.
Related MCP server: idea-basin-mcp
โจ Key Highlights
๐ง Agentic RAG powered by LangGraph
๐ Upload and chat with PDF documents
๐ Semantic vector search using Qdrant
๐ง Persistent long-term memory with Mem0
๐ฌ Conversation state managed using MongoDB Checkpointer
โก FastAPI REST API
๐ Redis + RQ background workers
๐ Model Context Protocol (MCP) Server
๐ณ Fully Dockerized architecture
๐ Structured logging and centralized error handling
๐งช Smoke-tested production workflow
๐ Project Overview
SecondBrain AI is a production-ready personal knowledge assistant that enables users to build an intelligent, searchable knowledge base from their own documents. Instead of relying solely on a large language model's built-in knowledge, SecondBrain retrieves relevant information from user-provided content and generates grounded, context-aware responses.
The system is built around an Agentic Retrieval-Augmented Generation (RAG) architecture powered by LangGraph. User requests are orchestrated through a multi-step workflow that performs intent routing, semantic retrieval, memory lookup, and response generation before returning a final answer.
To support real-world usage, SecondBrain combines multiple components into a modular backend:
FastAPI for serving REST APIs
Qdrant for semantic vector search
MongoDB for conversation checkpoints and persistence
Mem0 for long-term memory management
Redis + RQ for asynchronous background processing
Docker Compose for reproducible deployment
Model Context Protocol (MCP) for integration with external AI clients
The project follows production-oriented software engineering practices including modular architecture, centralized logging, environment-based configuration, containerization, background workers, and automated smoke testing.
Rather than being a simple chatbot, SecondBrain demonstrates how modern AI systems combine retrieval, reasoning, memory, orchestration, and external tools to build scalable intelligent applications.
โจ Features
๐ง AI & Intelligence
Agentic Retrieval-Augmented Generation (RAG) powered by LangGraph
Semantic document retrieval using Qdrant Vector Database
Long-term memory using Mem0
Short-term conversational memory with MongoDB Checkpointer
Context-aware response generation using Google Gemini
Multi-step workflow orchestration for intelligent query handling
๐ Document Processing
PDF document ingestion
Automatic text extraction and cleaning
Intelligent document chunking
Embedding generation
Vector indexing for semantic search
โ๏ธ Backend & Infrastructure
FastAPI REST API
Asynchronous document processing using Redis + RQ
Modular service-oriented architecture
Centralized logging
Custom exception handling
Environment-based configuration
Production-ready Docker deployment
๐ Integrations
Model Context Protocol (MCP) Server
REST API endpoints
Command Line Interface (CLI)
๐งช Quality & Reliability
Smoke tests
Dockerized development environment
Persistent MongoDB storage
Persistent Qdrant storage
Modular project structure
๐๏ธ System Architecture
The following diagram illustrates the high-level architecture of SecondBrain AI.
SecondBrain follows a modular architecture where each component has a well-defined responsibility.
Component | Responsibility |
FastAPI | Exposes REST APIs |
LangGraph | Orchestrates the AI workflow |
Gemini | Generates responses |
Qdrant | Stores vector embeddings |
MongoDB | Stores conversation state |
Mem0 | Manages long-term memory |
Redis + RQ | Executes background jobs |
MCP Server | Exposes tools for external AI clients |
๐ Detailed Workflow
The following diagram illustrates the complete execution flow inside SecondBrain AI.
Request Flow
User
โ
โผ
FastAPI
โ
โผ
LangGraph Workflow
โ
โโโ Route Request
โโโ Retrieve Documents
โโโ Retrieve Memory
โโโ Grade Documents
โโโ Rewrite Query (if needed)
โโโ Generate Response
โโโ Store Conversation Memory
โ
โผ
Gemini LLM
โ
โผ
ResponseDocument Upload Flow
PDF Upload
โ
โผ
FastAPI
โ
โผ
Redis Queue
โ
โผ
RQ Worker
โ
โผ
PDF Loader
โ
โผ
Text Cleaning
โ
โผ
Chunking
โ
โผ
Gemini Embeddings
โ
โผ
Qdrant Vector StoreThis architecture separates document ingestion from user interaction, enabling scalable background processing while keeping the API responsive.
โ๏ธ Tech Stack
Category | Technologies |
Programming Language | Python 3.13 |
Backend Framework | FastAPI |
AI Framework | LangChain, LangGraph |
LLM | Google Gemini |
Embeddings | Gemini Embedding Model |
Vector Database | Qdrant |
Memory | Mem0, MongoDB Checkpointer |
Database | MongoDB |
Background Processing | Redis, RQ Worker |
Document Processing | PyPDF |
API Documentation | Swagger / OpenAPI |
Protocol | Model Context Protocol (MCP) |
Containerization | Docker, Docker Compose |
Configuration | Python Dotenv |
Testing | Smoke Tests |
Version Control | Git, GitHub |
๐ Project Structure
SecondBrain/
โ
โโโ secondbrain/
โ โโโ agent/ # Agent orchestration
โ โโโ agents/ # Specialized AI agents
โ โโโ api/ # FastAPI endpoints
โ โโโ cli/ # Command-line interface
โ โโโ core/ # Logging & exceptions
โ โโโ graph/ # LangGraph workflow
โ โโโ mcp_server/ # MCP server implementation
โ โโโ memory/ # Short & long-term memory
โ โโโ models/ # Request & response models
โ โโโ queues/ # Redis queue & worker
โ โโโ rag/ # RAG pipeline
โ โโโ tools/ # AI tools
โ โโโ data/ # Runtime data
โ โโโ main.py # FastAPI application
โ
โโโ tests/ # Smoke tests
โโโ assets/ # README images
โโโ logs/ # Application logs
โ
โโโ Dockerfile
โโโ docker-compose.yml
โโโ requirements.txt
โโโ pyproject.toml
โโโ .env.example
โโโ README.md๐ฆ Core Components
Module | Description |
RAG Pipeline | Document ingestion, chunking, embeddings, retrieval |
LangGraph | Agent workflow orchestration |
Memory | Short-term & long-term conversational memory |
FastAPI | REST API layer |
Redis Worker | Background document processing |
Qdrant | Vector similarity search |
MongoDB | Conversation persistence |
MCP Server | External AI tool integration |
๐ Installation & Quick Start
Prerequisites
Before getting started, ensure you have the following installed:
Python 3.13+
Docker & Docker Compose
Git
Google Gemini API Key
Clone the Repository
git clone https://github.com/MandarGavali/SecondBrain.git
cd SecondBrainConfigure Environment Variables
Create a .env file in the project root.
GOOGLE_API_KEY=your_google_api_key
MONGODB_URI=mongodb://localhost:27017
QDRANT_URL=http://localhost:6333
REDIS_URL=redis://localhost:6379Run with Docker (Recommended)
Start the complete application stack:
docker compose up --buildThis launches:
FastAPI Server
Redis
MongoDB
Qdrant
Background Worker
Swagger UI:
http://localhost:8000/docsRun Locally (Without Docker)
Create a virtual environment:
python -m venv venvActivate it.
Windows:
venv\Scripts\activateLinux / macOS:
source venv/bin/activateInstall dependencies:
pip install -r requirements.txtStart the FastAPI server:
uvicorn secondbrain.main:app --reloadStart the Redis worker in another terminal:
python -m secondbrain.queues.workerThe API will be available at:
http://localhost:8000Swagger UI:
http://localhost:8000/docs๐ณ Docker Deployment
SecondBrain is fully containerized using Docker Compose, making the entire application stack reproducible with a single command.
Containers
Container | Purpose |
| FastAPI application |
| Background document processing |
| Conversation state & memory |
| Vector database |
| Background job queue |
Start the Stack
docker compose up --buildRun in detached mode:
docker compose up -dStop the stack:
docker compose downRebuild after dependency changes:
docker compose up --build --force-recreateVerify Services
docker psExpected running containers:
secondbrain-api
secondbrain-worker
secondbrain-mongodb
secondbrain-qdrant
secondbrain-redis
Persistent Storage
Docker volumes are used to persist application data.
Volume | Stores |
| MongoDB data |
| Vector embeddings |
This ensures conversations and indexed documents remain available even after restarting the containers.
๐ก API Reference
Once the application is running, Swagger documentation is available at:
http://localhost:8000/docsREST Endpoints
Method | Endpoint | Description |
POST |
| Upload and index PDF documents |
POST |
| Chat with indexed documents |
GET |
| Check background processing status |
Example Upload Request
curl -X POST \
"http://localhost:8000/upload" \
-F "file=@document.pdf"Example Chat Request
POST /chat
{
"query": "Summarize the uploaded document."
}๐ Model Context Protocol (MCP) Integration
SecondBrain includes a dedicated Model Context Protocol (MCP) Server, allowing external AI clients (such as Claude Desktop, Cursor, VS Code, and other MCP-compatible applications) to interact directly with the knowledge base.
Instead of exposing only REST APIs, MCP enables AI assistants to invoke tools, retrieve documents, and access memory through a standardized protocol.
Available MCP Tools
Tool | Description |
| Query the complete RAG pipeline with memory support |
| Perform semantic search across indexed documents |
| Upload new documents to the knowledge base |
| Access and manage long-term memory |
MCP Capabilities
AI-assisted document search
Agentic RAG workflow execution
Long-term memory retrieval
Knowledge base interaction
Tool-based AI integration
Standardized MCP interface
MCP Architecture
AI Client
(Claude Desktop / Cursor / VS Code)
โ
โผ
MCP Server
โ
โผ
SecondBrain Tools
โ
โผ
LangGraph Workflow
โ
โโโโโโโโดโโโโโโโโโ
โผ โผ
MongoDB Qdrant
โ โ
โโโโโโโโฌโโโโโโโโโ
โผ
Google GeminiThe MCP server allows external AI systems to securely access the capabilities of SecondBrain without directly interacting with the internal application components.
๐ผ๏ธ Screenshots
System Architecture
Engineering Workflow
FastAPI Swagger UI
๐ง Future Improvements
SecondBrain is designed with extensibility in mind. Some planned enhancements include:
๐ Web-based user interface
๐ User authentication and role-based access control
๐ Support for additional document formats (DOCX, Markdown, HTML, TXT)
โ๏ธ Cloud storage integration (AWS S3, Google Cloud Storage)
๐ Hybrid Search (Semantic + Keyword Search)
โก Streaming responses using Server-Sent Events (SSE)
๐ Observability with Prometheus & Grafana
๐ Monitoring and analytics dashboard
๐งฉ Plugin architecture for custom tools
๐ค Multi-agent collaboration workflows
๐ฃ Voice input and speech synthesis
๐ Multi-language document support
๐ฑ Web and mobile client applications
๐ Kubernetes deployment for horizontal scaling
๐ค Contributing
Contributions are welcome!
If you'd like to improve SecondBrain, please follow these steps:
Fork the repository
Create a feature branch
git checkout -b feature/your-featureCommit your changes
git commit -m "Add new feature"Push to your branch
git push origin feature/your-featureOpen a Pull Request
Please ensure your code follows the existing project structure and coding style.
๐ License
This project is licensed under the MIT License.
See the LICENSE file for more information.
๐ Acknowledgements
This project was built using several outstanding open-source technologies.
Special thanks to the teams behind:
LangChain
LangGraph
Google Gemini
FastAPI
Qdrant
MongoDB
Redis
Mem0
Docker
Model Context Protocol (MCP)
Their work makes projects like SecondBrain possible.
โญ If you found this project interesting, consider giving it a star!
Built with โค๏ธ by Mandar Gavali
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MandarGavali/SecondBrain'
If you have feedback or need assistance with the MCP directory API, please join our Discord server