home / mcp / knowledge base mcp server

Knowledge Base MCP Server

Provides a local knowledge base with MCP tools to add, search, and manage documents using ChromaDB.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "july090-mcp": {
      "command": "python",
      "args": [
        "mcp_server.py"
      ],
      "env": {
        "PYTHONPATH": "."
      }
    }
  }
}

You can run a local knowledge base server that uses ChromaDB for fast vector-based search and expose MCP (Model Context Protocol) endpoints so AI assistants can directly add, search, and manage documents in your knowledge base.

How to use

Once your MCP client is connected, you can perform practical actions to manage and query your knowledge base. Add documents to the local store, search for relevant topics, and list or inspect the documents you have stored. The MCP tooling enables your AI assistant to call these actions directly without manual file handling, making it easy to keep answers grounded in your own documents.

How to install

Prerequisites you need on your system before starting:

- Python 3.10 or newer (3.12 is recommended) and a Unix-like shell or Windows PowerShell

Install the core dependencies for the knowledge base and MCP server:

pip install chromadb PyPDF2 PyMuPDF

Optional for better embedding performance (needs initial internet access to download models):

pip install sentence-transformers

Start the MCP server component for the knowledge base locally. Use the runtime command shown here to run the MCP server directly:

python mcp_server.py

Configure the MCP client to connect to your local MCP server. Use the JSON configuration snippet below in your MCP client setup to register the knowledge base service under a logical name like knowledge-base.

{
  "mcpServers": {
    "knowledge-base": {
      "command": "python",
      "args": ["mcp_server.py"],
      "env": {
        "PYTHONPATH": "."
      }
    }
  }
}

Additional configuration and MCP tools

The MCP setup includes a server config that exposes a set of tools for interacting with the knowledge base. These tools let you add documents, search, list, delete, and obtain statistics about your stored documents.

MCP tools available for this knowledge base:

  • add_document — Add a document to the knowledge base
  • search_documents — Search the knowledge base for relevant passages
  • list_documents — List all documents currently stored
  • delete_document — Remove a document from the knowledge base
  • get_stats — Retrieve storage and usage statistics
  • batch_add_documents — Add multiple documents in one operation

Security, maintenance, and troubleshooting

Security: All data remains in local storage by default for a private, on-premises setup. Ensure the documents and knowledge_base folders are protected by appropriate filesystem permissions.

Maintenance: Regularly back up the knowledge_base directory to preserve index data and stored documents.

Troubleshooting: If PDFs or text files fail to be read, verify you have PyPDF2 or PyMuPDF installed, and ensure documents are UTF-8 encoded.

If the MCP connection fails, confirm Python is on the system path and dependencies are installed. Restart the MCP server after making changes.

Available tools

add_document

Add a document to the knowledge base via MCP tooling, enabling future queries to consider its content.

search_documents

Query the knowledge base and return relevant passages based on vector similarities.

list_documents

Provide an overview of all documents currently stored in the local knowledge base.

delete_document

Remove a document from the knowledge base by name or identifier.

get_stats

Retrieve statistical information about stored documents, vectors, and storage usage.

batch_add_documents

Add multiple documents in a single operation to streamline setup.