flipped-aurora/gin-vue-admin · error

解析执行计划失败: %v

Error message

解析执行计划失败: %v

What it means

The gva_execute tool's Handle (server/mcp/gva_execute.go:224) re-serializes the raw executionPlan argument to JSON before unmarshaling into ExecutionPlan. If this intermediate json.Marshal of the client-supplied value fails, the plan can't be parsed and this error is returned. Distinct from the more common Unmarshal failure at line 230 — this one indicates the argument itself is not a marshalable structure.

Source

Thrown at server/mcp/gva_execute.go:224

			mcp.AdditionalProperties(false),
		),
		mcp.WithString("requirement",
			mcp.Description("原始需求描述(可选,用于日志记录)"),
		),
	)
}

// Handle 处理执行请求(移除确认步骤)
func (g *GVAExecutor) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
	executionPlanData, ok := request.GetArguments()["executionPlan"]
	if !ok {
		return nil, errors.New("参数错误:executionPlan 必须提供")
	}

	// 解析执行计划
	planJSON, err := json.Marshal(executionPlanData)
	if err != nil {
		return nil, fmt.Errorf("解析执行计划失败: %v", err)
	}

	var plan ExecutionPlan
	err = json.Unmarshal(planJSON, &plan)
	if err != nil {
		return nil, fmt.Errorf("解析执行计划失败: %v\n\n请确保ExecutionPlan格式正确,参考工具描述中的结构体格式要求", err)
	}

	// 验证执行计划的完整性
	if err := g.validateExecutionPlan(ctx, &plan); err != nil {
		return nil, fmt.Errorf("执行计划验证失败: %v", err)
	}

	// 获取原始需求(可选)
	var originalRequirement string
	if reqData, ok := request.GetArguments()["requirement"]; ok {
		if reqStr, ok := reqData.(string); ok {
			originalRequirement = reqStr

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Confirm the client sends executionPlan as a JSON object, not a stringified JSON or scalar.
  2. Print/log the raw executionPlan argument to see what was actually received.
  3. If JSON-stringified, parse it client-side into an object before invoking the tool.
  4. Align the call with the schema in the tool description (packageName, packageType, flags, packageInfo/modulesInfo).

Example fix

// before
{"executionPlan": "{\"packageName\":\"user\"}"}
// after: pass a real object, not a JSON string
{"executionPlan": {"packageName": "user", "packageType": "package", "needCreatedPackage": false, "needCreatedModules": false, "needCreatedDictionaries": false}}
Defensive patterns

Strategy: validation

Validate before calling

function validateExecutionPlanArg(args) {
  const p = args?.executionPlan
  return typeof p === 'object' && p !== null && !Array.isArray(p) && typeof p.packageName === 'string' && p.packageName.length > 0
}

Type guard

function isExecutionPlanObject(v) {
  return typeof v === 'object' && v !== null && !Array.isArray(v) && typeof v.packageName === 'string'
}

Try / catch

if (!isExecutionPlanObject(args.executionPlan)) {
  throw new Error('executionPlan must be a plain object per the tool schema')
}
const result = await callTool('gva_execute', args)

Prevention

When it happens

Trigger: Calling gva_execute with an executionPlan argument that json.Marshal cannot process — e.g. the MCP client passed a non-object value (number, func-like placeholder) or a structure the marshaler rejects instead of a JSON object.

Common situations: MCP clients sending malformed tool arguments (executionPlan as a string or null variant instead of an object); buggy client-side argument construction; proxy layers mangling the arguments map.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/cf590691b34ef218. Report an issue: GitHub.