{"record":{"id":"9e6bbb8df9334ddb","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-9e6bbb","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/cloudstoragelistobjects/cloudstoragelistobjects.go","lineNumber":129,"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\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\tprefix := cloudstoragecommon.ResolveString(t.Cfg.Prefix, mapParams, prefixKey)\n\tdelimiter := cloudstoragecommon.ResolveString(t.Cfg.Delimiter, mapParams, delimiterKey)\n\tpageToken, _ := mapParams[pageTokenKey].(string)\n\tmaxResults, _ := mapParams[maxResultsKey].(int)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragelistobjects/cloudstoragelistobjects.go#L111-L147","documentation":"Thrown by the cloudstorage-list-objects tool's ValidateSource when the source instance passed to the tool does not implement the tool's internal compatibleSource interface. The tool only works with Cloud Storage sources; wiring it to any other source kind fails this type assertion.","triggerScenarios":"A tools.yaml binds the tool to a non-cloud-storage source (e.g. a postgres source) via `source:`; or code calls ValidateSource with the wrong sources.Source implementation.","commonSituations":"Copy-pasting a tool definition and forgetting to change the source reference; renaming sources and pointing the tool at the wrong one; programmatically assembling tool/source pairs.","solutions":["Point the tool's `source` field at a source with kind cloud-storage","Check that the referenced source name exists in the sources section of tools.yaml","Rebuild/reload after fixing so ValidateSource runs against the correct source"],"exampleFix":"// before\ntools:\n  list-objects:\n    kind: cloudstorage-list-objects\n    source: my-postgres\n// after\ntools:\n  list-objects:\n    kind: cloudstorage-list-objects\n    source: my-gcs","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(sources.Source); ok {\n    // additionally ensure the configured source kind is cloud-storage in tools.yaml\n}","typeGuard":"func asCloudStorageSource(s sources.Source) (CompatibleSource, bool) {\n    cs, ok := s.(CompatibleSource)\n    return cs, ok\n}","tryCatchPattern":null,"preventionTips":["Verify the tool's `source:` reference names a cloud-storage source","Keep source names unique and greppable to avoid stale references","Add a startup assertion/test that each tool validates against its configured source"],"tags":["go","configuration","type-mismatch","cloud-storage"],"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"}