Skip to main content
Glama
SMGilliatt

Knowledge Assistant MCP Server

by SMGilliatt

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.md

Setup

Prerequisites: Python 3.13, uv.

Clone the repository

git clone https://github.com/YOUR_USERNAME/knowledge-assistant-mcp.git
cd knowledge-assistant-mcp

Install dependencies with uv

uv sync

This creates a virtual environment (Python 3.13) and installs dependencies from pyproject.toml.

Configure environment variables

cp .env.sample .env

Edit .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 stdio

HTTP:

uv run python -m src.server --transport http --port 8000

Or use the entry point:

uv run knowledge-assistant-mcp --transport stdio

You 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

GOOGLE_API_KEY

Yes

Google AI (Gemini) API key – Google AI Studio

OPIK_API_KEY

No

Opik API key for observability – Opik

OPIK_PROJECT_NAME

No

Opik project name (default: knowledge-assistant)

MODEL_NAME

No

Gemini model (default: gemini-2.0-flash)

CHROMA_PERSIST_DIR

No

ChromaDB persistence directory (default: ./chroma_data)

CHROMA_COLLECTION

No

ChromaDB collection name (default: knowledge_base)

RAG_TOP_K

No

Number of chunks to retrieve (default: 5)

EMBEDDING_MODEL

No

Google embedding model for RAG (default: models/gemini-embedding-001)


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):

  1. Add documents (optional but needed for RAG answers)
    Use the add_documents tool: pass text (the content to ingest) and optionally source (e.g. "Context Engineering Book"). The server chunks and embeds the text into ChromaDB. You can add more documents anytime.

  2. 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.

  3. Human-in-the-loop
    Review the proposal, then call approve_or_edit_answer:

    • To accept: approved=True, same proposal_answer as returned.

    • To request changes: approved=False, same proposal_answer, and set user_feedback to 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_base and add_documents; persistence via CHROMA_PERSIST_DIR.

  • MCP resourceknowledge-assistant://server_info exposes 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_answer before finalizing.

  • Structured outputs – Pydantic models (AnswerProposal, SearchResult, RetrievedChunk, SynthesisResult) for synthesizer and API responses.

  • Observability (Opik) – Optional tracing when OPIK_API_KEY is 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 stdio

For 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 8000

License

MIT (or your chosen license).

Available Tools

4 tools
add_documentsA

Add a document (text) to the knowledge base. Use source to label where it came from.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYes
sourceNouser_input

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose any behavioral traits beyond the basic action. It does not mention whether the operation is idempotent, requires authentication, overwrites existing documents, or how it handles duplicates—critical context for a write operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with no filler or redundant information. It front-loads the primary action and then clarifies the optional parameter in a direct, efficient manner.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with only two parameters and an output schema exists, so the description does not need to explain return values. However, the lack of behavioral transparency (e.g., side effects, permissions) leaves gaps for a write operation, making the description minimally complete for its complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds value by explaining that 'text' is the document content and 'source' is a label for provenance. This goes beyond the schema's type and default information, providing meaningful semantic context for both parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: adding a text document to the knowledge base. It uses a specific verb ('Add') and resource ('knowledge base'), and the purpose is distinct from sibling tools that query, search, or approve.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context that this tool is for adding documents, implying it should be used when you want to insert new content rather than retrieve or edit existing content. It does not explicitly mention alternatives or exclusions, but the purpose is self-evident enough to guide usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
approvedYes
user_feedbackNo
proposal_answerYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It explains the decision logic (approved=True/False) and that user_feedback is needed for edits, which is useful. However, it does not disclose side effects, whether approval modifies the knowledge base, or any permissions/irreversibility. The tool's outcome beyond the parameters is left implicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences with no filler. It front-loads the core purpose ('Human-in-the-loop') and immediately provides the usage pattern. Every phrase contributes to understanding the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 params, 2 required) and the existence of an output schema, the description is adequate but not rich. It covers the branching logic and references the source (query_knowledge_base), but omits preconditions, post-conditions, or what happens next in the pipeline. This leaves room for agent confusion about workflow integration.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It explains 'approved' (accept or request changes) and 'user_feedback' (changes to request), but 'proposal_answer' is only indirectly referenced as 'the proposed answer'. While this adds meaning beyond the empty schema, one parameter remains underspecified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: to approve or request edits for an answer proposed by query_knowledge_base. It uses a specific verb ('approve', 'request edits') and identifies the resource ('the proposed answer'), distinguishing it from sibling tools like query_knowledge_base, add_documents, and search_knowledge_base.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the use case: after obtaining a proposal from query_knowledge_base, this tool decides on acceptance or revision. It gives clear context ('Human-in-the-loop') and ties the tool to a parent process, but does not explicitly name alternatives or state when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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).

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
top_kNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It goes beyond a simple query by revealing the multi-agent orchestration, the fact that the answer is only a proposal, and the human-in-the-loop requirement. This gives the agent a clear understanding of the tool's non-final and collaborative nature.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences long, each serving a distinct purpose: stating the action, explaining the internal pipeline, and providing the next-step workflow. It is front-loaded with the primary purpose and contains no redundant or irrelevant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is largely complete for a query tool: it covers the action, the pipeline, and the follow-up workflow. The existence of an output schema means return values need not be detailed. However, the missing parameter semantics for 'top_k' and the lack of explicit contrast with search_knowledge_base leave minor gaps in overall completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for parameter meaning. The 'query' parameter is implicitly explained as the question to ask, but 'top_k' is not mentioned at all, leaving its role (e.g., number of retrieved documents) ambiguous. This is a significant gap given the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Ask') and resource ('knowledge assistant'), and clearly explains the multi-agent pipeline (coordinator -> retriever -> synthesizer). It distinguishes the tool from siblings by mentioning it returns a proposed answer for review, which is unlike a direct search or an approval tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear workflow context by instructing the user to call approve_or_edit_answer after reviewing, which implicitly indicates a sequential use. However, it does not explicitly differentiate when to use this tool versus search_knowledge_base, missing the 'when-not' guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_knowledge_baseA

Search the knowledge base only (retriever); returns chunks without generating an answer.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
top_kNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the key behavioral trait that this is a retriever-only tool returning chunks, which is significant. However, it does not detail output format or any limitations, but the output schema exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that is front-loaded and contains no unnecessary words. It effectively communicates the core behavior.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple search tool with an output schema, the description is fairly complete. It clearly states the retriever-only nature and what is returned (chunks), but could more explicitly address when to use it over siblings. Still, the phrase 'only (retriever)' provides a hint.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description does not explain what 'query' or 'top_k' mean. While 'query' is self-evident from the tool name, 'top_k' is ambiguous. The description provides no additional meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches the knowledge base and returns chunks without generating an answer. This distinguishes it from sibling tools like query_knowledge_base, which presumably generates answers.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use this tool ('only retriever', 'without generating an answer') but does not explicitly name alternatives or provide exclusion criteria. It gives clear context, though a direct pointer to query_knowledge_base would be stronger.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv0.1.0
    • First observedadd_documents
    • First observedapprove_or_edit_answer
    • First observedquery_knowledge_base
    • First observedsearch_knowledge_base

TDQS

A4.2/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness4/5

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

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    A 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.
    3
    1
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    MCP 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.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    MCP server for local RAG over personal notes, PDFs, and documents, enabling plain-English querying and hybrid search with multi-hop context expansion.
    MIT

Latest Blog Posts

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/SMGilliatt/knowledge-assistant-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server