{"record":{"id":"ee597bff4c714a81","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-ee597b","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/cloudstoragegetbucketiampolicy/cloudstoragegetbucketiampolicy.go","lineNumber":106,"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\tmapParams := params.AsMap()\n\tbucket := cloudstoragecommon.ResolveString(t.Cfg.Bucket, mapParams, bucketKey)\n\tif bucket == \"\" {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a non-empty string\", bucketKey), nil)\n\t}\n\n\tresp, err := source.GetBucketIAMPolicy(ctx, bucket)\n\tif err != nil {\n\t\treturn nil, cloudstoragecommon.ProcessGCSError(err)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragegetbucketiampolicy/cloudstoragegetbucketiampolicy.go#L88-L124","documentation":"The cloudstorage-get-bucket-iam-policy tool only works with sources that implement its compatibleSource interface (a Cloud Storage source). ValidateSource is called at server startup when binding a tool to a source; if the configured source is of a different type (e.g. a Postgres source), this error is returned. It catches YAML mistakes where a tool references the wrong source name.","triggerScenarios":"A tool config's `source` field names a source whose Go type does not implement the tool's compatibleSource interface — checked during ValidateSource at startup.","commonSituations":"Copy-pasted tool configs referencing the wrong source; renaming sources in YAML without updating tool bindings; mixing cloudstorage tools with database sources.","solutions":["Point the tool's `source` field at a cloudstorage source defined in the `sources` section.","Remove the tool if it was added to the wrong source's toolset.","Check the source name spelling against the keys under `sources:` in the config."],"exampleFix":"# before\ntools:\n  get_bucket_iam_policy:\n    kind: cloudstorage-get-bucket-iam-policy\n    source: my-postgres\n# after\ntools:\n  get_bucket_iam_policy:\n    kind: cloudstorage-get-bucket-iam-policy\n    source: my-gcs-source","handlingStrategy":"validation","validationCode":"if _, ok := src.(cloudstorage.CompatibleSource); !ok {\n    return fmt.Errorf(\"tool %s requires a cloudstorage source\", toolName)\n}","typeGuard":"func isCompatible(s sources.Source) bool { _, ok := s.(compatibleSource); return ok }","tryCatchPattern":null,"preventionTips":["Keep tools nested under the matching source's tools list in YAML","Verify source kind fields when copying configs between projects","Start the server early in CI to surface ValidateSource errors"],"tags":["go","cloudstorage","source-type-mismatch","tool-initialization"],"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"}