{"record":{"id":"07d796427e0c98d8","repo":"googleapis/mcp-toolbox","slug":"unable-to-retrieve-source-for-tool-s","errorCode":null,"errorMessage":"unable to retrieve source for tool %s","messagePattern":"unable to retrieve source for tool (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/invoke/command.go","lineNumber":91,"sourceCode":"\t}\n\n\tprimitiveMgr := primitives.NewPrimitiveManager(sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap)\n\n\t// Execute Tool\n\ttoolName := args[0]\n\ttool, ok := primitiveMgr.GetTool(toolName)\n\tif !ok {\n\t\terrMsg := fmt.Errorf(\"tool %q not found\", toolName)\n\t\topts.Logger.ErrorContext(ctx, errMsg.Error())\n\t\treturn errMsg\n\t}\n\n\tsrcName := tool.GetSourceName()\n\tvar src sources.Source\n\tif srcName != \"\" {\n\t\tsrc, ok = primitiveMgr.GetSource(srcName)\n\t\tif !ok {\n\t\t\terrMsg := fmt.Errorf(\"unable to retrieve source for tool %s\", toolName)\n\t\t\topts.Logger.ErrorContext(ctx, errMsg.Error())\n\t\t\treturn errMsg\n\t\t}\n\t}\n\n\terr = tool.ValidateSource(src)\n\tif err != nil {\n\t\topts.Logger.ErrorContext(ctx, err.Error())\n\t\treturn err\n\t}\n\n\tvar paramsInput string\n\tif len(args) > 1 {\n\t\tparamsInput = args[1]\n\t}\n\n\tparams := make(map[string]any)\n\tif paramsInput != \"\" {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/invoke/command.go#L73-L109","documentation":"A tool was found, but runInvoke could not fetch its backing source from the PrimitiveManager by the tool's GetSourceName(). This indicates an inconsistent state: the tool references a source name that was not successfully initialized/registered. Tools without a source (srcName == \"\") skip this path entirely, so this only fires for source-backed tools whose source is missing.","triggerScenarios":"runInvoke finds the tool, tool.GetSourceName() is non-empty, but primitiveMgr.GetSource(srcName) returns ok=false — e.g. the source failed to register while the tool still resolved, a renamed/deleted sourceKey in the tools file, or a custom config where the source block is missing but the tool references it.","commonSituations":"Hand-edited tools files where a tool's sourceService/sourceConfig name doesn't match any defined source, partial config load errors that still registered the tool, composed configs merging a tool from one file with sources from another.","solutions":["Inspect the tools file: confirm the source name referenced by the tool matches a defined source exactly (name/case-sensitive)","Run `toolbox validate --tools-file tools.yaml` to catch dangling source references before invoking","Re-add the missing source block or correct the tool's source reference","If merging multiple configs, ensure the config providing the tool also provides (or shares) its source"],"exampleFix":"// before\nsources:\n  pg:\n    kind: postgres\n    ...  # tool references \"mydb\", source is named \"pg\"\ntools:\n  run-query:\n    kind: postgres-sql\n    source: mydb\n// after\nsources:\n  mydb:\n    kind: postgres\n    ...\ntools:\n  run-query:\n    kind: postgres-sql\n    source: mydb","handlingStrategy":"validation","validationCode":"cfg, _ := os.ReadFile(cfgPath)\nfor _, m := range toolSourceRefs.FindAllStringSubmatch(string(cfg), -1) {\n    srcName := m[1]\n    if !strings.Contains(string(cfg), \"  \"+srcName+\":\") {\n        return fmt.Errorf(\"tool references source %q which is not defined\", srcName)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := runInvoke(ctx, opts); err != nil {\n    if strings.Contains(err.Error(), \"unable to retrieve source for tool\") {\n        log.Printf(\"tool's source is missing from the loaded config: %v\", err)\n        return ErrConfigIncomplete\n    }\n    return err\n}","preventionTips":["Ensure every tool's `source:` field names an existing entry under `sources:` (exact match)","Run `toolbox validate` to catch dangling source references early","When composing configs from multiple files, load the sources file too","Avoid renaming sources without updating all tools referencing them"],"tags":["go","cli","config","source-resolution"],"backgroundTag":"tool-source-missing","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"}