{"record":{"id":"52f6d37a6989e1b7","repo":"alibaba/open-code-review","slug":"mcp-server-command-cannot-be-empty","errorCode":null,"errorMessage":"MCP server command cannot be empty","messagePattern":"MCP server command cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":864,"sourceCode":"\tif len(parts) != 3 || parts[1] == \"\" || parts[2] == \"\" {\n\t\treturn fmt.Errorf(\"invalid MCP server key %q: expected mcp_servers.<name>.<field>\", key)\n\t}\n\tname, field := parts[1], parts[2]\n\n\tif cfg.MCPServers == nil {\n\t\tcfg.MCPServers = make(map[string]MCPServerConfig)\n\t}\n\tentry := cfg.MCPServers[name]\n\n\tswitch field {\n\tcase \"type\":\n\t\tif value != \"stdio\" && value != \"remote\" {\n\t\t\treturn fmt.Errorf(\"invalid MCP server type %q: must be \\\"stdio\\\" or \\\"remote\\\"\", value)\n\t\t}\n\t\tentry.Type = value\n\tcase \"command\":\n\t\tif value == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server command cannot be empty\")\n\t\t}\n\t\tentry.Command = value\n\tcase \"args\":\n\t\tvar args []string\n\t\tif err := json.Unmarshal([]byte(value), &args); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tentry.Args = args\n\tcase \"env\":\n\t\tvar env []string\n\t\tif err := json.Unmarshal([]byte(value), &env); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tfor _, e := range env {\n\t\t\tidx := strings.Index(e, \"=\")\n\t\t\tif idx <= 0 {\n\t\t\t\treturn fmt.Errorf(\"invalid env entry %q: must be in KEY=VALUE format\", e)\n\t\t\t}","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L846-L882","documentation":"When setting mcp_servers.<name>.command, an empty string is rejected because a stdio MCP server needs an executable command to launch. This error guards against writing a config entry that could never start.","triggerScenarios":"Calling setMCPServerValue with field \"command\" and value \"\".","commonSituations":"Running `ocr config set mcp_servers.myserver.command` with an empty argument (shell consumes the empty string), or scripting config generation that skips the value.","solutions":["Pass the actual executable path or name, e.g. npx or /usr/local/bin/myserver","If the server is remote instead, set mcp_servers.<name>.type remote and a url rather than command","Remove the half-configured entry entirely if it is no longer needed"],"exampleFix":"// before\nocr config set mcp_servers.filesystem.command \"\"\n// after\nocr config set mcp_servers.filesystem.command npx","handlingStrategy":"validation","validationCode":"if command == \"\" {\n\treturn fmt.Errorf(\"command is required for stdio servers\")\n}","typeGuard":null,"tryCatchPattern":"if err := setMCPServerValue(cfg, key, value); err != nil {\n\tfmt.Fprintf(os.Stderr, \"config set failed: %v\\n\", err)\n\tos.Exit(1)\n}","preventionTips":["Always quote the command value so empty strings are not silently dropped","For remote servers set url, not command","Verify the command exists on PATH before configuring it"],"tags":["config","mcp","validation"],"backgroundTag":"empty-required-field","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}