Markdown RAG MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add -e "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}" markdown-rag -- uv run --directory /absolute/path/to/markdown-rag markdown-rag /absolute/path/to/docs --command mcp
Required:POSTGRES_PASSWORD+ 7 optional
README.md

A Retrieval Augmented Generation system for markdown documentation

Markdown RAG

A Retrieval Augmented Generation (RAG) system for markdown documentation with intelligent rate limiting and MCP server integration.

Features

  • Semantic Search: Vector-based similarity search using Google Gemini or Ollama embeddings
  • Markdown-Aware Chunking: Intelligent document splitting that preserves semantic boundaries
  • Rate Limiting: Sophisticated sliding window algorithm with token counting and batch optimization
  • MCP Server: Model Context Protocol server for AI assistant integration
  • PostgreSQL Vector Store: Scalable storage using pgvector extension
  • Incremental Updates: Smart deduplication prevents reprocessing existing documents
  • Production Ready: Type-safe configuration, comprehensive logging, and error handling

Installation

git clone https://github.com/yourusername/markdown-rag.git

Prerequisites

  • Python 3.11+
  • PostgreSQL 12+ with pgvector extension installed
  • Google Gemini API key (if using Google embeddings)
  • Ollama (if using local embeddings)
  • MCP-compatible client (Claude Desktop, Cline, etc.)

Quick Start

1. (Optional) Set Up PostgreSQL

createdb embeddings

If you do not create a database, the tool will create one for you. The pgvector extension will be automatically enabled when you first run the tool.

2. Ingest Documents

cd markdown-rag
# Use Google Gemini
uv run markdown-rag /path/to/docs --command ingest --engine google
# Or use Ollama
uv run markdown-rag /path/to/docs --command ingest --engine ollama

Required environment variables (create .env or export):

POSTGRES_PASSWORD=your_password
GOOGLE_API_KEY=your_gemini_api_key  # Only if using Google engine

3. Configure MCP Client

Add to your MCP client configuration (e.g., claude_desktop_config.json). The client will automatically start the server.

Minimal configuration:

{
  "mcpServers": {
    "markdown-rag": {
      "command": "uv",
      "args": [
        "run",
        "--directory"
        "/absolute/path/to/markdown-rag",
        "markdown-rag",
        "/absolute/path/to/docs",
        "--command",
        "mcp"
      ],
      "env": {
        "POSTGRES_PASSWORD": "your_password",
        "GOOGLE_API_KEY": "your_api_key"
      }
    }
  }
}

Full configuration:

{
  "mcpServers": {
    "markdown-rag": {
      "command": "uv",
      "args": [
        "run",
        "--directory"
        "/absolute/path/to/markdown-rag",
        "markdown-rag",
        "/absolute/path/to/docs",
        "--command",
        "mcp"
      ],
      "env": {
        "POSTGRES_USER": "postgres_username",
        "POSTGRES_PASSWORD": "your_password",
        "DISABLED_TOOLS": "delete_document,update_document",
        "CHUNK_OVERLAP": 50,
        # Google Configuration
        "GOOGLE_API_KEY": "your_api_key",
        "GOOGLE_MODEL": "models/gemini-embedding-001",
        "RATE_LIMIT_REQUESTS_PER_DAY": "1000",
        "RATE_LIMIT_REQUESTS_PER_MINUTE": "100",
        # Ollama Configuration
        "OLLAMA_HOST": "http://localhost:11434",
        "OLLAMA_MODEL": "mxbai-embed-large",
      }
    }
  }
}

4. Query via MCP

The server exposes several tools:

query
  • Semantic search over documentation
  • Arguments: query (string), num_results (integer, optional, default: 4)
list_documents
  • List all ingested documents
  • Arguments: none
delete_document
  • Remove a document from the index
  • Arguments: filename (string)
update_document
  • Re-ingest a specific document
  • Arguments: filename (string)
refresh_index
  • Scan directory and ingest new/modified files
  • Arguments: none

To disable tools (e.g., in production), set DISABLED_TOOLS environment variable:

DISABLED_TOOLS=delete_document,update_document,refresh_index

Configuration

Environment Variables

Variable Default Required Description
POSTGRES_USER postgres No PostgreSQL username
POSTGRES_PASSWORD - Yes PostgreSQL password
POSTGRES_HOST localhost No PostgreSQL host
POSTGRES_PORT 5432 No PostgreSQL port
POSTGRES_DB [engine]_embeddings No Database name
GOOGLE_API_KEY - Yes* Google Gemini API key (*if using Google)
GOOGLE_MODEL models/gemini... No Google embedding model
OLLAMA_HOST http://localhost... No

Tools (5)

queryPerform a semantic search over documentation.
list_documentsList all ingested documents.
delete_documentRemove a document from the index.
update_documentRe-ingest a specific document.
refresh_indexScan directory and ingest new or modified files.

Environment Variables

POSTGRES_PASSWORDrequiredPostgreSQL password
GOOGLE_API_KEYGoogle Gemini API key (if using Google engine)
POSTGRES_USERPostgreSQL username
POSTGRES_HOSTPostgreSQL host
POSTGRES_PORTPostgreSQL port
POSTGRES_DBDatabase name
GOOGLE_MODELGoogle embedding model
OLLAMA_HOSTOllama host URL

Configuration

claude_desktop_config.json
{"mcpServers": {"markdown-rag": {"command": "uv", "args": ["run", "--directory", "/absolute/path/to/markdown-rag", "markdown-rag", "/absolute/path/to/docs", "--command", "mcp"], "env": {"POSTGRES_PASSWORD": "your_password", "GOOGLE_API_KEY": "your_api_key"}}}}

Try it

Search the documentation for how to configure the rate limiter.
List all the documents currently indexed in the system.
Refresh the index to include the latest changes in my markdown files.
Delete the document named 'old-notes.md' from the index.

Frequently Asked Questions

What are the key features of Markdown RAG?

Semantic search using Google Gemini or Ollama embeddings. Markdown-aware chunking for better semantic boundaries. Scalable vector storage using PostgreSQL and pgvector. Sophisticated rate limiting with sliding window algorithm. Incremental updates with smart deduplication.

What can I use Markdown RAG for?

Enabling AI assistants to answer questions based on private markdown documentation. Maintaining a searchable knowledge base of technical project notes. Automating the indexing of evolving documentation directories. Integrating local or cloud-based semantic search into development workflows.

How do I install Markdown RAG?

Install Markdown RAG by running: git clone https://github.com/yourusername/markdown-rag.git

What MCP clients work with Markdown RAG?

Markdown RAG works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Markdown RAG docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare