{"record":{"id":"7154c709ce6d4b45","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-7154c7","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/cloudsqlcloneinstance/cloudsqlcloneinstance.go","lineNumber":102,"sourceCode":"}\n\n// Tool represents the clone-instance 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(fmt.Sprintf(\"error casting 'project' parameter: %v\", paramsMap[\"project\"]), nil)\n\t}\n\tsourceInstanceName, ok := paramsMap[\"sourceInstanceName\"].(string)\n\tif !ok {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsql/cloudsqlcloneinstance/cloudsqlcloneinstance.go#L84-L120","documentation":"ValidateSource for cloudsql-clone-instance asserts the source implements the tool's compatibleSource interface (a Cloud SQL Admin source). A source of any other Go type fails the assertion, returning this error. The tool needs Cloud SQL Admin capabilities (project/instance access) that only the compatible source provides.","triggerScenarios":"Config validation or Invoke-time checks where the clone-instance tool is bound to a non-Cloud SQL source, e.g. a plain postgres/mysql source instead of cloud-sql admin, or a custom source missing the interface methods.","commonSituations":"Binding the tool to the database connection source rather than the Cloud SQL Admin source; renaming sources and updating tool bindings incorrectly; interface changes after a toolbox upgrade.","solutions":["Point the tool's `source` at a cloud-sql (admin) kind source.","Run config validation before starting the server to catch the mismatch.","For custom wrappers, implement the full compatibleSource interface.","Verify the source kind under `sources:` actually supports instance cloning operations."],"exampleFix":"// before\n  clone-instance:\n    kind: cloud-sql-clone-instance\n    source: my-postgres\n// after\n  clone-instance:\n    kind: cloud-sql-clone-instance\n    source: cloud-sql-admin","handlingStrategy":"validation","validationCode":"// Go: validate the Cloud SQL source before tool use\nif err := cloneTool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"clone-instance requires a cloud-sql admin source: %w\", err)\n}","typeGuard":"func asCloudSQLSource(s sources.Source) (compatibleSource, bool) {\n    cs, ok := s.(compatibleSource)\n    return cs, ok\n}","tryCatchPattern":"if err := cloneTool.ValidateSource(src); err != nil {\n    log.Fatalf(\"cloud-sql-clone-instance misconfigured: %v\", err)\n}","preventionTips":["Distinguish the Cloud SQL Admin source from engine connection sources in tools.yaml and bind clone-instance to the former.","Validate bindings at startup and in CI.","Keep custom source wrappers implementing compatibleSource with compile-time assertions.","After version upgrades, confirm the compatibleSource interface hasn't gained methods."],"tags":["go","config","type-assertion","source-compatibility","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"}