{"record":{"id":"95e140b6f5be1756","repo":"googleapis/mcp-toolbox","slug":"missing-kind-field-or-it-is-not-a-string-v","errorCode":null,"errorMessage":"missing 'kind' field or it is not a string: %v","messagePattern":"missing 'kind' field or it is not a string: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/config.go","lineNumber":207,"sourceCode":"\tfor index, doc := range file.Docs {\n\t\tif doc == nil || doc.Body == nil {\n\t\t\tcontinue\n\t\t}\n\t\tdocIndex := index + 1\n\t\tvar resource map[string]any\n\t\tif err := decoder.DecodeFromNodeContext(ctx, doc.Body, &resource); err != nil {\n\t\t\tif len(file.Docs) > 1 {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"document %d: %s\", docIndex, yaml.FormatError(err, false, false))\n\t\t\t}\n\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"unable to decode YAML document: %s\", yaml.FormatError(err, false, false))\n\t\t}\n\t\tvar kind, name string\n\t\tvar ok bool\n\t\tif kind, ok = resource[\"kind\"].(string); !ok {\n\t\t\tif len(file.Docs) > 1 {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"%s missing 'kind' field or it is not a string\", formatDocLocation(docIndex, keyToken(doc.Body, \"kind\"), doc.Body))\n\t\t\t}\n\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"missing 'kind' field or it is not a string: %v\", resource)\n\t\t}\n\t\tif name, ok = resource[\"name\"].(string); !ok {\n\t\t\t// A `kind: group` may omit `name` to target the default nameless group;\n\t\t\t// every other resource requires a name.\n\t\t\tif kind == \"group\" {\n\t\t\t\tif rawName, present := resource[\"name\"]; !present || rawName == nil {\n\t\t\t\t\tname, ok = \"\", true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !ok {\n\t\t\tif len(file.Docs) > 1 {\n\t\t\t\tfallbackToken := keyToken(doc.Body, \"name\")\n\t\t\t\tif fallbackToken == nil {\n\t\t\t\t\tfallbackToken = keyToken(doc.Body, \"kind\")\n\t\t\t\t}\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"%s missing 'name' field or it is not a string\", formatDocLocation(docIndex, fallbackToken, doc.Body))\n\t\t\t}","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/config.go#L189-L225","documentation":"This is the single-document variant of the missing-'kind' error: when the YAML file contains exactly one document, UnmarshalPrimitiveConfig returns an error that includes the raw parsed resource map (%v) instead of a document-location prefix. It means the top-level map has no 'kind' key or the value is not a string.","triggerScenarios":"Calling ParseConfig on a single-document YAML file whose root map lacks a 'kind' key or has a non-string kind value; the offending map is printed in the error.","commonSituations":"New users writing their first tools.yaml without kind; editors stripping or reordering keys; pasting a partial config fragment; YAML anchors causing kind to resolve to null.","solutions":["Add 'kind: <source|tool|authService|group|...>' as a top-level key in the YAML document.","Inspect the map printed in the error to confirm what was actually parsed; ensure kind sits at the root, not nested.","If kind exists but parses oddly (e.g. null from an anchor), inline its literal string value.","Check indentation so the root is a flat mapping of keys including kind."],"exampleFix":"// before (file tools.yaml)\nname: my-source\nkind: 123\n// after\nkind: source\nname: my-source","handlingStrategy":"validation","validationCode":"docs := strings.Split(yamlText, \"\\n---\")\nif len(docs) == 1 {\n    var root map[string]any\n    if err := yaml.Unmarshal([]byte(yamlText), &root); err != nil { panic(err) }\n    if k, ok := root[\"kind\"].(string); !ok || k == \"\" {\n        return fmt.Errorf(\"single-doc config needs a string 'kind', parsed root: %v\", root)\n    }\n}","typeGuard":"k, ok := root[\"kind\"]\nhasStringKind := ok && func(v any) bool { s, isStr := v.(string); return isStr && s != \"\" }(k)","tryCatchPattern":"if err := server.ParseConfig(ctx, ...); err != nil {\n    if strings.Contains(err.Error(), \"missing 'kind'\") {\n        log.Fatalf(\"config error: add a top-level 'kind' string to %s: %v\", toolsFile, err)\n    }\n    return err\n}","preventionTips":["Copy complete config examples from the docs, not fragments.","Keep kind as the first key in every YAML document.","Avoid YAML anchors/aliases for the kind key; inline the literal string.","Lint YAML files with a schema that requires kind."],"tags":["yaml","config","validation"],"backgroundTag":"missing-yaml-kind-field","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}