home / mcp / docs rag mcp server

Docs Rag MCP Server

Provides document-based RAG querying from a local docs directory using Git repositories and text files.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kazuph-mcp-docs-rag": {
      "command": "npx",
      "args": [
        "-y",
        "@kazuph/mcp-docs-rag"
      ],
      "env": {
        "DOCS_PATH": "/Users/username/docs",
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

You run a local Retrieval-Augmented Generation (RAG) MCP server that indexes documents in a specified directory and lets you query them with context from those documents. It supports both Git repositories and plain text files, and you can manage documents, perform RAG queries, and index new sources from the local machine.

How to use

You interact with the server through an MCP client to manage documents and perform queries. Start by ensuring your documents are available in your chosen local directory, then index or add new sources. Use the available tools to list documents, add new repositories or text files, and run RAG queries that return AI-generated answers grounded in your documents.

Key actions you can perform: - List documents to see what is available - Add Git repositories with optional sparse checkout - Add plain text files by URL - Run rag_query to obtain AI responses that include document context - Use helper prompts to guide how documents are used for responses

How to install

Prerequisites you need before installing:
- Node.js and npm installed on your system
- A local directory to store documents (default is ~/docs, but you can configure a different path via DOCS_PATH)
- A Gemini API key for indexing and querying (set GEMINI_API_KEY in your environment)
Install dependencies and build the server:
- Run: `npm install`
- Run: `npm run build
For development with auto-rebuild:
- Run: `npm run watch

Configure the MCP client to run the server. Use the provided MCP JSON snippet below to set the server up in your Claude Desktop client, replacing paths and keys with your own values.

{
  "mcpServers": {
    "docs_rag": {
      "command": "npx",
      "args": ["-y", "@kazuph/mcp-docs-rag"],
      "env": {
        "DOCS_PATH": "/Users/username/docs",
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Additional setup and usage notes

Environment variables: - DOCS_PATH: Path to the local directory containing documents. Default is ~/docs but you can customize it. - GEMINI_API_KEY: Your Google Gemini API key used for indexing and querying documents.

Usage tips: - Ensure the docs directory contains Git repositories or text files with a .txt extension to be indexed. - Use list_documents to verify what is available, then use add_git_repository or add_text_file to expand your data. - When running rag_query, provide a document_id and a natural-language query to get AI-generated results with document context.

Troubleshooting and notes

Debugging MCP servers is performed over stdio. If you need debugging tools, consider using the MCP Inspector to access debugging utilities in your browser.

Security: keep your GEMINI_API_KEY confidential and do not expose it in client configurations or public repositories.

Available tools

list_documents

List all available documents in the DOCS_PATH directory, returning a formatted list and the total count.

rag_query

Query documents using RAG, requiring a document_id and a text query; returns AI-generated results with context from documents.

add_git_repository

Clone a Git repository into the docs directory with optional sparse checkout and an optional custom document name; automatically pulls latest changes if the repository already exists.

add_text_file

Download a plain text file into the docs directory using its URL.

guide_documents_usage

Provide guidance on using documents and RAG features, including a list of available documents and usage tips for RAG queries.