multica-ai/multica · error

parse mcp_config json

Error message

parse mcp_config json: %w

What it means

Wraps the json.Unmarshal failure in parseCursorManagedMcpServers when the saved mcp_config JSON cannot be parsed into the expected {mcpServers: {...}} shape. Indicates a corrupt or hand-edited saved config; Cursor MCP preparation aborts.

Solutions

  1. Fix the mcp_config JSON so it parses.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/internal/daemon/execenv/cursor_mcp.go:216 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/341dd0e3be9cb2d0. Report an issue: GitHub.

Appendix: source

Thrown at server/internal/daemon/execenv/cursor_mcp.go:216

	}
	if closeErr != nil {
		_ = os.Remove(target)
		return closeErr
	}
	return nil
}

func hasManagedCursorMcpConfig(raw json.RawMessage) bool {
	trimmed := bytes.TrimSpace(raw)
	return len(trimmed) > 0 && !bytes.Equal(trimmed, []byte("null"))
}

func parseCursorManagedMcpServers(raw json.RawMessage) (map[string]json.RawMessage, error) {
	var cfg struct {
		McpServers map[string]json.RawMessage `json:"mcpServers"`
	}
	if err := json.Unmarshal(raw, &cfg); err != nil {
		return nil, fmt.Errorf("parse mcp_config json: %w", err)
	}
	if cfg.McpServers == nil {
		return map[string]json.RawMessage{}, nil
	}
	for name, server := range cfg.McpServers {
		if strings.TrimSpace(name) == "" {
			return nil, fmt.Errorf("mcp server name must not be empty")
		}
		var obj map[string]any
		if err := json.Unmarshal(server, &obj); err != nil {
			return nil, fmt.Errorf("mcp_servers.%s: %w", name, err)
		}
		if obj == nil {
			return nil, fmt.Errorf("mcp_servers.%s must be a JSON object", name)
		}
	}
	return cfg.McpServers, nil
}

View on GitHub (pinned to 2c0912b6ec)