{"record":{"id":"08ab2ad4514d5b72","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-08ab2a","errorCode":null,"errorMessage":"invalid source for %q tool: source %q is not a compatible type","messagePattern":"invalid source for %q tool: source %q is not a compatible type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/looker/lookergetprojectfile/lookergetprojectfile.go","lineNumber":108,"sourceCode":"// validate interface\nvar _ tools.Tool = Tool{}\n\ntype Tool struct {\n\ttools.BaseTool[Config]\n}\n\nfunc (t Tool) GetSourceName() string {\n\treturn t.Cfg.Source\n}\n\nfunc (t Tool) ToConfig() tools.ToolConfig {\n\treturn t.Cfg\n}\n\nfunc (t Tool) ValidateSource(source sources.Source) error {\n\t_, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn nil\n}\n\nfunc (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {\n\tsource, ok := s.(compatibleSource)\n\tif !ok {\n\t\treturn nil, util.NewClientServerError(\"source used is not compatible with the tool\", http.StatusInternalServerError, nil)\n\t}\n\tlogger, err := util.LoggerFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, util.NewClientServerError(\"unable to get logger from ctx\", http.StatusInternalServerError, err)\n\t}\n\n\tsdk, err := source.GetLookerSDK(ctx, string(accessToken))\n\tif err != nil {\n\t\treturn nil, util.NewClientServerError(fmt.Sprintf(\"error getting sdk: %v\", err), http.StatusInternalServerError, err)\n\t}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/looker/lookergetprojectfile/lookergetprojectfile.go#L90-L126","documentation":"The looker-get-project-file tool's ValidateSource method type-asserts the supplied sources.Source to the tool's compatibleSource interface. If the source bound to this tool does not implement that interface (i.e. it is not a Looker source), the assertion fails and this error is returned before the tool ever runs. It is a wiring/config mismatch, not a runtime failure.","triggerScenarios":"Calling ValidateSource (directly or via server/toolset startup) with a source whose concrete Go type does not satisfy lookergetprojectfile.compatibleSource; e.g. a tool YAML entry sets `source: my-source` where my-source is a postgres/bigquery/http source rather than a Looker source.","commonSituations":"Copy-pasting a tools.yaml and forgetting to change the `source:` field to the Looker source name; renaming the Looker source in the sources section without updating the tool's source reference so it resolves to another source; mixing sources in a toolset where a Looker tool is attached to a non-Looker source.","solutions":["Open your toolbox YAML and set the tool's `source:` field to the name of a source declared with kind `looker`.","Verify the referenced source exists under `sources:` and is of type looker (the Looker API source implements UseClientAuthorization/GetAuthTokenHeaderName).","If you embed this tool in code, pass the looker source instance (lookers.Source) to the toolset/server, not another sources.Source implementation."],"exampleFix":"// before (tools.yaml)\ntools:\n  get-project-file:\n    kind: looker-get-project-file\n    source: my-postgres   # wrong source\n// after\ntools:\n  get-project-file:\n    kind: looker-get-project-file\n    source: my-looker     # a looker-kind source","handlingStrategy":"type-guard","validationCode":"// Before building the toolset, check each tool's declared source kind\nfor name, toolCfg := range cfg.Tools {\n    src, ok := cfg.Sources[toolCfg.Source]\n    if !ok {\n        return fmt.Errorf(\"tool %q references unknown source %q\", name, toolCfg.Source)\n    }\n    if _, isLooker := src.(*lookers.Source); !isLooker {\n        return fmt.Errorf(\"tool %q needs a looker source, got %T\", name, src)\n    }\n}","typeGuard":"func isCompatibleLookerSource(s sources.Source) bool {\n    _, ok := s.(lookergetprojectfilecompatibleSource)\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"looker tool source binding invalid, fix the 'source:' field in tools.yaml: %w\", err)\n}","preventionTips":["Keep Looker tools and the Looker source in the same clearly-named section of tools.yaml.","Grep your YAML for kind: looker-* tools and confirm each `source:` maps to kind: looker.","Run the toolbox with a startup smoke test so ValidateSource fails fast in CI."],"tags":["go","looker","config","source-binding"],"backgroundTag":"incompatible-source-type","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"}