{"record":{"id":"156fe2d57e31815e","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-156fe2","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/cloudsqlcreatebackup/cloudsqlcreatebackup.go","lineNumber":101,"sourceCode":"}\n\n// Tool represents the create-backup 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) 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\tparamsMap := params.AsMap()\n\n\tproject, ok := paramsMap[\"project\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"error casting 'project' parameter: %v\", paramsMap[\"project\"]), nil)\n\t}\n\tinstance, ok := paramsMap[\"instance\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"error casting 'instance' parameter: %v\", paramsMap[\"instance\"]), nil)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsql/cloudsqlcreatebackup/cloudsqlcreatebackup.go#L83-L119","documentation":"ValidateSource on the cloud-sql-create-backup tool asserts the bound source implements `compatibleSource`; failing the assertion returns this error. The tool can only create Cloud SQL backups through sources that expose the SQL admin service and backup operations. The error means the tool was attached to a source of the wrong kind.","triggerScenarios":"Calling ValidateSource during tool/source binding (config load or tool resolution) with a sources.Source that does not satisfy the tool's compatibleSource interface — the tool's `source` field names a non-Cloud-SQL source such as a plain postgres or mysql source.","commonSituations":"tools.yml `create-backup` tool pointed at a database source instead of a cloudsql* source; a custom source missing GetDefaultProject/GetService/UseClientAuthorization/CreateBackup; typos or refactors that swapped the source name; toolbox version upgrades adding methods to compatibleSource.","solutions":["Change the tool's `source:` field to a Cloud SQL source implementing compatibleSource (cloudsqlpg, cloudsqlmysql, cloudsqlmssql, etc.).","Verify the source's kind and name in the config; the error quotes the misconfigured source name.","If a custom source is intended, implement all compatibleSource methods including CreateBackup.","Reload the server config; ValidateSource should pass at startup."],"exampleFix":"# before\ntools:\n  create-backup:\n    kind: cloud-sql-create-backup\n    source: postgres-source\n\n# after\ntools:\n  create-backup:\n    kind: cloud-sql-create-backup\n    source: cloudsql-postgres-source","handlingStrategy":"validation","validationCode":"// Go: validate binding before invoking\nif err := tool.ValidateSource(src); err != nil {\n    log.Fatalf(\"create-backup source invalid: %v\", err)\n}","typeGuard":"func canCreateBackup(s sources.Source) bool {\n    _, ok := s.(interface {\n        GetDefaultProject() string\n        GetService(context.Context, string) (*sqladmin.Service, error)\n        UseClientAuthorization() bool\n    })\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(source); err != nil {\n    return fmt.Errorf(\"cloud-sql-create-backup requires a cloudsql* source: %w\", err)\n}","preventionTips":["Use cloudsqlpg/cloudsqlmysql/cloudsqlmssql sources for backup tools.","Run server startup validation in CI to catch misbindings.","Keep a single source of truth for source names in your config.","After refactors or renames, re-validate all tool->source references.","Consult the tool's docs for its required source interface."],"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"}