Rename create to plan command in core code, MCP server, and all documentation

Co-authored-by: No-Github <18167071+No-Github@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-23 12:38:04 +00:00
parent aca4af8800
commit df01f8d103
8 changed files with 42 additions and 37 deletions

8
MCP.md
View File

@@ -22,8 +22,8 @@ The redc MCP server exposes the following capabilities:
1. **list_templates** - List all available redc templates/images
2. **list_cases** - List all running cases in the current project
3. **create_case** - Create a new case from a template
4. **start_case** - Start a case by ID
3. **plan_case** - Plan a new case from a template (like terraform plan - preview resources without creating them)
4. **start_case** - Start a case by ID (this actually creates and starts the infrastructure)
5. **stop_case** - Stop a running case by ID
6. **kill_case** - Kill (destroy) a case by ID
7. **get_case_status** - Get the status of a specific case
@@ -136,7 +136,7 @@ Response:
"id": 3,
"method": "tools/call",
"params": {
"name": "create_case",
"name": "plan_case",
"arguments": {
"template": "aliyun/ecs",
"name": "my-test-case",
@@ -148,6 +148,8 @@ Response:
}
```
**Note:** `plan_case` performs a terraform plan to validate the configuration without actually creating infrastructure. Use `start_case` afterwards to actually create and start the resources.
### Start a Case
```json

View File

@@ -22,8 +22,8 @@ redc MCP 服务器提供以下能力:
1. **list_templates** - 列出所有可用的 redc 模板/镜像
2. **list_cases** - 列出当前项目中的所有场景
3. **create_case** - 从模板创建新场景
4. **start_case** - 通过 ID 启动场景
3. **plan_case** - 从模板规划新场景(类似 terraform plan - 预览资源而不实际创建)
4. **start_case** - 通过 ID 启动场景(这将实际创建并启动基础设施)
5. **stop_case** - 通过 ID 停止运行中的场景
6. **kill_case** - 通过 ID 销毁场景
7. **get_case_status** - 获取特定场景的状态
@@ -136,7 +136,7 @@ SSE 服务器提供三个端点:
"id": 3,
"method": "tools/call",
"params": {
"name": "create_case",
"name": "plan_case",
"arguments": {
"template": "aliyun/ecs",
"name": "my-test-case",
@@ -148,6 +148,8 @@ SSE 服务器提供三个端点:
}
```
**注意:** `plan_case` 执行 terraform plan 来验证配置而不实际创建基础设施。之后使用 `start_case` 来实际创建和启动资源。
### 启动场景
```json

View File

@@ -252,13 +252,13 @@ redc image ls
ecs is the template file name
````bash
redc create --name boring_sheep_ecs [template_name] # Create an instance and plan (this process does not create the instance, just checks information)
# After create completes, it returns a caseid which can be used with the start command
redc plan --name boring_sheep_ecs [template_name] # Plan an instance (this process validates the configuration but doesn't create infrastructure)
# After plan completes, it returns a caseid which can be used with the start command to actually create infrastructure
redc start [caseid]
redc start [casename]
````
Directly create and start a case with template name ecs
Directly plan and start a case with template name ecs
```
redc run aliyun/ecs

View File

@@ -260,8 +260,8 @@ redc image ls
ecs 为模版文件名称
````bash
redc create --name boring_sheep_ecs [模版名称] # 创建一个实例并 plan该过程不会创建实例只是检查信息
# create创建完成后会返回caseid 可使用start命令启动
redc plan --name boring_sheep_ecs [模版名称] # 规划一个实例(该过程验证配置但不会创建基础设施
# plan完成后会返回caseid 可使用start命令实际创建基础设施
redc start [caseid]
redc start [casename]
````

View File

@@ -46,9 +46,9 @@ redc image ls # List local templates
### Deploy
```bash
redc run <template> -n <name> -e key=val # Create & start
redc create <template> -n <name> # Create only
redc start <case-id> # Start case
redc run <template> -n <name> -e key=val # Plan & start (create infrastructure)
redc plan <template> -n <name> # Plan only (preview without creating)
redc start <case-id> # Start case (create infrastructure)
```
### Manage
@@ -80,8 +80,8 @@ redc exec 8a57078ee856 whoami
**Controlled:**
```bash
redc create aws/ec2 -n staging
# Review, then:
redc plan aws/ec2 -n staging
# Review the planned resources, then:
redc start <case-id>
redc cp deploy.sh <case-id>:/root/
redc exec <case-id> "bash /root/deploy.sh"

View File

@@ -46,9 +46,9 @@ redc image ls # 列出本地模板
### 部署
```bash
redc run <模板> -n <名称> -e key=val # 创建并启动
redc create <模板> -n <名称> # 仅创建
redc start <case-id> # 启动场景
redc run <模板> -n <名称> -e key=val # 规划并启动(创建基础设施)
redc plan <模板> -n <名称> # 仅规划(预览而不创建
redc start <case-id> # 启动场景(创建基础设施)
```
### 管理
@@ -80,8 +80,8 @@ redc exec 8a57078ee856 whoami
**受控部署:**
```bash
redc create aws/ec2 -n staging
# 审查后:
redc plan aws/ec2 -n staging
# 审查规划的资源后:
redc start <case-id>
redc cp deploy.sh <case-id>:/root/
redc exec <case-id> "bash /root/deploy.sh"

View File

@@ -35,15 +35,15 @@ var runCmd = &cobra.Command{
},
}
var createCmd = &cobra.Command{
Use: "create [template_name]",
Short: "创建一个新的基础设施场景",
Example: "redc create ecs -u team1 -n operation_alpha",
var planCmd = &cobra.Command{
Use: "plan [template_name]",
Short: "预览plan一个新的基础设施场景,检查将要创建的资源",
Example: "redc plan ecs -u team1 -n operation_alpha",
Args: cobra.ExactArgs(1), // 强制要求输入一个模板名,例如 pte
Run: func(cmd *cobra.Command, args []string) {
templateName := args[0]
if c, err := createLogic(templateName); err == nil {
gologger.Info().Msgf("✅「%s」%s 场景创建完成接下来您可以start启动该场景", c.Name, c.Id)
gologger.Info().Msgf("✅「%s」%s 场景 plan 完成接下来您可以start启动该场景", c.Name, c.Id)
}
},
}
@@ -65,13 +65,13 @@ func createLogic(templateName string) (*redc.Case, error) {
}
func init() {
rootCmd.AddCommand(createCmd)
rootCmd.AddCommand(planCmd)
rootCmd.AddCommand(runCmd)
CRCommonFlagSet := pflag.NewFlagSet("common", pflag.ExitOnError)
CRCommonFlagSet.StringVarP(&userName, "user", "u", "system", "指定用户/操作员")
CRCommonFlagSet.StringVarP(&projectName, "name", "n", "", "指定项目/任务名称")
CRCommonFlagSet.StringToStringVarP(&envVars, "env", "e", nil, "设置环境变量 (格式: key=value)")
createCmd.Flags().AddFlagSet(CRCommonFlagSet)
planCmd.Flags().AddFlagSet(CRCommonFlagSet)
runCmd.Flags().AddFlagSet(CRCommonFlagSet)
}

View File

@@ -242,8 +242,8 @@ func (s *MCPServer) getTools() []Tool {
},
},
{
Name: "create_case",
Description: "Create a new case from a template",
Name: "plan_case",
Description: "Plan a new case from a template (like terraform plan - preview resources without creating them)",
InputSchema: ToolSchema{
Type: "object",
Properties: map[string]Property{
@@ -443,14 +443,14 @@ func (s *MCPServer) executeTool(name string, args map[string]interface{}) (ToolR
case "list_cases":
return s.toolListCases()
case "create_case":
case "plan_case":
template, ok := args["template"].(string)
if !ok {
return ToolResult{}, fmt.Errorf("missing or invalid 'template' parameter")
}
caseName, _ := args["name"].(string)
env, _ := args["env"].(map[string]interface{})
return s.toolCreateCase(template, caseName, env)
return s.toolPlanCase(template, caseName, env)
case "start_case":
caseID, ok := args["case_id"].(string)
@@ -540,8 +540,8 @@ func (s *MCPServer) toolListCases() (ToolResult, error) {
}, nil
}
func (s *MCPServer) toolCreateCase(template string, name string, env map[string]interface{}) (ToolResult, error) {
// Create case using the RedcProject.CaseCreate method
func (s *MCPServer) toolPlanCase(template string, name string, env map[string]interface{}) (ToolResult, error) {
// Plan case using the RedcProject.CaseCreate method (which performs terraform plan)
vars := make(map[string]string)
if env != nil {
for k, v := range env {
@@ -551,14 +551,15 @@ func (s *MCPServer) toolCreateCase(template string, name string, env map[string]
c, err := s.project.CaseCreate(template, redc.U, name, vars)
if err != nil {
return ToolResult{}, fmt.Errorf("failed to create case: %v", err)
return ToolResult{}, fmt.Errorf("failed to plan case: %v", err)
}
output := fmt.Sprintf("Case created successfully:\n")
output := fmt.Sprintf("Case planned successfully (terraform plan completed):\n")
output += fmt.Sprintf("- ID: %s\n", c.GetId())
output += fmt.Sprintf("- Name: %s\n", c.Name)
output += fmt.Sprintf("- Template: %s\n", template)
output += fmt.Sprintf("\nUse 'start_case' with ID '%s' to start the case.\n", c.GetId())
output += fmt.Sprintf("\nThe case has been validated but not started yet.\n")
output += fmt.Sprintf("Use 'start_case' with ID '%s' to actually create and start the infrastructure.\n", c.GetId())
return ToolResult{
Content: []ContentItem{{