
RAG
STDIOMCP server providing RAG capabilities for LLMs using local document indexing.
MCP server providing RAG capabilities for LLMs using local document indexing.
mcp-rag-server is a Model Context Protocol (MCP) server that enables Retrieval Augmented Generation (RAG) capabilities for connected LLMs. It indexes documents from your project and provides relevant context to enhance LLM responses.
Built with Google Genkit, ChromaDB, and Ollama.
(Provide a minimal runnable example here, assuming Docker setup is complete)
# Example: Querying via an MCP client (conceptual) # (Actual usage depends on the client implementation)
.txt
, .md
, code files (via generic splitting), .json
, .jsonl
, .csv
. (Code file chunking is basic).nomic-embed-text
).indexDocuments
: Manually index a file or directory.queryDocuments
: Retrieve relevant document chunks for a query.removeDocument
: Remove a specific document's chunks by source path.removeAllDocuments
: Clear the entire index for the current project.listDocuments
: List indexed document source paths.docker-compose.yml
for easy setup of the server, ChromaDB, and Ollama.This method runs the server and its dependencies (ChromaDB, Ollama) in isolated containers.
Prerequisites:
8000
(ChromaDB) and 11434
(Ollama) are free on your host machine, or adjust ports in docker-compose.yml
.Clone the Repository:
git clone https://github.com/sylphlab/rag-server-mcp.git cd mcp-rag-server
Start Services:
docker-compose up -d --build
Pull Embedding Model (First Run):
The default embedding model (nomic-embed-text
) needs to be pulled into the Ollama container after it starts.
docker exec ollama ollama pull nomic-embed-text
docker-compose up
before running this. You only need to do this once as the model will be persisted in a Docker volume.Integration with MCP Client:
Configure your MCP client (e.g., in VS Code settings or another MCP server) to connect to this server. Since it's running via Docker Compose, you typically don't run it via npx
directly in the client config. Instead, the client needs to know how to communicate with the running server (which isn't directly exposed by default in this setup, usually communication happens via other means like direct API calls if the server exposed an HTTP interface, or via shared volumes/databases if applicable).
Note: The current setup primarily facilitates RAG via Genkit flows within this project or potentially other services within the same Docker network. Direct MCP client integration from an external host requires exposing the server's MCP port from the Docker container.
Configure the server via environment variables, typically set within the docker-compose.yml
file for the rag-server
service:
CHROMA_URL
: URL of the ChromaDB service. (Default in compose: http://chromadb:8000
)OLLAMA_HOST
: URL of the Ollama service. (Default in compose: http://ollama:11434
)INDEX_PROJECT_ON_STARTUP
: Set to true
(default) or false
to enable/disable automatic indexing on server start.INDEXING_EXCLUDE_PATTERNS
: Comma-separated list of glob patterns to exclude from indexing (e.g., **/node_modules/**,**/.git/**
). Defaults are defined in autoIndexer.ts
.GENKIT_ENV
: Set to production
or development
(influences logging, etc.).LOG_LEVEL
: Set log level (e.g., debug
, info
, warn
, error
).(See docker-compose.yml
and src/config/genkit.ts
for more details)
(Performance benchmarks are not yet available.)
(Comparison with other RAG solutions will be added later.)
npm install
npm run build
npm run lint
npm run format
npm run validate
(runs format check, lint, typecheck, tests)npm test
(runs unit tests)npm run test:cov
(runs unit tests with coverage)docker-compose up -d
). Run specific E2E tests via Vitest commands or potentially integrate into npm test
. (Note: E2E tests are currently failing due to external service interaction issues).CHROMA_URL
, OLLAMA_HOST
).npm start
Full documentation is available at [TODO: Add link to deployed VitePress site].
Contributions are welcome! Please open an issue to discuss changes before submitting a pull request. Follow coding standards and commit conventions.
This project is licensed under the MIT License.