{"record":{"id":"a1fe16cd9af7a8e6","repo":"alibaba/open-code-review","slug":"unknown-mcp-server-field-q-supported-fields-are","errorCode":null,"errorMessage":"unknown MCP server field %q: supported fields are type, command, args, env, url, headers, tools, setup","messagePattern":"unknown MCP server field %q: supported fields are type, command, args, env, url, headers, tools, setup","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":927,"sourceCode":"\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tseen := make(map[string]struct{}, len(tools))\n\t\tfiltered := make([]string, 0, len(tools))\n\t\tfor _, t := range tools {\n\t\t\tif t == \"\" {\n\t\t\t\treturn fmt.Errorf(\"tool names in %s must not be empty\", key)\n\t\t\t}\n\t\t\tif _, dup := seen[t]; dup {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tseen[t] = struct{}{}\n\t\t\tfiltered = append(filtered, t)\n\t\t}\n\t\tentry.Tools = filtered\n\tcase \"setup\":\n\t\tentry.Setup = value\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown MCP server field %q: supported fields are type, command, args, env, url, headers, tools, setup\", field)\n\t}\n\n\tcfg.MCPServers[name] = entry\n\treturn nil\n}\n\n// parseMCPHeaders parses a JSON object of header key-value pairs.\n// Example: {\"Authorization\": \"Bearer $TOKEN\", \"X-Custom\": \"value\"}\nfunc parseMCPHeaders(value string) (map[string]string, error) {\n\tvar m map[string]string\n\tif err := json.Unmarshal([]byte(value), &m); err != nil {\n\t\treturn nil, fmt.Errorf(\"expected JSON object: %w\", err)\n\t}\n\tfor k, v := range m {\n\t\tif k == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"header name must not be empty\")\n\t\t}\n\t\tif v == \"\" {","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L909-L945","documentation":"setMCPServerValue only recognizes the fields type, command, args, env, url, headers, tools and setup; any other field name passed on the MCP server config key falls into the default case and is rejected with this message listing the supported fields.","triggerScenarios":"`ocr config set mcp-servers.myserver.timeout 30` or any typo/unknown key such as `url` misspelled as `endpoint`, or nested fields not supported by this setter.","commonSituations":"Typos in field names; assuming fields from other MCP config formats (e.g. server-level settings like timeout or disabled) are supported; copying field names from a different tool's schema.","solutions":["Use only: type, command, args, env, url, headers, tools, setup","Fix the typo in the field name indicated in the %q","Run `ocr config get mcp-servers.<name>` to see the existing entry shape"],"exampleFix":"// before\nocr config set mcp-servers.myserver.endpoint https://mcp.example.com\n// after\nocr config set mcp-servers.myserver.url https://mcp.example.com","handlingStrategy":"validation","validationCode":"var mcpServerFields = map[string]bool{\n    \"type\": true, \"command\": true, \"args\": true, \"env\": true,\n    \"url\": true, \"headers\": true, \"tools\": true, \"setup\": true,\n}\nif !mcpServerFields[field] { return fmt.Errorf(\"unsupported field %q\", field) }","typeGuard":"func isKnownMCPField(f string) bool { return mcpServerFields[f] }","tryCatchPattern":"if err := setMCPServerValue(cfg, name, field, value); err != nil {\n    if strings.Contains(err.Error(), \"unknown MCP server field\") { /* correct the field name from the message */ }\n    return err\n}","preventionTips":["Keep the supported-field list (type, command, args, env, url, headers, tools, setup) at hand","Use shell completion for config keys","Copy field names from `ocr config get` output rather than from memory"],"tags":["cli","config","mcp","unknown-field"],"backgroundTag":"unknown-config-field","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}