rag-mcp
rag-mcp is a Retrieval-Augmented Generation MCP server that lets you ingest, store, and semantically search text using PostgreSQL + pgvector and any OpenAI-compatible embeddings (OpenAI, Azure, Ollama, llama.cpp).
Ingest Text: Chunk, embed, and store any text into a named collection, with optional JSON metadata per chunk.
Semantic Search: Query a collection with natural language and retrieve the top-k most relevant chunks, each with a 0–1 cosine similarity score.
List Collections: View all collections and their chunk counts.
Delete Collection: Permanently remove a collection and all its chunks (irreversible).
Configure: Customize database connection, embedding service, and chunking parameters via environment variables.
Integrate: Designed for any LLM agent or MCP client to ground responses in your documents.
Allows using local Ollama models for embedding generation, enabling offline or private semantic search.
Enables the MCP server to generate embeddings using OpenAI's embedding models for semantic search.
Provides the vector storage and search backend using pgvector for efficient cosine similarity queries.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@rag-mcp search my notes for 'project roadmap'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
rag-mcp
A RAG-over-docs MCP server: ingest text into collections, then let any LLM agent semantically search it. Backed by PostgreSQL + pgvector, embeddings via any OpenAI-compatible endpoint (OpenAI, Azure, or a local Ollama / llama.cpp server).
RAG is split the MCP-native way — this server owns retrieval (chunk → embed → store → cosine search); the calling model owns generation. Point Claude, ChatGPT, Cursor, or any MCP client at it and answers get grounded in your docs.
Tools
Tool | Purpose |
| Chunk, embed, and store text in a collection (with optional metadata) |
| Top-k semantic search over a collection; returns chunks + 0–1 cosine score |
| List collections and their chunk counts |
| Delete a collection and all its chunks |
| Re-embed a collection's stored content with the current embeddings backend, migrating dimension if needed |
Related MCP server: Chalee MCP RAG
Quickstart
# 1. Start Postgres + pgvector and the server
cp .env.example .env # set EMBEDDINGS_API_KEY
docker compose up -d --build
# — or run locally over stdio (e.g. for Claude Desktop) —
uv pip install --system .
docker compose up -d db # just the database
EMBEDDINGS_API_KEY=sk-... rag-mcpAdd to an MCP client (stdio):
{ "mcpServers": { "rag": { "command": "rag-mcp",
"env": { "EMBEDDINGS_API_KEY": "sk-...",
"DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/rag" } } } }Deployment overrides
docker-compose.yml publishes Postgres to 127.0.0.1:5432 only (not
0.0.0.0), so psql debugging from the host works but the database is never
reachable off-host. rag-mcp itself talks to it over the compose network as
db:5432. For further host-specific tweaks (e.g. dropping the port binding
entirely on a server where even loopback access isn't needed), copy
docker-compose.override.yml.example
to docker-compose.override.yml — it's gitignored and loaded automatically by
docker compose. Don't hand-edit the tracked docker-compose.yml or hide
local changes with git update-index --skip-worktree; either desyncs
git status/git diff from what's actually deployed and can silently block
fast-forward merges of upstream fixes.
Configuration
All via environment (see .env.example): DATABASE_URL,
POSTGRES_PASSWORD (must match the password in DATABASE_URL; set a real
secret on any host beyond local dev), EMBEDDINGS_API_BASE /
EMBEDDINGS_API_KEY / EMBEDDINGS_MODEL, EMBED_DIM
(must match your model's dimension — 1536 for text-embedding-3-small),
CHUNK_SIZE, CHUNK_OVERLAP, and MCP_TRANSPORT (stdio | http).
How it works
ingest_text splits text on natural boundaries with overlap, embeds each chunk,
and stores it in a chunks table with a vector(EMBED_DIM) column and an
ivfflat cosine index. search embeds the query and returns the nearest chunks
by cosine distance (<=>). Everything is namespaced by collection.
Switching embedding backends/dimensions
Changing EMBEDDINGS_PROVIDER, EMBEDDINGS_MODEL, or EMBED_DIM makes the
live chunks.embedding column mismatch the new config — the server detects
this at startup, logs it loudly, and search/ingest_text refuse to run
until it's resolved (list_collections/delete_collection are unaffected).
Recover by calling reindex_collection(collection) for every collection. It
re-embeds each row's stored content (bypassing ingest_text's chunking, so
existing chunk boundaries don't shift) with the currently configured backend.
If the new embedding width differs from the live column, your vectors are
staged in a hidden column rather than written live, so other, not-yet-migrated
collections keep serving search normally; once every collection has been
reindexed, the last call atomically swaps the staged column in as embedding
and rebuilds its index. The tool's response includes dimension_changed and
column_swapped so you can tell whether search/ingest_text are usable
again yet.
License
Copyright © 2026 Next Level Management Advisors, LLC.
Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) — see LICENSE. If you run a modified version over a network, the AGPL requires you to make your modified source available to its users.
Commercial licensing: to use this in a closed-source or commercial product, or to host a modified version without publishing your source, a commercial license is available — contact forrest@nlma.io.
Available Tools
4 toolsdelete_collectionA
Delete a collection and all of its chunks. Irreversible.
Inputs: collection (required). Returns: object
ingest_textA
Chunk, embed, and store text in a collection for later semantic search.
collection: logical namespace (e.g. a project or document set). metadata: optional JSON attached to every chunk (source, title, url, ...).
Inputs: text (required), collection (required), metadata. Returns: object
list_collectionsA
List all collections and their chunk counts.
Inputs: no named parameters. Returns: result
searchA
Semantic search a collection. Returns the top-k chunks with a 0-1 cosine score.
Inputs: query (required), collection (required), k. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct purpose: delete_collection removes a collection, ingest_text adds content, list_collections enumerates collections, and search queries them. There is no functional overlap.
All tool names follow a consistent verb_noun snake_case pattern (e.g., delete_collection, ingest_text, list_collections). Even 'search' fits as a verb describing the action.
With 4 tools, the server provides essential RAG operations (CRUD for collections plus search) without being too sparse or overly complex. This is appropriate for its purpose.
The tool surface covers the core workflow: list collections, ingest text, search, and delete. Missing update or get collection details, but these represent minor gaps that agents can work around.
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
Turn documents into structured, AI-ready data by parsing, enriching, chunking, and embedding.
Database for your AI agent. Turn its output into data, docs, skills, and apps you can actually use.
Versioned agent memory in your own Postgres: portable context, permissioned, audit trail.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables semantic search across text documents using vector embeddings stored in PostgreSQL. Provides multiple search modalities including semantic similarity, question/answer, and style-based search through a retrieval-augmented generation system.3Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables RAG (Retrieval-Augmented Generation) capabilities with document processing, vector storage, and intelligent Q\&A using OpenAI embeddings and semantic search.MIT
- AlicenseNot gradedqualityDmaintenanceEnables retrieval-augmented generation (RAG) by indexing and searching through documents (Markdown, text, PowerPoint, PDF) using vector embeddings with multilingual-e5-large model and PostgreSQL pgvector. Supports contextual chunk retrieval and incremental indexing for efficient document management.71MIT
- AlicenseNot gradedqualityDmaintenanceEnables uploading, organizing, and semantically searching documents with support for various file types and embedding providers.20 npmMIT