Knowledge Assistant MCP Server
Provides integration with Google's Gemini models for natural language generation and embeddings, enabling the MCP server to perform LLM-based tasks and generate embeddings for document retrieval.
Provides integration with LangChain for building retrieval-augmented generation (RAG) pipelines, connecting to ChromaDB vector store and orchestrating document retrieval and synthesis.
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., "@Knowledge Assistant MCP Server What is the main topic of the uploaded research paper?"
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.
Knowledge Assistant MCP Server
A multi-agent RAG (Retrieval-Augmented Generation) MCP server built with FastMCP in Python. It answers questions from your documents using a coordinator, retriever, and synthesizer agents, and includes a human-in-the-loop step where you approve or request edits before finalizing answers.
What it does
Query your knowledge base: Ask questions in natural language; the server retrieves relevant chunks and proposes an answer with citations.
Multi-agent pipeline: A coordinator decides whether to use the knowledge base, a retriever (RAG) fetches relevant documents, and a synthesizer produces a structured answer proposal.
Human-in-the-loop: You review the proposed answer and either approve it or request edits before the answer is finalized.
Add documents: Ingest text into the vector store (ChromaDB) so the assistant can answer from your own content.
Use cases: Internal knowledge assistant, FAQ over your docs, Q&A over notes or wikis, and similar RAG workflows that require a human approval step.
Related MCP server: Modular RAG System
Project Structure
knowledge-assistant-mcp/
├── src/
│ ├── server.py # FastMCP app entry point
│ ├── config/
│ │ └── settings.py # pydantic-settings (server name, API keys, model, RAG settings)
│ ├── routers/
│ │ ├── tools.py # Register MCP tools
│ │ ├── resources.py # Register MCP resources
│ │ └── prompts.py # Register MCP prompts
│ ├── tools/ # Tool implementations
│ ├── resources/ # Resource implementations
│ ├── prompts/ # Prompt content (workflow with human-in-the-loop)
│ ├── app/ # Core logic: RAG, LLM, orchestrator (coordinator/retriever/synthesizer)
│ ├── models/ # Pydantic schemas (structured outputs)
│ └── utils/ # Helpers (e.g. Opik)
├── pyproject.toml
├── .env.sample
├── Dockerfile
└── README.mdSetup
Prerequisites: Python 3.13, uv.
Clone the repository
git clone https://github.com/YOUR_USERNAME/knowledge-assistant-mcp.git
cd knowledge-assistant-mcpInstall dependencies with uv
uv syncThis creates a virtual environment (Python 3.13) and installs dependencies from pyproject.toml.
Configure environment variables
cp .env.sample .envEdit .env and set at least:
GOOGLE_API_KEY(required): Used for Gemini (LLM and embeddings).
Get it from Google AI Studio.
Optional:
OPIK_API_KEY: For observability (tracing). Get it from Opik.OPIK_PROJECT_NAME: Opik project name (default:knowledge-assistant).MODEL_NAME: Gemini model (default:gemini-2.0-flash).CHROMA_PERSIST_DIR: Directory for ChromaDB (default:./chroma_data).CHROMA_COLLECTION: Collection name (default:knowledge_base).RAG_TOP_K: Number of chunks to retrieve (default:5).EMBEDDING_MODEL: Google embedding model for RAG (default:models/gemini-embedding-001). Override if your API uses a different model.
Run the server
Stdio (for Cursor / Claude Desktop):
uv run python -m src.server --transport stdioHTTP:
uv run python -m src.server --transport http --port 8000Or use the entry point:
uv run knowledge-assistant-mcp --transport stdioYou should see the FastMCP banner and the process waiting for connections; stop with Ctrl+C.
Environment variables
Variables you can set in .env, and where to get API keys:
Environment variables summary
Variable | Required | Description |
| Yes | Google AI (Gemini) API key – Google AI Studio |
| No | Opik API key for observability – Opik |
| No | Opik project name (default: |
| No | Gemini model (default: |
| No | ChromaDB persistence directory (default: |
| No | ChromaDB collection name (default: |
| No | Number of chunks to retrieve (default: |
| No | Google embedding model for RAG (default: |
Connecting from Cursor (or another MCP client)
Add this to your Cursor MCP settings (e.g. .cursor/mcp.json), replacing the path and API key as needed:
{
"mcpServers": {
"knowledge-assistant": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/knowledge-assistant-mcp",
"run",
"python",
"-m",
"src.server",
"--transport",
"stdio"
],
"env": {
"GOOGLE_API_KEY": "your-google-api-key-here"
}
}
}
}You can also rely on a .env file in the project directory and omit env or only set ENV_FILE_PATH if your client supports it.
How to use
Once the server is running and connected (e.g. in Cursor):
Add documents (optional but needed for RAG answers)
Use the add_documents tool: passtext(the content to ingest) and optionallysource(e.g."Context Engineering Book"). The server chunks and embeds the text into ChromaDB. You can add more documents anytime.Ask a question
Use the query_knowledge_base tool with your question. The server runs the multi-agent pipeline (coordinator → retriever → synthesizer) and returns a proposed answer with citations.Human-in-the-loop
Review the proposal, then call approve_or_edit_answer:To accept:
approved=True, sameproposal_answeras returned.To request changes:
approved=False, sameproposal_answer, and setuser_feedbackto your requested edits. The server can then produce a revised answer.
You can also use search_knowledge_base to only search the vector store (no generated answer), and the knowledge_assistant_workflow prompt as a step-by-step guide. The resource knowledge-assistant://server_info exposes server metadata and RAG settings.
Features
Core:
FastMCP server (src/server.py) with tools (query_knowledge_base, approve_or_edit_answer, add_documents, search_knowledge_base), one workflow prompt (knowledge_assistant_workflow) with a human-in-the-loop step (review proposal → approve or edit via approve_or_edit_answer), uv-based setup, and the structure above. No API keys in the repo; .env.sample and .gitignore are included.
Additional:
Multi-agent orchestration – Coordinator, retriever (RAG), and synthesizer agents in
src/app/orchestrator.py.RAG with vector database – ChromaDB + LangChain + Google embeddings;
search_knowledge_baseandadd_documents; persistence viaCHROMA_PERSIST_DIR.MCP resource –
knowledge-assistant://server_infoexposes server name, version, collection, and RAG settings.Human-in-the-loop validation – Workflow returns a proposal; the user approves or requests edits with
approve_or_edit_answerbefore finalizing.Structured outputs – Pydantic models (
AnswerProposal,SearchResult,RetrievedChunk,SynthesisResult) for synthesizer and API responses.Observability (Opik) – Optional tracing when
OPIK_API_KEYis set.
Docker
Build and run with Docker:
docker build -t knowledge-assistant-mcp .
docker run --rm -e GOOGLE_API_KEY=your-key -v $(pwd)/chroma_data:/app/chroma_data knowledge-assistant-mcp --transport stdioFor HTTP on port 8000:
docker run --rm -p 8000:8000 -e GOOGLE_API_KEY=your-key -v $(pwd)/chroma_data:/app/chroma_data knowledge-assistant-mcp --transport http --port 8000License
MIT (or your chosen license).
Available Tools
4 toolsadd_documentsA
Add a document (text) to the knowledge base. Use source to label where it came from.
Inputs: text (required), source. Returns: object
approve_or_edit_answerA
Human-in-the-loop: approve the proposed answer from query_knowledge_base, or request edits. Set approved=True to accept, or approved=False and provide user_feedback for changes.
Inputs: approved (required), proposal_answer (required), user_feedback. Returns: object
query_knowledge_baseA
Ask the knowledge assistant a question. Runs a multi-agent pipeline: coordinator -> retriever (RAG) -> synthesizer. Returns a proposed answer for your review. After reviewing, call approve_or_edit_answer to approve or request edits (human-in-the-loop).
Inputs: query (required), top_k. Returns: object
search_knowledge_baseA
Search the knowledge base only (retriever); returns chunks without generating an answer.
Inputs: query (required), top_k. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: query_knowledge_base runs the full RAG pipeline and returns a proposed answer, search_knowledge_base performs raw retrieval only, approve_or_edit_answer handles the human-in-the-loop review step, and add_documents ingests new content. Although query and search both access the knowledge base, their outputs and workflows are fundamentally different and clearly described.
All tool names follow a consistent verb_noun pattern in snake_case: query_knowledge_base, approve_or_edit_answer, add_documents, search_knowledge_base. The naming is uniform and predictable, with no mixed conventions or ambiguous verbs.
With exactly 4 tools, the server is well-scoped for its purpose. Each tool addresses a distinct stage of the knowledge assistant workflow (ingestion, retrieval, synthesis, and review), and the count feels neither sparse nor bloated for the domain.
The core workflow is covered: add documents, search raw chunks, generate a proposed answer, and approve/request edits. However, there are minor gaps in document lifecycle management—no tools for deleting, updating, or listing documents—which could force workarounds in some use cases.
Maintenance
Related MCP Connectors
Impri MCP server — human-in-the-loop approval inbox for AI agents
Human-in-the-loop for AI agents over MCP: durable approvals with a hosted review page & audit trail
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseAqualityCmaintenanceA multi-agent Retrieval-Augmented Generation system exposed as an MCP server. Ask a question and a LangGraph pipeline plans the retrieval, pulls evidence from a pgvector knowledge base, optionally augments it with live web research, drafts a cited answer, and then self-critiques it for grounding — revising until the answer is supported by the sources.31MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for a modular RAG system that enables natural language question answering over enterprise documents with intent-aware routing, adaptive retrieval, and citation-backed responses.-
- AlicenseNot gradedqualityDmaintenanceMCP server providing tools for entity extraction, query refinement, and relevance checking to build Agentic RAG applications.MIT
- FlicenseNot gradedqualityDmaintenanceMCP server for a shared Postgres-backed knowledge base with hybrid retrieval and agentic RAG, enabling coding agents to upload, search, and ask questions over documents with cited answers.-