Docs RAG

by kazuph

3 stars
Not rated
GitHub

About

Enables AI to query and analyze local documents and Git repositories through a RAG system built with TypeScript, LlamaIndex, and Gemini embeddings.

Details

Author
kazuph
Repository
kazuph/mcp-docs-rag
GitHub stars
3
Categories
Developer Tools, Design, Workplace, File Management, AI, Search, Knowledge Base, API
Tags
#integration

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Docs RAG
    Command (node, npx, python, etc.) npx
    Arguments
    • Argument 1 -y
    • Argument 2 @kazuph/mcp-docs-rag
    Environment
    • DOCS_PATH /Users/username/docs
    • GEMINI_API_KEY your-api-key-here

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Once configured, you can use the server with Claude to:

1. Add documents:

   Add a new document from GitHub: https://github.com/username/repository

or with a custom document name:
   Add GitHub repository https://github.com/username/repository-name and name it 'framework'

or with sparse checkout of a specific directory:
   Add only the 'src/components' directory from https://github.com/username/repository

or combine custom name and sparse checkout:
   Add the 'examples/demo' directory from https://github.com/username/large-repo and name it 'demo-app'

or add a text file:
   Add this text file: https://example.com/document.txt

2. Query documents:

   What does the documentation say about X in the Y repository?

3. List available documents:

   What documents do you have access to?

The server will automatically handle indexing of documents for efficient retrieval.

list_documents

List all available documents in the DOCS_PATH directory. Returns a formatted list of all documents and shows the total number of available documents.

rag_query

Query documents using RAG. Takes document_id and query as parameters. Returns AI-generated responses with context from documents.

add_git_repository

Clone a Git repository to the docs directory with optional sparse checkout. Takes repository_url as parameter, with optional document_name to customize the name and optional subdirectory for sparse checkout.

add_text_file

Download a text file to the docs directory. Takes file_url as parameter and uses wget to download the file.

- list_documents - List all available documents in the DOCS_PATH directory
- Returns a formatted list of all documents
- Shows total number of available documents
- rag_query - Query documents using RAG
- Takes document_id and query as parameters
- Returns AI-generated responses with context from documents
- add_git_repository - Clone a Git repository to the docs directory with optional sparse checkout
- Takes repository_url as parameter
- Optional document_name parameter to customize the name of the document (use simple descriptive names without '-docs' suffix)
- Optional subdirectory parameter for sparse checkout of specific directories
- Automatically pulls latest changes if repository already exists
- add_text_file - Download a text file to the docs directory
- Takes file_url as parameter
- Uses wget to download file

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

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

Linux

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

Macos

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

Windows

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

mcp-docs-rag MCP Server

RAG (Retrieval-Augmented Generation) for documents in a local directory

This is a TypeScript-based MCP server that implements a RAG system for documents stored in a local directory. It allows users to query documents using LLMs with context from locally stored repositories and text files.

Features

Resources

- List and access documents via docs:// URIs - Documents can be Git repositories or text files - Plain text mime type for content access

Tools

- list_documents - List all available documents in the DOCS_PATH directory - Returns a formatted list of all documents - Shows total number of available documents - rag_query - Query documents using RAG - Takes document_id and query as parameters - Returns AI-generated responses with context from documents - add_git_repository - Clone a Git repository to the docs directory with optional sparse checkout - Takes repository_url as parameter - Optional document_name parameter to customize the name of the document (use simple descriptive names without '-docs' suffix) - Optional subdirectory parameter for sparse checkout of specific directories - Automatically pulls latest changes if repository already exists - add_text_file - Download a text file to the docs directory - Takes file_url as parameter - Uses wget to download file

Prompts

- guide_documents_usage - Guide on how to use documents and RAG functionality - Includes list of available documents - Provides usage hints for RAG functionality

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Setup

This server requires a local directory for storing documents. By default, it uses ~/docs but you can configure a different location with the DOCS_PATH environment variable.

Document Structure

The documents directory can contain:
- Git repositories (cloned directories)
- Plain text files (with .txt extension)

Each document is indexed separately using llama-index.ts with Google's Gemini embeddings.

API Keys

This server uses Google's Gemini API for document indexing and querying. You need to set your Gemini API key as an environment variable:

export GEMINI_API_KEY=your-api-key-here

You can obtain a Gemini API key from the Google AI Studio website. Add this key to your shell profile or include it in the environment configuration for Claude Desktop.

Installation

To use with Claude Desktop, add the server config:

On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
On Linux: ~/.config/Claude/claude_desktop_config.json

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

Make sure to replace /Users/username/docs with the actual path to your documents directory.

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:

npm run inspector

The Inspector will provide a URL to access debugging tools in your browser.

Usage

Once configured, you can use the server with Claude to:

1. Add documents:

   Add a new document from GitHub: https://github.com/username/repository

or with a custom document name:
   Add GitHub repository https://github.com/username/repository-name and name it 'framework'

or with sparse checkout of a specific directory:
   Add only the 'src/components' directory from https://github.com/username/repository

or combine custom name and sparse checkout:
   Add the 'examples/demo' directory from https://github.com/username/large-repo and name it 'demo-app'

or add a text file:
   Add this text file: https://example.com/document.txt

2. Query documents:

   What does the documentation say about X in the Y repository?

3. List available documents:

   What documents do you have access to?

The server will automatically handle indexing of documents for efficient retrieval.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.