home / mcp / mcp rag mcp server
Provides multilingual document ingestion, vector search, and retrieval-augmented generation from diverse formats using a Postgres pgvector backend.
Configuration
View docs{
"mcpServers": {
"karaage0703-mcp-rag-server": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/mcp-rag-server",
"python",
"-m",
"src.main"
],
"env": {
"SOURCE_DIR": "./data/source",
"POSTGRES_DB": "ragdb",
"EMBEDDING_DIM": "1024",
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5432",
"POSTGRES_USER": "postgres",
"PROCESSED_DIR": "./data/processed",
"EMBEDDING_MODEL": "intfloat/multilingual-e5-large",
"POSTGRES_PASSWORD": "password",
"EMBEDDING_PREFIX_QUERY": "query: ",
"EMBEDDING_PREFIX_EMBEDDING": "passage: "
}
}
}
}You can run an MCP-based Retrieval-Augmented Generation server that indexes multilingual document formats, stores embeddings in a vector database, and serves answers by querying the indexed data. This guide shows practical steps to install, configure, and operate the server so you can power intelligent, context-aware document search and retrieval workflows.
Start the MCP server locally and connect with an MCP client to index your documents, run embeddings, and perform vector search. You can index multiple formats (Markdown, text, slides, PDFs) from a hierarchical source directory, then query with natural language to retrieve relevant chunks and full documents for richer context. Use the provided CLI tools to manage the index and inspect the number of documents stored. When you query, the search results can include surrounding context and full documents to improve accuracy and readability.
Prerequisites you need before installation are Python 3.10 or newer and PostgreSQL 14 or newer with the pgvector extension.
# If uv is not installed yet, install it (the runtime used to run the server)
pip install uv
# Install server dependencies (the package manager will resolve these)
uv syncEnvironment setup and server configuration help you tailor the MCP RAG server to your environment.
Configure your environment by creating a .env file with the following variables to connect to PostgreSQL and to set indexing behavior and embedding models.
# PostgreSQL connection
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_DB=ragdb
# Document sources
SOURCE_DIR=./data/source
PROCESSED_DIR=./data/processed
# Embedding model configuration
EMBEDDING_MODEL=intfloat/multilingual-e5-large
EMBEDDING_DIM=1024
EMBEDDING_PREFIX_QUERY="query: "
EMBEDDING_PREFIX_EMBEDDING="passage: "You can use built-in tools to search, count documents in the index, and manage the index lifecycle via the CLI.
Performs vector search on the indexed embeddings and returns top results with optional context and full documents.
Returns the number of documents currently stored in the index.
Indexes documents from the source directory, with options for chunk size, chunk overlap, and incremental indexing.