Moon MCP服务器
Moon MCP Server是一个模板项目,用于构建模型上下文协议(MCP)后端,使用 FastMCP它与Poetry打包在一起,附带了一个轻量级的Dockerfile,并公开了一个简单的 ping 用于验证连接的工具。MCP服务器从Qdrant矢量数据库中检索上下文,从而可以轻松地向代理提供相关信息。
特性
- ✅ FastMCP供电的MCP服务器已准备好独立运行
- ✅ 从Qdrant矢量数据库中检索上下文知识
- ✅ 面向Python 3.11的诗歌项目配置
- ✅ Dockerfile已准备好进行容器部署
- ✅ GitHub操作的基本CI工作流(linting占位符)
入门指南
先决条件
- Python 3.11
- 诗歌
安装
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-mcpDocker镜像运行 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服务进行调整。
