{"record":{"id":"f341c0e31fa8810c","repo":"googleapis/mcp-toolbox","slug":"unable-to-retrieve-s-source-for-tool-q-f341c0","errorCode":null,"errorMessage":"unable to retrieve %s source for tool %q","messagePattern":"unable to retrieve (.+?) source for tool %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/toolsets.go","lineNumber":72,"sourceCode":"}\n\ntype ToolsetManifest struct {\n\tServerVersion string              `json:\"serverVersion\"`\n\tToolsManifest map[string]Manifest `json:\"tools\"`\n}\n\n// BuildManifest resolves the manifest for every tool in the toolset against the\n// provided sources, returning an error if any tool's manifest cannot be built.\nfunc (t Toolset) BuildManifest(pMgr PrimitiveManagerI) (ToolsetManifest, error) {\n\ttoolsManifest := make(map[string]Manifest, len(t.Tools))\n\tfor _, tool := range t.Tools {\n\t\tsrcName := (*tool).GetSourceName()\n\t\tvar src sources.Source\n\t\tvar ok bool\n\t\tif srcName != \"\" {\n\t\t\tsrc, ok = pMgr.GetSource(srcName)\n\t\t\tif !ok {\n\t\t\t\treturn ToolsetManifest{}, fmt.Errorf(\"unable to retrieve %s source for tool %q\", srcName, (*tool).GetName())\n\t\t\t}\n\t\t}\n\t\tm, err := (*tool).Manifest(src)\n\t\tif err != nil {\n\t\t\treturn ToolsetManifest{}, fmt.Errorf(\"error generating manifest for tool %q: %w\", (*tool).GetName(), err)\n\t\t}\n\t\ttoolsManifest[(*tool).GetName()] = m\n\t}\n\treturn ToolsetManifest{ServerVersion: t.Manifest.ServerVersion, ToolsManifest: toolsManifest}, nil\n}\n\nfunc (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool) (Toolset, error) {\n\t// finish toolset setup\n\t// Check each declared tool name exists\n\ttoolset := Toolset{\n\t\tToolsetConfig: t,\n\t\tTools:         make([]*Tool, 0, len(t.ToolNames)),\n\t\tManifest: ToolsetManifest{","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/toolsets.go#L54-L90","documentation":"When building a toolset manifest, each tool's declared source is looked up in the populated source manager. If the tool names a source that was not registered (or failed to initialize), BuildManifest aborts with this error naming the source kind and tool. A tool cannot produce its manifest without its backing source.","triggerScenarios":"Calling BuildManifest on a toolset where tool.GetSourceName() returns a name absent from pMgr — the tool's `source:` field references a source not defined in the YAML, or the source block failed to load earlier.","commonSituations":"Typo in the tool's `source:` field; the corresponding source entry missing or commented out in the config; the source itself failed to initialize and was never added to the manager; renaming a source without updating tools that reference it.","solutions":["Ensure a source with the exact name the tool references is defined in the `sources:` section of the config","Fix typos in the tool's `source:` field so it matches a defined source key","Check startup logs for earlier source initialization failures that prevented registration","If renaming a source, update every tool that references it"],"exampleFix":"// before (tools.yaml)\ntools:\n  run_query:\n    kind: trino-execute-sql\n    source: trino-prod\n// after (with matching source defined)\nsources:\n  trino-prod:\n    kind: trino\n    host: trino.example.com\ntools:\n  run_query:\n    kind: trino-execute-sql\n    source: trino-prod","handlingStrategy":"validation","validationCode":"definedSources := map[string]bool{\"my-trino\": true} // keys of sources: in config\nfor _, t := range toolsetTools {\n    if t.Source != \"\" && !definedSources[t.Source] {\n        return fmt.Errorf(\"tool %q references undefined source %q\", t.Name, t.Source)\n    }\n}","typeGuard":null,"tryCatchPattern":"manifest, err := tools.BuildManifest(toolset, pMgr)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to retrieve\") {\n        // surface which source/tool pair to fix in the config\n    }\n    return err\n}","preventionTips":["Define every source a tool references before listing the tool","After renaming a source, grep the config for all references","Check startup logs for failed source initializations","Keep source names simple lowercase keys to avoid typos"],"tags":["go","config","toolset","source-lookup"],"backgroundTag":"source-not-found","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"}