模型上下文协议后端模板

Moon MCP Server是一个基于FastMCP的模型上下文协议后端模板项目,用于从Qdrant向量数据库中检索上下文信息,为代理提供相关数据支持。

  • by adityapnusantara
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 aditya624/moon

使用说明

Moon MCP服务器

Moon MCP Server是一个模板项目,用于构建模型上下文协议(MCP)后端,使用 FastMCP它与Poetry打包在一起,附带了一个轻量级的Dockerfile,并公开了一个简单的 ping 用于验证连接的工具。MCP服务器从Qdrant矢量数据库中检索上下文,从而可以轻松地向代理提供相关信息。

特性

  • ✅ FastMCP供电的MCP服务器已准备好独立运行
  • ✅ 从Qdrant矢量数据库中检索上下文知识
  • ✅ 面向Python 3.11的诗歌项目配置
  • ✅ Dockerfile已准备好进行容器部署
  • ✅ GitHub操作的基本CI工作流(linting占位符)

入门指南

先决条件

安装

poetry install

运行服务器

poetry run python moon/main.py

环境变量

服务器从环境变量中读取其配置(可选 通过本地加载 .env 文件)。下面列出了最常见的设置:

变量 描述 默认值
MCP_TRANSPORT MCP服务器使用的传输类型。 streamable-http
MCP_HOST MCP服务器绑定到的主机接口 0.0.0.0
QDRANT_URL 提供上下文的Qdrant实例的基本URL。 https://657e9ff8-daa0-4003-bf76-c531e697932d.europe-west3-0.gcp.cloud.qdrant.io:6333
QDRANT_API_KEY Qdrant实例的API密钥。 空
QDRANT_TOP_K 要返回的顶级搜索结果数。 10
HF_TOKEN 用于嵌入呼叫的拥抱脸令牌。 空
HF_MODEL 拥抱人脸嵌入模型标识符。 BAAI/bge-m3

使用Docker运行

docker build -t moon-mcp .
docker run --rm -p 8181:8181 --env-file .env moon-mcp

Docker镜像运行 python moon/main.py,匹配本地执行流。更新 .env 文件(或提供其他 --env-file)配置 MCP_HOST, MCP_PORT,以及运行容器时的其他环境变量。

运行测试

poetry run pytest

项目布局

moon/
├── .github/             GitHub Actions workflows
├── dockerfile           Production-ready container image definition
├── docs/                Documentation assets
├── moon/                Application source code
│   ├── agent/           LangGraph agent scaffolding
│   ├── api/             FastAPI routers and dependencies
│   ├── config.py        Pydantic settings module
│   ├── main.py          FastMCP application entrypoint
│   └── tools/           MCP tool definitions
├── pyproject.toml       Poetry configuration and dependencies
├── scripts/             Helper scripts for local development
├── tests/               Pytest-based unit and integration tests
└── README.md            Project overview and usage instructions

许可证

此项目按原样提供。请随时根据您自己的MCP服务进行调整。