{"record":{"id":"18d09519a62b2e2d","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-18d095","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/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go","lineNumber":154,"sourceCode":"\t}\n\n\tresp, err := source.CreateInstance(ctx, project, name, dbVersion, rootPassword, settings, string(accessToken))\n\tif err != nil {\n\t\treturn nil, util.ProcessGcpError(err)\n\t}\n\treturn resp, nil\n}\n\n// Authorized always returns true: this admin tool intentionally bypasses\n// per-request auth-service checks (server-side credentials handle access).\nfunc (t Tool) Authorized(verifiedAuthServices []string) bool {\n\treturn true\n}\n\nfunc (t Tool) RequiresClientAuthorization(source sources.Source) (bool, error) {\n\ts, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn false, fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn s.UseClientAuthorization(), nil\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","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go#L136-L172","documentation":"cloudsqlmysql-create-instance is wired to Cloud SQL Admin sources only. RequiresClientAuthorization type-asserts the injected sources.Source to the tool's private compatibleSource interface; when the configured source is any other source kind (e.g. a plain mysql/postgres database source), the assertion fails and this error is returned instead of an authorization decision.","triggerScenarios":"Calling RequiresClientAuthorization (directly or via server startup/auth middleware) while the tool is bound to a source whose concrete type does not implement compatibleSource — for example attaching the tool to a `mysql` source instead of a `cloud-sql-mysql` source, or renaming/swapping source kinds in the YAML config without updating the tool's `source` field.","commonSituations":"Copy-pasting a tool config between prebuilt configs and leaving the source pointing at the wrong kind; upgrading toolbox versions where the tool narrowed which sources it accepts; typos in the source name causing fallback to an unexpected source; mixing dataplex/cloud-sql sources across tools in one config.","solutions":["Point the tool's `source` field in the YAML config at a Cloud SQL MySQL source (kind `cloud-sql-mysql`) that implements UseClientAuthorization/GetDefaultProject","Verify with `toolbox --tools` or the tool manifest that the resolved source name matches the intended cloudsql source","If you truly need a non-CloudSQL source, use a tool designed for that source instead of cloudsqlmysql-create-instance"],"exampleFix":"// before\ntools:\n  create-instance:\n    kind: cloud-sql-mysql-create-instance\n    source: my-mysql   # plain mysql source\n// after\ntools:\n  create-instance:\n    kind: cloud-sql-mysql-create-instance\n    source: my-cloudsql-mysql  # cloud-sql-mysql source","handlingStrategy":"type-guard","validationCode":"_, ok := src.(cloudsqlmysqlsource.CompatibleSource); if !ok { return fmt.Errorf(\"tool %s requires a cloud-sql-mysql source\", toolName) }","typeGuard":"func isCloudSQLMySQLSource(s sources.Source) bool { _, ok := s.(interface{ UseClientAuthorization() bool; GetDefaultProject() string }); return ok }","tryCatchPattern":"ok, err := tool.RequiresClientAuthorization(src)\nif err != nil {\n    if strings.Contains(err.Error(), \"not a compatible type\") {\n        // rebind tool to a cloud-sql-mysql source before proceeding\n    }\n    return err\n}","preventionTips":["Keep tool `source:` references pointing at same-engine sources (cloud-sql-mysql tools -> cloud-sql-mysql source)","Run `toolbox --tools` after every config change to surface validation errors early","Add config linting/CI checks asserting source kinds per tool kind"],"tags":["go","type-assertion","configuration","cloudsql"],"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"}