{"record":{"id":"b3d3f7712d9fa73b","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-b3d3f7","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/postgres/postgreslistroles/postgreslistroles.go","lineNumber":161,"sourceCode":"\tresp, err := source.RunSQL(ctx, listRolesStatement, sliceParams)\n\tif err != nil {\n\t\treturn nil, util.ProcessGeneralError(err)\n\t}\n\treturn resp, 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\n}\n","sourceCodeStart":143,"sourceCodeEnd":165,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/postgres/postgreslistroles/postgreslistroles.go#L143-L165","documentation":"The postgres-list-roles tool's ValidateSource fails because the bound source does not implement compatibleSource (PostgresPool() *pgxpool.Pool and RunSQL). Only Postgres-family sources expose a pgx pool, so any other source kind is rejected. This surfaces at startup when tools are resolved against sources.","triggerScenarios":"A `postgres-list-roles` tool whose `source:` points to a non-Postgres source (mysql, mssql, sqlite, http, etc.) or to an undefined/misspelled source.","commonSituations":"Hand-maintained configs spanning engines; renamed sources; combining cloud-sql-mysql with postgres tools after copying a template.","solutions":["Point `source:` at a Postgres-family source (postgres, cloud-sql-postgres, alloydb-postgres).","Verify the source key exists in `sources:` and its kind is Postgres-based.","Swap in the correct tool for your engine if not on Postgres."],"exampleFix":"# before\ntools:\n  list-roles:\n    kind: postgres-list-roles\n    source: mysql-prod\n# after\ntools:\n  list-roles:\n    kind: postgres-list-roles\n    source: pg-prod","handlingStrategy":"validation","validationCode":"src := myConfig.sources[tool.Source]\nif _, ok := src.(interface {\n    PostgresPool() *pgxpool.Pool\n    RunSQL(context.Context, string, []any) (any, error)\n}); !ok {\n    return fmt.Errorf(\"postgres-list-roles requires a Postgres-family source, got %T\", src)\n}","typeGuard":"func isCompatiblePostgresSource(s sources.Source) bool {\n    _, ok := s.(interface {\n        PostgresPool() *pgxpool.Pool\n        RunSQL(context.Context, string, []any) (any, error)\n    })\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Pair role-listing tools exclusively with Postgres kinds.","Keep one config file per database engine to prevent cross-engine tool reuse.","Validate configs at startup in CI."],"tags":["postgres","source-validation","config","go"],"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"}