{"record":{"id":"7f57c6195d3abb5d","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-7f57c6","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/cloudstoragecopyobject/cloudstoragecopyobject.go","lineNumber":122,"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\tsourceBucket := cloudstoragecommon.ResolveString(t.Cfg.SourceBucket, mapParams, sourceBucketKey)\n\tif sourceBucket == \"\" {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a non-empty string\", sourceBucketKey), nil)\n\t}\n\tsourceObject, ok := mapParams[sourceObjectKey].(string)\n\tif !ok || sourceObject == \"\" {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a non-empty string\", sourceObjectKey), nil)\n\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragecopyobject/cloudstoragecopyobject.go#L104-L140","documentation":"Tool.ValidateSource type-asserts the provided sources.Source against the compatibleSource interface implemented only by Cloud Storage sources. If the tool is bound to a source of a different kind (Postgres, HTTP, etc.), the assertion fails and this error names both the tool type and the configured source name. This protects against wiring tools to incompatible sources in tools.yaml.","triggerScenarios":"Declaring a cloud-storage-copyobject tool whose `source:` points at a non-Cloud-Storage source kind in tools.yaml; programmatically passing a wrong source to the tool registry.","commonSituations":"Wrong `source:` key in the tool's YAML block; renaming/refactoring sources so the tool points at a leftover source; composing prebuilt configs with mismatched source kinds.","solutions":["Point the tool's `source:` field at a Cloud Storage source (kind: cloud-storage)","Check the source's `kind` in sources.yaml matches what the tool requires","Restructure tools.yaml so each tool references a source of the correct type"],"exampleFix":"// before (tools.yaml)\ntools:\n  copy_object:\n    source: my-postgres\n// after\ntools:\n  copy_object:\n    source: my-gcs-source","handlingStrategy":"type-guard","validationCode":"func sourceIsGCS(s sources.Source) bool {\n    _, ok := s.(cloudstoragecopyobject.CompatibleSource)\n    return ok\n}\n// before wiring: if !sourceIsGCS(src) { return fmt.Errorf(\"tool requires a cloud-storage source\") }","typeGuard":"func asCompatibleSource(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(\"fix the tool's `source:` field in tools.yaml to a cloud-storage source: %w\", err)\n}","preventionTips":["Cross-check every tool's `source:` against the source `kind` in sources.yaml","Only bind GCS tools to kind: cloud-storage sources","Run `toolbox validate` (or server start) in CI to fail fast","After renaming sources, grep tools.yaml for stale references"],"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"}