{"record":{"id":"cf487701877caba8","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-cf4877","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/lookercreateagent/lookercreateagent.go","lineNumber":126,"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":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/looker/lookercreateagent/lookercreateagent.go#L108-L144","documentation":"ValidateSource checks that the sources.Source passed to the lookercreateagent tool satisfies the tool's compatibleSource interface via type assertion. When the bound source does not implement the Looker-specific methods the interface requires, the tool rejects it. This is a fail-fast guard ensuring the tool is only used with Looker sources it can actually talk to.","triggerScenarios":"Any Invoke/authorization setup path that hands the tool a source of the wrong concrete type — e.g. a looker-create-agent tool configured with a non-Looker source, or a custom source lacking the compatibleSource methods.","commonSituations":"Miswired YAML mapping the tool to the wrong source; custom sources that embed the base source but omit Looker-specific methods; stale binaries after source interface refactors.","solutions":["Update the tool config so its 'source' references a Looker source implementing compatibleSource.","Implement the missing compatibleSource methods (UseClientAuthorization, GetAuthTokenHeaderName, etc.) if this is your custom source.","Rebuild the toolbox so interface changes in sources are picked up.","Cross-check tool definitions in YAML against the source kinds documented for looker-create-agent."],"exampleFix":"// before: custom source missing interface methods\ntype MySource struct{ sources.Source }\n// after: satisfy compatibleSource\ntype MySource struct{ sources.Source }\nfunc (s MySource) UseClientAuthorization() bool { return false }\nfunc (s MySource) GetAuthTokenHeaderName() string { return \"X-Looker-Api-Session-Token\" }","handlingStrategy":"type-guard","validationCode":"// Go: assert the source implements the tool's interface before wiring\nfunc validatePairing(t tools.Tool, s sources.Source) error {\n    if v, ok := t.(interface{ ValidateSource(sources.Source) error }); ok {\n        return v.ValidateSource(s)\n    }\n    return nil\n}","typeGuard":"func asCompatibleSource(s sources.Source) (compatibleSource, bool) {\n    cs, ok := s.(compatibleSource)\n    return cs, ok\n}","tryCatchPattern":null,"preventionTips":["Verify each tool's 'source' field names a source of the correct kind.","Run ValidateSource during startup/CI instead of discovering at request time.","Implement all compatibleSource methods on custom sources.","Keep the toolbox binary in sync with source interface changes."],"tags":["type-assertion","configuration","looker","validation"],"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"}