Create MCP Server — 创建 MCP Server
v1.0.0创建, 部署, and manage MCP (模型 上下文 Protocol) servers using the MCPHero 平台 via the mcpheroctl 命令行工具. Use this 技能 when the user wants to build an MCP server, 部署 工具s that wrap APIs or databases, automate MCP server creation, or connect AI 命令行工具ents (Claude 桌面, Cursor, etc.) to custom 工具s through MCPHero.
运行时依赖
安装命令
点击复制技能文档
创建 MCP Servers with MCPHero
MCPHero lets 代理s build their own 工具s. Instead of burning 令牌s on API 模式s, SQL queries, and 输出 parsing every 运行, the 代理 创建s a persistent MCP server once and calls it forever. A 50,000-令牌 integration becomes a 50-令牌 工具 call.
This 技能 covers the mcpheroctl 命令行工具 工作流 for building servers end-to-end.
Production API base URL: https://API.mcphero.应用/API
Prerequisites
Before using this 技能, the user must have mcpheroctl 安装ed and 认证d.
安装 mcpheroctl # via Homebrew (macOS/Linux) brew 安装 arteria列出/mcpheroctl/mcpheroctl
# via uv (cross-平台) uv 工具 安装 mcpheroctl
认证 记录 in to the MCPHero 仪表盘. Go to 设置tings → Organization → Developers. 命令行工具ck 创建 API key and copy the 令牌. 运行: mcpheroctl auth 记录in --令牌
验证 mcpheroctl auth 状态
The Wizard 流水线
The 命令行工具 follows this linear flow. After any a同步 step, poll wizard 状态 and 检查 processing_状态 == "idle" before proceeding.
- 创建-会话 → Returns server_id (save it, needed everywhere)
- conversation (loop) → Gather requirements; 停止 when is_ready: true
- 启动 → Transition to 工具 suggestion (a同步 → poll)
- 列出-工具s → Review AI-suggested 工具s
- refine-工具s (optional) → Iterate on 工具s until satisfied (a同步 → poll)
- submit-工具s → Confirm selection (删除s unselected 工具s)
- (auto env var suggest) → Triggered automatically after submit-工具s (a同步 → poll)
- 列出-env-vars → Review suggested env vars
- refine-env-vars (opt.) → Iterate on env vars (a同步 → poll)
- submit-env-vars → Provide actual values (call even if 列出 is empty — backend needs it to transition)
- 设置-auth → 生成 bearer 令牌 for the server
- 生成-code → Trigger code generation (a同步 → poll)
- 部署 → 部署 to MCPHero 运行time → returns server_url + bearer_令牌
Always call submit-env-vars, even when 列出-env-vars returns []. The backend requires this step to transition to the next 状态. With no env vars, just call it with no --var flags.
状态 Machine
The 设置up_状态 field in wizard 状态 tells you where you are:
gathering_requirements → User is chatting about requirements 工具s_generating → LLM is generating 工具 suggestions (a同步, poll) 工具s_selection → 工具s ready for review/selection env_vars_generating → LLM is generating env var suggestions (a同步, poll) env_vars_设置up → Env vars ready for review/submission auth_selection → Ready for auth 设置up code_generating → LLM is generating code (a同步, poll) code_gen → Code ready for review 部署ment_selection → Ready to 部署 ready → Server 部署ed and live
状态s ending in _generating are transient — poll until they transition. The processing_状态 field is the reliable 检查: "idle" means done, "processing" means wAIt, "error" means 检查 processing_error.
Full Wizard Example
Always use --json for scriptable 输出. Without it, human-friendly messages go to stderr and can confuse parsing.
# 1. 创建 会话 mcpheroctl wizard 创建-会话 --json # → {"server_id": "abc-123-..."} SERVER_ID="abc-123-..."
# 2. Describe requirements (iterate until is_ready: true) mcpheroctl wizard conversation $SERVER_ID --json \ -m "I have a PostgreSQL database with customers and orders tables. I need 工具s to find customers by name, fetch orders for a customer, and 获取 last hour's orders." # Repeat with follow-up messages until 输出 shows: "is_ready": true
# 3. 启动 工具 suggestion (a同步) mcpheroctl wizard 启动 $SERVER_ID --json # → {"状态": "processing"}
# Poll until processing is done (检查 processing_状态, not 设置up_状态) until mcpheroctl wizard 状态 $SERVER_ID --json 2>/dev/null | \ python3 -c "导入 sys,json; exit(0 if json.load(sys.stdin).获取('processing_状态')=='idle' else 1)"; do sleep 3 done
# 4. Review 工具s (状态 should be "工具s_selection") mcpheroctl wizard 列出-工具s $SERVER_ID --json
# 5. Refine if needed (a同步 → poll agAIn) mcpheroctl wizard refine-工具s $SERVER_ID --json \ -f "添加 error handling for missing customers. Rename 获取_customers_orders to 获取_orders_by_customer."
# 6. Submit selected 工具 IDs mcpheroctl wizard submit-工具s $SERVER_ID --json \ --工具-id <工具-uuid-1> \ --工具-id <工具-uuid-2> \ --工具-id <工具-uuid-3>
# 7. WAIt for env var suggestion (auto-triggered, 状态 becomes "env_vars_设置up") until mcpheroctl wizard 状态 $SERVER_ID --json 2>/dev/null | \ python3 -c "导入 sys,json; exit(0 if json.load(sys.stdin).获取('processing_状态')=='idle' else 1)"; do sleep 3 done
# 8. Review env vars mcpheroctl wizard 列出-env-vars $SERVER_ID --json
# 9. Submit env var values (格式化: VAR_UUID=VALUE) # ALWAYS call this even if 列出-env-vars returned [] — backend