RAG-MCP

RAG-MCP

A Python server that enables retrieval-augmented generation through semantic, question/answer, and style search modalities using PostgreSQL and pgvector for embedding storage and retrieval.

Category
访问服务器

README

rag-mcp: a ridiculously over-engineered retrieval system

welcome to rag-mcp, a project that answers the age-old question, "what if we took a perfectly good idea—retrieval-augmented generation—and made it so complicated it becomes a monument to our own hubris?" it's a model context protocol (mcp) server that slings text embeddings around like a coked-up short-stop, using postgresql and the pgvector extension because, honestly, who needs simplicity?

this is for the real sickos, the ones who look at a problem and think, "i could solve this with a simple script, but what if, instead, i built a byzantine system of interlocking parts that will be a nightmare to maintain?" you're my people.

what the hell is this thing?

at its core, rag-mcp is a python server that provides a set of tools for searching a knowledge base of text. but instead of just one boring way to search, we've got modalities. think of them as different flavors of search, each one a special little snowflake optimized for a specific kind of task.

  • semantic search: for when you want to find things that are, like, vibing with your query.
  • question/answer search: you ask a question, it pretends to have the answer. classic.
  • style search: finds stuff that feels the same. it's like a sommelier for text. deeply pretentious and surprisingly useful.

it's all built on the fastmcp framework, which means you can talk to it with other ai agents, creating a truly absurd, self-referential ouroboros of code.

architecture, or "how the sausage gets made"

it's a beautiful mess. here's the blueprint:

  1. the server (rag_mcp_server.py): a python script that's the brains of the operation. it handles incoming requests, talks to the database, and generally tries to keep its cool.
  2. the database (postgresql + pgvector): this is where we stash all the text and its corresponding vector embeddings. the create_tables.pgsql script lays out the whole schema, which is surprisingly organized for something i came up with. we're talking documents, document_chunks, and embeddings tables, all linked up. it's almost professional.
  3. the embedding engine (openai-compatible): we need something to turn words into numbers. the server calls out to an openai-compatible api to get the embeddings. you get to provide the endpoint, so you can use whatever weird, home-brewed model you want.
  4. the tools: the server exposes its search modalities as mcp tools. right now, we've got search_semantic_similarity, search_qa, and search_style.

setup, or "good luck"

getting this beast to run is a rite of passage.

prerequisites:

  • python 3.whatever. if it works, it works.
  • postgresql, with the pgvector extension enabled. if you don't know how to do that, google it. this isn't a charity.

installation:

  1. clone the repo. obviously.

  2. install the python junk:

    pip install -r requirements.txt
    
  3. set up the database. connect to your postgres instance and run the create_tables.pgsql script. it'll create the tables and the fancy hnsw indexes for fast, fast, fast vector searches.

  4. environment variables. you need to set these. create a .env file or just scream them into the void, your choice.

    # database stuff
    rm_db_host=localhost
    rm_db_port=5432
    rm_db_name=your_db_name
    rm_db_user=your_db_user
    rm_db_password=your_super_secret_password
    
    # embedding model stuff
    rm_openai_api_key=your_api_key
    rm_openai_endpoint=your_model_endpoint_url
    

usage, or "let's dance"

if you've made it this far, you're either a genius or you're very, very lost. either way, let's fire it up.

  1. run the server:
    python rag_mcp_server.py
    
  2. if it doesn't immediately crash and burn, the server is now listening, exposing its mcp tools to the world. you can now call search_style, search_qa, and search_semantic_similarity from whatever mcp client you've got.

connecting from clients, or "who's gonna talk to this thing?"

so you've got this glorious monstrosity running. now what? you need something to talk to it. if you're using some ai assistant thingy in vscode or claude desktop or whatever the hell, you'll need to tell it how to find our server.

you'll probably have to edit some json settings file. find the spot for mcpServers and add something like this:

{
  "mcpServers": {
    "RAG-MCP Knoledge Base Server": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "fastmcp",
        "run",
        "/location/of/the/script/rag_mcp_server.py:mcp"
      ],
      "env": {
        "RM_DB_HOST": "localhost",
        "RM_DB_PORT": "5432",
        "RM_DB_NAME": "your_db_name",
        "RM_DB_USER": "your_db_user",
        "RM_DB_PASSWORD": "your_super_secret_password",
        "RM_OPENAI_API_KEY": "your_api_key",
        "RM_OPENAI_ENDPOINT": "your_model_endpoint_url"
      },
      "transport": "stdio",
      "type": null,
      "cwd": null,
      "timeout": null,
      "description": null,
      "icon": null,
      "authentication": null
    }
  }
}

obviously, change /location/of/the/script/rag_mcp_server.py:mcp to the actual, you know, location of the script. and fill in the env with your secrets. don't just copy-paste this like a mindless drone. or do. i'm not your dad.

extending the system, or "make it weirder"

the best part of this whole thing is how easy it is to make it even more baroque. you can add your own search modalities. maybe you want a search that only returns results in iambic pentameter. maybe you want one that searches for recipes for disaster. go nuts.

i wrote a whole damn manual for it. check out manual.md. it'll walk you through the process of adding new models, tasks, and tool functions. it's so easy, it's almost disappointing.


this project is provided as-is, without any warranty, express or implied. if it sets your computer on fire, that's on you. you chose this life.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选