{"record":{"id":"ab24c1d2ed3c7743","repo":"siyuan-note/siyuan","slug":"property-q-x-mcp-header-value-q-is-not-a-valid","errorCode":null,"errorMessage":"property %q: x-mcp-header value %q is not a valid HTTP field name","messagePattern":"property %q: x-mcp-header value %q is not a valid HTTP field name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/mcp/tools/validation.go","lineNumber":249,"sourceCode":"\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpath := propertyName\n\t\t\tif prefix != \"\" {\n\t\t\t\tpath = prefix + \".\" + propertyName\n\t\t\t}\n\t\t\tif rawHeader, exists := property[\"x-mcp-header\"]; exists {\n\t\t\t\theader, ok := rawHeader.(string)\n\t\t\t\tif !ok || header == \"\" {\n\t\t\t\t\treturn fmt.Errorf(`property %q: x-mcp-header must be a non-empty string`, path)\n\t\t\t\t}\n\t\t\t\tpropertyType, _ := property[\"type\"].(string)\n\t\t\t\tif propertyType != \"string\" && propertyType != \"integer\" && propertyType != \"boolean\" {\n\t\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\t`property %q: x-mcp-header can only be applied to primitive types (integer, string, boolean), got %q`,\n\t\t\t\t\t\tpath, propertyType)\n\t\t\t\t}\n\t\t\t\tif !validHTTPFieldName(header) {\n\t\t\t\t\treturn fmt.Errorf(`property %q: x-mcp-header value %q is not a valid HTTP field name`, path, header)\n\t\t\t\t}\n\t\t\t\tnormalized := strings.ToLower(header)\n\t\t\t\tif seen[normalized] {\n\t\t\t\t\treturn fmt.Errorf(`property %q: duplicate x-mcp-header value %q`, path, header)\n\t\t\t\t}\n\t\t\t\tseen[normalized] = true\n\t\t\t}\n\t\t\tnested, _ := property[\"properties\"].(map[string]any)\n\t\t\tif err := walk(nested, path); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\treturn walk(properties, \"\")\n}\n","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/mcp/tools/validation.go#L231-L267","documentation":"The value of x-mcp-header must be a syntactically valid HTTP field name, checked by validHTTPFieldName (token characters per RFC 7230). Values containing spaces, colons, non-ASCII, or other illegal characters are rejected before the header can ever be sent.","triggerScenarios":"A schema property declares x-mcp-header with a value like \"Content Type\", \"x-custom:header\", or one containing unicode/special characters, then tool schema validation runs.","commonSituations":"Typos in header names, pasting a full header line (\"X-Foo: bar\") instead of the name, localizing header names, or using underscores-containing names if the validator forbids them.","solutions":["Use a valid RFC 7230 token as the header name, e.g. \"X-Trace-Id\"","Remove any colon/space/value portion — only the field name is allowed","Match the case pattern of standard headers (validation may still accept any valid token; normalize later)"],"exampleFix":"// before\n{\"x-mcp-header\":\"Content Type: abc\"}\n// after\n{\"x-mcp-header\":\"Content-Type\"}","handlingStrategy":"validation","validationCode":"const TOKEN_RE = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\nfunction checkHeaderNames(schema) {\n  for (const prop of Object.values(schema.properties || {})) {\n    if (typeof prop['x-mcp-header'] === 'string' && !TOKEN_RE.test(prop['x-mcp-header'])) {\n      throw new Error(`invalid HTTP field name: ${prop['x-mcp-header']}`);\n    }\n  }\n}","typeGuard":"const isValidHeaderName = (s) => typeof s === 'string' && /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/.test(s);","tryCatchPattern":"try { registerTool(schema) } catch (e) { if (String(e).includes('valid HTTP field name')) fixHeaderNameAndRetry(schema); else throw e; }","preventionTips":["Use standard header-name characters only (letters, digits, - and _)","Never paste full \"Name: value\" header lines into x-mcp-header","Cross-check names against RFC 7230 token rules"],"tags":["json-schema","mcp","http-headers","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}