{"record":{"id":"d11e2411f696b3ee","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-d11e24","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/yugabytedbsql/yugabytedbsql.go","lineNumber":106,"sourceCode":"// validate interface\nvar _ tools.Tool = Tool{}\n\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\n\tparamsMap := params.AsMap()\n\tnewStatement, err := parameters.ResolveTemplateParams(t.Cfg.TemplateParameters, t.Cfg.Statement, paramsMap)\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"unable to extract template params\", err)\n\t}\n\n\tnewParams, err := parameters.GetParams(t.Cfg.Parameters, paramsMap)\n\tif err != nil {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/yugabytedbsql/yugabytedbsql.go#L88-L124","documentation":"YugabyteDB SQL tools only accept sources implementing compatibleSource (a database/sql-backed YugabyteDB source). ValidateSource's type assertion failing produces this error, blocking tool execution against a wrong-kind source.","triggerScenarios":"Pairing a yugabytedbsql tool with a source of another kind (e.g. postgres) in tools.yaml; calling ValidateSource/Invoke with a sources.Source that doesn't implement compatibleSource.","commonSituations":"YugabyteDB being Postgres-wire-compatible leads users to reuse postgres sources; copy-pasted prebuilt configs with unchanged source references; kind typos in the source definition.","solutions":["Set the tool's source to a kind: yugabytedb source in tools.yaml","Fix the source kind if it was accidentally declared as postgres or another kind","Verify the source name referenced by the tool exists and matches the intended source"],"exampleFix":"# before\nsources:\n  yb:\n    kind: postgres\ntools:\n  yb-sql:\n    kind: yugabytedb-execute-sql\n    source: yb\n# after\nsources:\n  yb:\n    kind: yugabytedb\n    host: yb.example.com\n    port: 5433\ntools:\n  yb-sql:\n    kind: yugabytedb-execute-sql\n    source: yb","handlingStrategy":"validation","validationCode":"kind, _ := getSourceKind(toolsYAML, tool.Source)\nif kind != \"yugabytedb\" {\n    return fmt.Errorf(\"tool %s requires a yugabytedb source, got %s\", tool.Name, kind)\n}","typeGuard":"func asYugabyteSource(s sources.Source) (compatibleSource, bool) {\n    cs, ok := s.(compatibleSource)\n    return cs, ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    // rebind tool to a kind: yugabytedb source and reload\n}","preventionTips":["Declare a dedicated kind: yugabytedb source even though the wire protocol is Postgres-compatible","Keep source kinds and tool kinds consistent in configs","Preflight-load configs in CI to catch mismatches"],"tags":["go","tool-configuration","yugabytedb","type-assertion"],"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"}