{"record":{"id":"50166becf9077573","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-50166b","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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go","lineNumber":109,"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\tsdk, err := source.GetLookerSDK(ctx, string(accessToken))\n\tif err != nil {\n\t\treturn nil, util.NewClientServerError(\"error getting sdk\", http.StatusInternalServerError, err)\n\t}\n\n\tmapParams := params.AsMap()\n\tprojectId, ok := mapParams[\"project_id\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"'project_id' must be a string, got %T\", mapParams[\"project_id\"]), nil)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go#L91-L127","documentation":"ValidateSource on the looker-create-projectfile tool asserts that the provided sources.Source implements the tool's compatibleSource interface. If the assertion fails, the source is of an incompatible type (not a Looker source) and the tool returns this error instead of proceeding to Invoke.","triggerScenarios":"ValidateSource is called with a source whose concrete type is not a Looker source — typically because the tool's YAML source field points at a non-Looker source, or the wrong Source is passed programmatically.","commonSituations":"Config typo mapping a Looker tool to a database source; tests passing a mock source lacking the compatibleSource methods; sources refactored so kind strings no longer match.","solutions":["Point the tool's source field at a looker-kind source in the config","Confirm the source was registered via its init() and initialized as the Looker source type","In code/tests, pass a source implementing the compatibleSource interface"],"exampleFix":"# before\nsource: my-bigquery\ntools:\n  create-file:\n    kind: looker-create-projectfile\n# after\nsource: my-looker\ntools:\n  create-file:\n    kind: looker-create-projectfile","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(lookercreateprojectfile.CompatibleSource); !ok {\n    return fmt.Errorf(\"looker-create-projectfile requires a looker source\")\n}","typeGuard":"func isCompatibleLookerSource(s sources.Source) bool {\n    _, ok := s.(lookercreateprojectfile.CompatibleSource)\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    if strings.Contains(err.Error(), \"not a compatible type\") {\n        // rebind tool to the looker source\n    }\n    return err\n}","preventionTips":["Match tool kind and source kind in the YAML config","Validate the toolbox config before server startup","Keep source kind names stable across upgrades","Call ValidateSource early in startup to catch misbindings"],"tags":["go","looker","source-type-mismatch"],"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"}