{"record":{"id":"2ce87ecd5d2ad426","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-2ce87e","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/cloudstoragecreatebucket/cloudstoragecreatebucket.go","lineNumber":117,"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, ok := mapParams[bucketKey].(string)\n\tif !ok || bucket == \"\" {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a non-empty string\", bucketKey), nil)\n\t}\n\tproject := cloudstoragecommon.ResolveString(t.Cfg.Project, mapParams, projectKey)\n\tlocation := cloudstoragecommon.ResolveString(t.Cfg.Location, mapParams, locationKey)\n\tuniformBucketLevelAccess := cloudstoragecommon.ResolveBool(t.Cfg.UniformBucketLevelAccess, mapParams, uniformBucketLevelAccessKey)\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragecreatebucket/cloudstoragecreatebucket.go#L99-L135","documentation":"Identical guard to the copy-object tool: cloud-storage-createbucket.ValidateSource asserts the bound source implements compatibleSource (a Cloud Storage source). Any other source kind produces this error naming the tool type and the source name.","triggerScenarios":"A create_bucket tool entry in tools.yaml whose `source:` references a non-GCS source; passing an incompatible source instance when registering tools programmatically.","commonSituations":"Miswired tools.yaml after refactoring source names; reusing a generic tool template pointing at the wrong source; mixing prebuilt configs for different backends.","solutions":["Set the tool's `source:` to a `kind: cloud-storage` source","Verify sources.yaml declares the referenced source with the Cloud Storage kind","Fix any renamed source references left over from refactoring"],"exampleFix":"// before\ntools:\n  create_bucket:\n    source: mysql-src\n// after\ntools:\n  create_bucket:\n    source: gcs-src","handlingStrategy":"type-guard","validationCode":"func sourceIsGCSForCreate(s sources.Source) bool {\n    _, ok := s.(cloudstoragecreatebucket.CompatibleSource)\n    return ok\n}\n// before wiring: if !sourceIsGCSForCreate(src) { return errors.New(\"create_bucket requires a cloud-storage source\") }","typeGuard":"func asCompatibleCreateSource(s sources.Source) (compatibleSource, bool) {\n    cs, ok := s.(compatibleSource)\n    return cs, ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"bind create_bucket to a kind: cloud-storage source: %w\", err)\n}","preventionTips":["Map GCS-only tools exclusively to cloud-storage sources","Verify kind fields in sources.yaml before referencing them","Run config load in CI to surface mismatches early","Grep for renamed/removed source names after refactors"],"tags":["config","type-mismatch","cloud-storage","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"}