{"record":{"id":"6ed78b03b4e8a7a0","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-6ed78b","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/lookerhealthanalyze/lookerhealthanalyze.go","lineNumber":122,"sourceCode":"\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":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/looker/lookerhealthanalyze/lookerhealthanalyze.go#L104-L140","documentation":"ValidateSource on the looker-health-analyze tool type-asserts the provided sources.Source to the tool's compatibleSource interface; if the assertion fails it returns this error. It exists so the server can verify at bind/validation time that a tool's source is usable by the tool. Any non-Looker source triggers it.","triggerScenarios":"Calling ValidateSource with a source that does not implement compatibleSource — typically when a tool in tools.yaml references a source of the wrong kind, or when server code passes the wrong Source to the tool.","commonSituations":"Misconfigured tools.yaml mapping the tool to a non-Looker source, duplicated source names with different kinds, or code refactors that changed source types without updating tool bindings.","solutions":["Point the tool's source field at a Looker source in tools.yaml.","Ensure the source implements all methods of the compatibleSource interface.","Rebuild/reload the toolbox so validation runs against the corrected sources.","Add a unit test calling ValidateSource with your source to catch regressions."],"exampleFix":"// before\ntool.ValidateSource(genericHTTPSource{})\n// after\nif _, ok := genericHTTPSource{}.(looker.CompatibleSource); !ok {\n    tool.ValidateSource(lookerSource) // use a source implementing compatibleSource\n}","handlingStrategy":"validation","validationCode":"if err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"source %T incompatible with looker-health-analyze: %w\", src, err)\n}","typeGuard":"func isCompatibleLookerSource(s sources.Source) bool {\n    _, ok := s.(interface {\n        UseClientAuthorization() bool\n        GetAuthTokenHeaderName() string\n    })\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    if strings.Contains(err.Error(), \"not a compatible type\") {\n        return fmt.Errorf(\"bind tool to a looker source, got %T\", src)\n    }\n    return err\n}","preventionTips":["Verify source kind matches tool expectations before binding","Test ValidateSource with production sources in unit tests","Avoid duplicate source names with different kinds in tools.yaml","Re-run validation after any source interface refactor"],"tags":["go","looker","source-compatibility","type-assertion"],"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"}