[ SKILL_DOCUMENTATION ]
# 直接创建 (MCP) 详情
使用此参考资料获取 MCP 直接创建示例及后续配置。
## 直接创建工作流
### 第 1 步:分析代码库
使用 [codebase-analysis.md](codebase-analysis.md) 确定运行时、构建/启动命令、环境变量和数据存储。
### 第 2 步:通过 MCP 创建资源
**创建 Web 服务:**
create_web_service(
name: "my-api",
runtime: "node", # 或 python, go, rust, ruby, elixir, docker
repo: "https://github.com/username/repo",
branch: "main", # 可选,默认为仓库默认分支
buildCommand: "npm ci",
startCommand: "npm start",
plan: "free", # free, starter, standard, pro, pro_max, pro_plus, pro_ultra
region: "oregon", # oregon, frankfurt, singapore, ohio, virginia
envVars: [
{"key": "NODE_ENV", "value": "production"}
]
)
**创建静态网站:**
create_static_site(
name: "my-frontend",
repo: "https://github.com/username/repo",
branch: "main",
buildCommand: "npm run build",
publishPath: "dist", # 或 build, public, out
envVars: [
{"key": "VITE_API_URL", "value": "https://api.example.com"}
]
)
**创建 Cron 任务:**
create_cron_job(
name: "daily-cleanup",
runtime: "node",
repo: "https://github.com/username/repo",
schedule: "0 0 * * *", # 每天午夜 (cron 语法)
buildCommand: "npm ci",
startCommand: "node scripts/cleanup.js",
plan: "free"
)
**创建 PostgreSQL 数据库:**
create_postgres(
name: "myapp-db",
plan: "free", # free, basic_256mb, basic_1gb, basic_4gb, pro_4gb 等
region: "oregon"
)
**创建键值存储 (Redis):**
create_key_value(
name: "myapp-cache",
plan: "free", # free, starter, standard, pro, pro_plus
region: "oregon",
maxmemoryPolicy: "allkeys_lru" # 驱逐策略
)
### 第 3 步:配置环境变量
创建服务后,添加环境变量:
update_environment_variables(
serviceId: "",
envVars: [
{"key": "DATABASE_URL", "value": ""},
{"key": "JWT_SECRET", "value": ""},
{"key": "API_KEY", "value": ""}
]
)
**注意:** 对于数据库连接字符串,请从仪表板的数据库详情中获取内部 URL,或通过 `get_postgres(postgresId: "")` 获取。
### 第 4 步:验证部署
具有 `autoDeploy: "yes"` (默认) 的服务在创建时会自动部署。
**检查部署状态:**
list_deploys(service