{"record":{"id":"3ccea5019f483ae3","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-3ccea5","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/lookerdeleteprojectfile/lookerdeleteprojectfile.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\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":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/looker/lookerdeleteprojectfile/lookerdeleteprojectfile.go#L90-L126","documentation":"ValidateSource verifies at startup that the source bound to this lookerdeleteprojectfile tool implements the looker-compatibleSource interface. If the configured source is any type other than a Looker source, the type assertion fails and this error is returned, preventing the tool from being invoked against an incompatible backend.","triggerScenarios":"Server startup/config validation where the tool's YAML `source:` points to a non-looker source kind; calling ValidateSource directly with a foreign sources.Source.","commonSituations":"Copy-pasted tool configs referencing the wrong source name; refactors that renamed or re-typed a source; multi-source configs where the tool was pointed at postgres/http instead of looker.","solutions":["Point the tool's source field at a source of kind \"looker\" in the config","Confirm the referenced source is defined and registered as looker","If calling programmatically, pass a sources/looker source instance"],"exampleFix":"// before\nsources:\n  db: { kind: postgres, ... }\ntools:\n  del-file: { kind: looker-delete-project-file, source: db }\n// after\nsources:\n  lk: { kind: looker, ... }\ntools:\n  del-file: { kind: looker-delete-project-file, source: lk }","handlingStrategy":"type-guard","validationCode":"if err := tool.ValidateSource(src); err != nil { return fmt.Errorf(\"config invalid: %w\", err) }","typeGuard":"func isLookerSource(s sources.Source) bool { _, ok := s.(compatibleSource); return ok }","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil { log.Fatalf(\"incompatible source: %v\", err) }","preventionTips":["Call ValidateSource once at startup for every tool","Keep tool `source:` names pointing at looker-kind sources","Add config tests that load and validate all tool definitions"],"tags":["go","looker","config","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"}