{"record":{"id":"06ddf18e0281e789","repo":"alibaba/open-code-review","slug":"invalid-mcp-server-type-q-must-be-stdio-or-re","errorCode":null,"errorMessage":"invalid MCP server type %q: must be \"stdio\" or \"remote\"","messagePattern":"invalid MCP server type %q: must be \"stdio\" or \"remote\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":859,"sourceCode":"\treturn nil\n}\n\nfunc setMCPServerValue(cfg *Config, key, value string) error {\n\tparts := strings.SplitN(key, \".\", 3)\n\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}","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L841-L877","documentation":"Validation guard in setMCPServerValue for `ocr config set mcp_servers.<name>.type`: the only supported MCP server transport types are stdio (launch a local subprocess) and remote (connect to a URL). Any other string would leave the config with a type the client cannot dispatch on, so it is rejected when writing the config.","triggerScenarios":"Calling setMCPServerValue with field \"type\" and a value other than \"stdio\" or \"remote\", e.g. \"local\", \"http\", \"sse\", or a value with different casing like \"STDIO\".","commonSituations":"Users guessing the type name from other MCP client configs (some clients use \"sse\" or \"http\"), typing the value in uppercase, or copying config from incompatible tools.","solutions":["Use exactly \"stdio\" for a local command-based server","Use exactly \"remote\" for an HTTP/HTTPS URL-based server","Check spelling and lowercase the value; \"STDIO\" is rejected"],"exampleFix":"// before\nocr config set mcp_servers.filesystem.type local\n// after\nocr config set mcp_servers.filesystem.type stdio","handlingStrategy":"validation","validationCode":"if v != \"stdio\" && v != \"remote\" {\n\treturn fmt.Errorf(\"type must be stdio or remote, got %q\", v)\n}","typeGuard":"func isMCPServerType(v string) bool {\n\treturn v == \"stdio\" || v == \"remote\"\n}","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":["Use lowercase \"stdio\" or \"remote\" exactly","Match the value to how the server connects: local process = stdio, HTTP endpoint = remote","Keep a config cheat sheet of valid field values"],"tags":["config","mcp","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}