{"record":{"id":"d74114e4af599194","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-d74114","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/cloudsqlgetinstances/cloudsqlgetinstances.go","lineNumber":100,"sourceCode":"\n// buildParams builds the tool's parameters. A non-empty project means the source has a\n// configured default project, which is baked into the project param; otherwise the plain form is used.\nfunc buildParams(project string) parameters.Parameters {\n\tprojectParam := parameters.NewStringParameter(\"projectId\", \"The project ID\")\n\tif project != \"\" {\n\t\tprojectParam = parameters.NewStringParameter(\"projectId\", \"The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.\", parameters.WithStringDefault(project))\n\t}\n\treturn parameters.Parameters{\n\t\tprojectParam,\n\t\tparameters.NewStringParameter(\"instanceId\", \"The instance ID\"),\n\t}\n}\n\n// resolveParams builds the tool's parameters using the source's configured default GCP project.\nfunc (t Tool) resolveParams(source sources.Source) (parameters.Parameters, error) {\n\ts, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn buildParams(s.GetDefaultProject()), nil\n}\n\n// GetParameters returns the tool's parameters, resolved against the source.\nfunc (t Tool) GetParameters(source sources.Source) (parameters.Parameters, error) {\n\treturn t.resolveParams(source)\n}\n\n// Manifest returns the tool's manifest, resolved against the source.\nfunc (t Tool) Manifest(source sources.Source) (tools.Manifest, error) {\n\tallParameters, err := t.resolveParams(source)\n\tif err != nil {\n\t\treturn tools.Manifest{}, err\n\t}\n\treturn tools.Manifest{Description: t.Cfg.Description, Parameters: allParameters.Manifest(), AuthRequired: t.Cfg.AuthRequired}, nil\n}\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsql/cloudsqlgetinstances/cloudsqlgetinstances.go#L82-L118","documentation":"In the cloud-sql-get-instances tool, resolveParams asserts the source to the tool's compatibleSource interface to read the source's default GCP project; a failed assertion yields this error. It indicates the tool is paired with a source kind that does not implement the Cloud SQL Admin surface (GetDefaultProject) required to resolve its parameters. It is a setup-time source/tool compatibility failure, not a GCP API error.","triggerScenarios":"GetParameters(source) on the cloudsqlgetinstances tool with a source that fails the source.(compatibleSource) assertion — e.g. during server startup or MCP tool listing when the config maps cloud-sql-get-instances to a postgres/mysql/bigquery source instead of a Cloud SQL Admin source.","commonSituations":"Typically a tools.yaml misconfiguration (tool pointing at the wrong source), a custom source not implementing GetDefaultProject() string, or interface changes after upgrading only one of the source/tool packages.","solutions":["Point the tool at a Cloud SQL Admin-compatible source in tools.yaml.","Add GetDefaultProject() string (and the rest of compatibleSource) to any custom source implementation.","Upgrade source and tool packages in lockstep to avoid interface drift.","Call ValidateSource before GetParameters in custom initialization to catch the mismatch.","Debug with fmt.Printf(\"%T\", src) to confirm the concrete source type."],"exampleFix":"// before\ngetInstances.GetParameters(myPostgresSource) // incompatible\n// after\ngetInstances.GetParameters(cloudSQLAdminSource) // implements compatibleSource","handlingStrategy":"validation","validationCode":"if _, ok := src.(compatibleSource); !ok {\n\treturn fmt.Errorf(\"source %T incompatible with cloud-sql-get-instances\", src)\n}","typeGuard":"func supportsGetInstances(s sources.Source) bool {\n\t_, ok := s.(interface {\n\t\tGetDefaultProject() string\n\t\tUseClientAuthorization() bool\n\t})\n\treturn ok\n}","tryCatchPattern":"params, err := tool.GetParameters(src)\nif err != nil {\n\tlog.Printf(\"wrong source bound to cloud-sql-get-instances: %v\", err)\n\treturn err\n}","preventionTips":["Verify tools.yaml maps this tool to a Cloud SQL Admin source","Add static interface assertions (var _ compatibleSource = ...) in custom source packages","Call ValidateSource before GetParameters during startup","Keep go.mod versions of tool and source packages in sync","Include a startup self-check that resolves parameters for every configured tool"],"tags":["go","type-assertion","configuration","cloudsql","parameters"],"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"}