{"record":{"id":"6edf4b08b94ea6d2","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-6edf4b","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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudsql/cloudsqlcreatedatabase/cloudsqlcreatedatabase.go","lineNumber":100,"sourceCode":"}\n\n// Tool represents the create-database 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\n// Invoke executes the tool's logic.\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(\"missing 'project' parameter\", nil)\n\t}\n\tinstance, ok := paramsMap[\"instance\"].(string)\n\tif !ok {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsql/cloudsqlcreatedatabase/cloudsqlcreatedatabase.go#L82-L118","documentation":"ValidateSource on the cloud-sql-create-database tool asserts the bound source implements `compatibleSource`; if the assertion fails it returns this error. Only Cloud SQL sources that can provide the SQL admin service and create-database operation are permitted. The error means the tool was bound to an incompatible source kind.","triggerScenarios":"Calling ValidateSource during tool/source binding with a sources.Source that does not implement the tool's compatibleSource interface — typically a `create-database` tool whose `source:` points at a non-Cloud-SQL source.","commonSituations":"tools.yml miswiring (postgres/mysql source named instead of cloudsql*); typos in source names; custom sources missing required methods; toolbox upgrades that expanded compatibleSource.","solutions":["Point the tool's `source:` at a Cloud SQL source implementing compatibleSource (cloudsqlpg, cloudsqlmysql, cloudsqlmssql).","Check the quoted source name and fix kind/name mismatches in the config.","For custom sources, implement GetDefaultProject, GetService, UseClientAuthorization, and CreateDatabase.","Reload config and verify startup validation succeeds."],"exampleFix":"# before\ntools:\n  create-database:\n    kind: cloud-sql-create-database\n    source: pg-source\n\n# after\ntools:\n  create-database:\n    kind: cloud-sql-create-database\n    source: cloudsql-pg-source","handlingStrategy":"validation","validationCode":"// Go: fail fast at config load\nif err := tool.ValidateSource(src); err != nil {\n    log.Fatalf(\"create-database source invalid: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := tool.ValidateSource(source); err != nil {\n    return fmt.Errorf(\"cloud-sql-create-database bound to %T, expected a cloudsql* source: %w\", source, err)\n}","preventionTips":["Call ValidateSource during startup/config load.","Pair cloud-sql-create-database exclusively with cloudsql* sources.","Keep source names consistent and typo-checked between sections.","Re-run validation after toolbox upgrades.","Compare with the upstream prebuilt cloud-sql tool 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"}