Cover image
Try Now
2025-04-07

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

MCP RAG Server

NPM Version License CI Status

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.

Quick Start

(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)

Why Choose This Project?

  • Seamless MCP Integration: Designed specifically for the Model Context Protocol ecosystem.
  • Local Control: Leverages local models (Ollama) and vector stores (ChromaDB) for privacy and customization.
  • Automatic Context: Indexes your project files automatically to provide relevant context to LLMs.
  • Extensible: Built with Genkit, allowing for potential future extensions and integrations.

Features

  • Automatic Indexing: Scans the project directory on startup (configurable) and indexes supported files.
  • Supported File Types: .txt, .md, code files (via generic splitting), .json, .jsonl, .csv. (Code file chunking is basic).
  • Hierarchical Chunking: Intelligently chunks Markdown files, separating text and code blocks.
  • Vector Storage: Uses ChromaDB for persistent vector storage.
  • Local Embeddings: Leverages Ollama for local embedding generation (default: nomic-embed-text).
  • MCP Tools: Exposes RAG functions as standard MCP tools:
    • 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.
  • Dockerized: Includes a docker-compose.yml for easy setup of the server, ChromaDB, and Ollama.

Design Philosophy

  • Simplicity: Aims for a straightforward setup and usage experience, especially with Docker Compose.
  • Modularity: Leverages Genkit flows for organizing RAG logic.
  • Local-First: Prioritizes local tools like Ollama and ChromaDB for core functionality.

Installation & Usage (Docker Compose - Recommended)

This method runs the server and its dependencies (ChromaDB, Ollama) in isolated containers.

  1. Prerequisites:

    • Install Docker Desktop or Docker Engine.
    • Ensure port 8000 (ChromaDB) and 11434 (Ollama) are free on your host machine, or adjust ports in docker-compose.yml.
  2. Clone the Repository:

    git clone https://github.com/sylphlab/rag-server-mcp.git
    cd mcp-rag-server
    
  3. Start Services:

    docker-compose up -d --build
    
    • This builds the server image, downloads ChromaDB and Ollama images, and starts the services.
    • The first run might take time to download images and build.
  4. 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
    
    • Wait a few moments after docker-compose up before running this. You only need to do this once as the model will be persisted in a Docker volume.
  5. 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.

Configuration (Environment Variables)

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

(Performance benchmarks are not yet available.)

Comparison with Other Solutions

(Comparison with other RAG solutions will be added later.)

Future Plans

  • Improve code file chunking strategies.
  • Add support for more file types (e.g., PDF).
  • Enhance filtering capabilities for queries.
  • Investigate and resolve E2E test failures.
  • Add more robust error handling.

Development

  1. Prerequisites: Node.js (LTS), npm.
  2. Install Dependencies: npm install
  3. Build: npm run build
  4. Run Linters/Formatters:
    • npm run lint
    • npm run format
    • npm run validate (runs format check, lint, typecheck, tests)
  5. Run Tests:
    • npm test (runs unit tests)
    • npm run test:cov (runs unit tests with coverage)
    • E2E Tests: Require Docker Compose environment running (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).
  6. Run Server Locally (without Docker):
    • Ensure ChromaDB and Ollama are running and accessible (e.g., locally installed or separate Docker containers).
    • Set environment variables (CHROMA_URL, OLLAMA_HOST).
    • npm start

Documentation

Full documentation is available at [TODO: Add link to deployed VitePress site].

Contributing

Contributions are welcome! Please open an issue to discuss changes before submitting a pull request. Follow coding standards and commit conventions.

License

This project is licensed under the MIT License.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

  • modelcontextprotocol
  • 模型上下文协议服务器

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

    Reviews

    3 (1)
    Avatar
    user_fPsWp5fC
    2025-04-17

    As a devoted user of rag-server-mcp, I can confidently say it's a game-changer for managing server tasks. The seamless integration, coupled with its robust performance, makes it an indispensable tool for any developer. Kudos to sylphlab for creating such a versatile and reliable solution. Check it out at https://github.com/sylphlab/rag-server-mcp – you won't be disappointed!