{"record":{"id":"23d168aedbe5bdcf","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-23d168","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/cloudsql/cloudsqlconnectgce/cloudsqlconnectgce.go","lineNumber":145,"sourceCode":"\t\t),\n\t}\n}\n\nvar _ tools.Tool = Tool{}\n\n// Tool represents the cloud-sql-connect-gce tool.\ntype Tool struct {\n\ttools.BaseTool[Config]\n}\n\nfunc (t Tool) GetSourceName() string {\n\treturn t.Cfg.Source\n}\n\nfunc (t Tool) ValidateSource(src sources.Source) error {\n\t_, ok := src.(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) ToConfig() tools.ToolConfig {\n\treturn t.Cfg\n}\n\n// Invoke fetches the Cloud SQL instance, detects its engine, validates\n// connectivity to the target VM, and returns connection recommendations.\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\n\tsqlService, err := source.GetService(ctx, string(accessToken))\n\tif err != nil {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsql/cloudsqlconnectgce/cloudsqlconnectgce.go#L127-L163","documentation":"ValidateSource on the cloud-sql-connect-gce tool performs a type assertion of the bound source to `compatibleSource`; when the assertion fails it returns this error. The tool only supports sources that can provide the SQL admin service and Cloud SQL Connect GCE capabilities. It is an early compatibility check, so the error means the tool was wired to a wrong-kind source.","triggerScenarios":"Calling ValidateSource (invoked when the tool is attached to a source, e.g., during config load or tool resolution) with a sources.Source that does not implement the tool's compatibleSource interface — the tool's `source` field names a non-Cloud-SQL or non-connect-capable source.","commonSituations":"Configuring `cloud-sql-connect-gce` against a vanilla postgres/mysql source; a renamed or custom source type lacking the required methods; copying a tool definition into a prebuilt config where the source kind differs; typos in the source name resolving to an unrelated source.","solutions":["Set the tool's `source:` to a Cloud SQL source compatible with connect-gce (implements GetDefaultProject, GetService, UseClientAuthorization, and the connect methods).","Cross-check the source kind in sources config; only cloudsql* sources satisfy compatibleSource for this tool.","If a custom source is intended, implement all compatibleSource interface methods.","Run server startup and read the validation error's quoted source name (Cfg.Source) to fix the exact miswired entry."],"exampleFix":"# before\nsources:\n  db:\n    kind: postgres\n    ...\ntools:\n  connect-gce:\n    kind: cloud-sql-connect-gce\n    source: db\n\n# after\nsources:\n  db:\n    kind: cloudsqlpostgres\n    ...\ntools:\n  connect-gce:\n    kind: cloud-sql-connect-gce\n    source: db","handlingStrategy":"validation","validationCode":"// Go: run ValidateSource yourself at startup before serving traffic\nif err := tool.ValidateSource(src); err != nil {\n    log.Fatalf(\"config error: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := tool.ValidateSource(source); err != nil {\n    return fmt.Errorf(\"cloud-sql-connect-gce bound to incompatible source %T: %w\", source, err)\n}","preventionTips":["Call ValidateSource eagerly during config load to fail fast.","Only attach cloud-sql-connect-gce to cloudsql* sources.","Keep source names consistent between the sources and tools sections.","After upgrading, re-run startup validation — interfaces may have grown.","Diff your config against the upstream prebuilt cloud-sql config."],"tags":["go","cloudsql","type-mismatch","configuration"],"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"}