mcpField
M
mcp-rag-server

mcp-rag-server

Local
github.com/kwanLeeFrmViMemory & Knowledge36Updated 80w ago

About mcp-rag-server

mcp-rag-server is an MCP server that adds Retrieval Augmented Generation to LLM clients. It indexes local documents and returns relevant chunks to the model through MCP. It stores vectors in a local SQLite store and supports several embedding providers.

Key features

  1. 01Indexes txt, md, json, jsonl and csv documents
  2. 02Configurable chunk size for text splitting
  3. 03Local vector store built on SQLite
  4. 04Supports OpenAI, Ollama, Granite and Nomic embeddings
  5. 05Exposes MCP tools and resources over stdio

Use cases

  1. 01Answering questions from a local document set with an LLM
  2. 02Building a searchable index of project documentation
  3. 03Running retrieval locally with an Ollama embedding model

MCP support

The project is an MCP server that exposes tools such as embedding_documents and query_documents, plus rag:// resources, to MCP clients.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"rag-server-kwanleefrmvi": {
"command": "npx",
"args": [
"-y",
"mcp-rag-server"
]
}
}
}
Run commandnpx -y mcp-rag-server

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmmcp-rag-server

Tools

5

Saved tool list · updated 3w ago

ParameterTypeRequiredDescription
pathstringYesPath containing .json, .jsonl, .txt, .md, .csv files to index

Details

From the project README

mcp-rag-server

npm version License Node.js Version

A Model Context Protocol (MCP) server that enables Retrieval Augmented Generation (RAG). It indexes your documents and serves relevant context to Large Language Models via the MCP protocol.

Integration Examples

Generic MCP Client Configuration
{
  "mcpServers": {
    "rag": {
      "command": "npx",
      "args": ["-y", "mcp-rag-server"],
      "env": {
        "BASE_LLM_API": "http://localhost:11434/v1",
        "EMBEDDING_MODEL": "nomic-embed-text",
        "VECTOR_STORE_PATH": "./vector_store",
        "CHUNK_SIZE": "500"
      }
    }
  }
}
Example Interaction
# Index documents
>> tool:embedding_documents {"path":"./docs"}

# Check status
>> resource:embedding-status

<< rag://embedding/status
Current Path: ./docs/file1.md
Completed: 10
Failed: 0
Total chunks: 15
Failed Reason:

Table of Contents

Features

  • Index documents in .txt, .md, .json, .jsonl, and .csv formats
  • Customizable chunk size for splitting text
  • Local vector store powered by SQLite (via LangChain's LibSQLVectorStore)
  • Supports multiple embedding providers (OpenAI, Ollama, Granite, Nomic)
  • Exposes MCP tools and resources over stdio for seamless integration with MCP clients

Installation

From npm
npm install -g mcp-rag-server
From Source
git clone https://github.com/kwanLeeFrmVi/mcp-rag-server.git
cd mcp-rag-server
npm install
npm run build
npm start

Quick Start

export BASE_LLM_API=http://localhost:11434/v1
export EMBEDDING_MODEL=granite-embedding-278m-multilingual-Q6_K-1743674737397:latest
export VECTOR_STORE_PATH=./vector_store
export CHUNK_SIZE=500

# Run (global install)
mcp-rag-server

# Or via npx
npx mcp-rag-server

💡 Tip: We recommend using Ollama for embedding. Install and pull the nomic-embed-text model:

ollama pull nomic-embed-text
export EMBEDDING_MODEL=nomic-embed-text

Configuration

VariableDescriptionDefault
BASE_LLM_APIBase URL for embedding APIhttp://localhost:11434/v1
LLM_API_KEYAPI key for your LLM provider(empty)
EMBEDDING_MODELEmbedding model identifiernomic-embed-text
VECTOR_STORE_PATHDirectory for local vector store./vector_store
CHUNK_SIZECharacters per text chunk (number)500

💡 Recommendation: Use Ollama embedding models like nomic-embed-text for best performance.

Usage

MCP Tools

Once running, the server exposes these tools via MCP:

  • embedding_documents(path: string): Index documents under the given path
  • query_documents(query: string, k?: number): Retrieve top k chunks (default 15)
  • remove_document(path: string): Remove a specific document
  • remove_all_documents(confirm: boolean): Clear the entire index (confirm=true)
  • list_documents(): List all indexed document paths
MCP Resources

Clients can also read resources via URIs:

  • rag://documents — List all document URIs
  • rag://document/{path} — Fetch full content of a document
  • rag://query-document/{numberOfChunks}/{query} — Query documents as a resource
  • rag://embedding/status — Check current indexing status (completed, failed, total)

How RAG Works

  1. Indexing: Reads files, splits text into chunks based on CHUNK_SIZE, and queues them for embedding.
  2. Embedding: Processes each chunk sequentially against the embedding API, storing vectors in SQLite.
  3. Querying: Embeds the query and retrieves nearest text chunks from the vector store, returning them to the client.

Development

npm install
npm run build      # Compile TypeScript
npm start          # Run server
npm run watch      # Watch for changes

Contributing

Contributions are welcome! Please open issues or pull requests on GitHub.

License

MIT 2025 Quan Le

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.