{"record":{"id":"d9489aa93b219ba3","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-d9489a","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/cloudstorage/cloudstoragelistbuckets/cloudstoragelistbuckets.go","lineNumber":121,"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\tmapParams := params.AsMap()\n\tproject := cloudstoragecommon.ResolveString(t.Cfg.Project, mapParams, projectKey)\n\tprefix := cloudstoragecommon.ResolveString(t.Cfg.Prefix, mapParams, prefixKey)\n\tpageToken, _ := mapParams[pageTokenKey].(string)\n\tmaxResults, _ := mapParams[maxResultsKey].(int)\n\tif maxResults < 0 {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid '%s' parameter: %d must be >= 0 (use 0 for the API default)\", maxResultsKey, maxResults), nil)\n\t}\n\tif maxResults > maxResultsLimit {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragelistbuckets/cloudstoragelistbuckets.go#L103-L139","documentation":"cloudstorage-list-buckets' ValidateSource rejects sources not implementing its compatibleSource interface. The tool must be bound to a Cloud Storage source (which provides project context); binding to any other source type fails at startup.","triggerScenarios":"The tool config's `source` value resolves to a Go type failing the compatibleSource assertion in ValidateSource.","commonSituations":"Tool listed under the wrong source in the YAML; reused toolset definitions across configs; typos causing fallback to a differently-typed source.","solutions":["Set `source:` to a cloudstorage source defined in the config.","Move/delete the tool if attached to an incompatible source.","Verify the source name matches a cloudstorage entry under `sources:`."],"exampleFix":"# before\nsource: spanner-source\n# after\nsource: gcs-project-source","handlingStrategy":"validation","validationCode":"if _, ok := src.(compatibleSource); !ok {\n    return fmt.Errorf(\"list-buckets requires a cloudstorage source, got %T\", src)\n}","typeGuard":"func isCompatible(s sources.Source) bool { _, ok := s.(compatibleSource); return ok }","tryCatchPattern":null,"preventionTips":["Only attach cloudstorage-list-buckets to cloudstorage sources","Confirm source keys and kinds after refactors","Run server startup checks as part of CI pipelines"],"tags":["go","cloudstorage","source-type-mismatch"],"backgroundTag":"source-type-mismatch","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"}