feat: 新增 HTTP MCP Server,让 AI Agent 接入选菜

新增 packages/mcp,基于 Streamable HTTP 暴露菜谱库能力,复用 packages/cook 的选菜算法:recommend_recipes 按现有食材推荐,search_recipes 条件检索,check_incompatible 食材相克,get_recipe 菜谱详情。容器内与 nginx 共存,映射 2230 端口供 Agent 连接。
This commit is contained in:
toor
2026-10-22 16:55:29 +08:00
committed by trae-solo-agent
parent 8ff7b879b9
commit 79baab6080
12 changed files with 919 additions and 1 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# 同一容器内同时跑 nginx(Web,2229)和 MCP Server(2230)。
# 任一进程退出即终止容器,交由 Docker 的 restart 策略整体重启。
set -e
node /opt/cook-mcp/dist/index.mjs &
MCP_PID=$!
nginx -g 'daemon off;' &
NGINX_PID=$!
cleanup() {
kill "$MCP_PID" "$NGINX_PID" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
# busybox ash 的 wait 不支持 -n,改为轮询两个进程是否都还活着
while kill -0 "$MCP_PID" 2>/dev/null && kill -0 "$NGINX_PID" 2>/dev/null; do
sleep 1
done