alibaba/open-code-review · error
unknown MCP server field %q: supported fields are type, comm
Error message
unknown MCP server field %q: supported fields are type, command, args, env, url, headers, tools, setup
What it means
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.
Source
Thrown at cmd/opencodereview/config_cmd.go:927
return fmt.Errorf("invalid JSON array for %s: %w", key, err)
}
seen := make(map[string]struct{}, len(tools))
filtered := make([]string, 0, len(tools))
for _, t := range tools {
if t == "" {
return fmt.Errorf("tool names in %s must not be empty", key)
}
if _, dup := seen[t]; dup {
continue
}
seen[t] = struct{}{}
filtered = append(filtered, t)
}
entry.Tools = filtered
case "setup":
entry.Setup = value
default:
return fmt.Errorf("unknown MCP server field %q: supported fields are type, command, args, env, url, headers, tools, setup", field)
}
cfg.MCPServers[name] = entry
return nil
}
// parseMCPHeaders parses a JSON object of header key-value pairs.
// Example: {"Authorization": "Bearer $TOKEN", "X-Custom": "value"}
func parseMCPHeaders(value string) (map[string]string, error) {
var m map[string]string
if err := json.Unmarshal([]byte(value), &m); err != nil {
return nil, fmt.Errorf("expected JSON object: %w", err)
}
for k, v := range m {
if k == "" {
return nil, fmt.Errorf("header name must not be empty")
}
if v == "" {View on GitHub (pinned to 5cf97d0d15)
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
Example fix
// before ocr config set mcp-servers.myserver.endpoint https://mcp.example.com // after ocr config set mcp-servers.myserver.url https://mcp.example.com
Defensive patterns
Strategy: validation
Validate before calling
var mcpServerFields = map[string]bool{
"type": true, "command": true, "args": true, "env": true,
"url": true, "headers": true, "tools": true, "setup": true,
}
if !mcpServerFields[field] { return fmt.Errorf("unsupported field %q", field) } Type guard
func isKnownMCPField(f string) bool { return mcpServerFields[f] } Try / catch
if err := setMCPServerValue(cfg, name, field, value); err != nil {
if strings.Contains(err.Error(), "unknown MCP server field") { /* correct the field name from the message */ }
return err
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- MCP server %q not found
- invalid headers for %s: %w
- tool names in %s must not be empty
- load config: %w
- unset supports provider, max_tokens, effort, custom_provider
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/a1fe16cd9af7a8e6.
Report an issue: GitHub.