模型种子库的MCP服务器
用于ModelSEEDVault SBML管理的初始Python/FastAPI MCP服务器支架。
快速入门
.venv/ 被git故意忽略。每个开发人员都应该在该目录中创建自己的本地虚拟环境。使用Python 3.11实现一致性:
uv venv --python 3.11 .venv
source .venv/bin/activate将项目安装到该环境中:
uv pip install -e .使用您本地的virtualenv Python运行服务器:
SBML_API_BASE_URL='http://192.168.1.202:8080/' \
uv run --python .venv/bin/python uvicorn mcp_curation.main:app --host 127.0.0.1 --port 8000 --reload如果在您的环境中启用了auth,请同时包含API密钥:
MCP_API_KEY='change-me' \
SBML_API_BASE_URL='http://192.168.1.202:8080/' \
uv run --python .venv/bin/python uvicorn mcp_curation.main:app --host 127.0.0.1 --port 8000 --reload安装
pip install -e .运行组合服务器(FastAPI+FastMCP)
export MCP_API_KEY="change-me"
uvicorn mcp_curation.main:app --host 127.0.0.1 --port 8000 --reload配置SBML后端端点
默认后端URL:
http://localhost:8080
用以下内容覆盖它:
export SBML_API_BASE_URL="http://localhost:8080"
export MCP_API_KEY="change-me"
uvicorn mcp_curation.main:app --host 127.0.0.1 --port 8000 --reload为前端开发配置CORS
默认允许的前端来源:
http://192.168.1.164:62699
用逗号分隔的列表覆盖它:
export CORS_ALLOW_ORIGINS="http://192.168.1.164:62699,http://localhost:3000"服务器允许:
- 方法:
GET,POST,OPTIONS - 标题:
Authorization,Content-Type,X-API-Key
未认证 OPTIONS 允许飞行前请求,因此浏览器CORS检查在经过身份验证的API调用之前成功。
FastMCP安装到FastAPI中的位置:
/mcp
MCP认证:
- 必需的环境变量:
MCP_API_KEY(如果未设置,则在启动时自动生成) - 发送:
- Authorization: Bearer - X-API-Key:
- 适用于所有非公共路线,包括
/mcp/*和/sbml-curation/*. - 公共路由(不需要API密钥):
- /health - /docs - /redoc - /openapi.json
例子:
curl -H "Authorization: Bearer $MCP_API_KEY" \
http://127.0.0.1:8000/sbml-curation/modelsSwagger测试 /docs:
- 点击
Authorize. - 您可以使用以下任一方式:
- HTTPBearer:仅输入API密钥值。 - APIKeyHeader:输入的API密钥值 X-API-Key.
- 运行任何
/sbml-curation/*从文档UI中选择端点。
第一条路线
GET /healthGET /sbml-curation/configGET /sbml-curation/modelsGET /sbml-curation/models/{model_id}/compartmentsGET /sbml-curation/models/{model_id}/speciesGET /sbml-curation/models/{model_id}/reactionsGET /sbml-curation/models/{model_id}/genesPOST /sbml-curation/annotationGET /sbml-curation/models/{model_id}/compartment/{compartment_id}/annotationGET /sbml-curation/models/{model_id}/species/{species_id}/annotationGET /sbml-curation/models/{model_id}/reaction/{reaction_id}/annotationGET /sbml-curation/models/{model_id}/gene/{gene_id}/annotation
文档
- Swagger用户界面:
http://127.0.0.1:8000/docs
FastMCP工具
sbml_curation_configlist_modelslist_model_compartmentslist_model_specieslist_model_reactionslist_model_genes
SBML客户端助手
mcp_curation.client.sbml_client.add_curation_event(subject_eid, object, agent_id)
发布到 /graph/edge/{src}/{dst}/has_annotation_event?agent=...
mcp_curation.client.sbml_client.list_curation_events(subject_eid)
获取 /graph/node/{subject_eid}/child?edgeType=has_annotation_event
