{"record":{"id":"4cf2baa7239da57b","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-4cf2ba","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/postgreslistlocks/postgreslistlocks.go","lineNumber":139,"sourceCode":"\tresp, err := source.RunSQL(ctx, listLocks, 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":121,"sourceCodeEnd":143,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/postgres/postgreslistlocks/postgreslistlocks.go#L121-L143","documentation":"This error is thrown by the postgres-list-locks tool's ValidateSource when the source attached to the tool does not implement the compatibleSource interface (PostgresPool() *pgxpool.Pool and RunSQL(context.Context, string, []any) (any, error)). Toolbox validates every tool/source pairing at startup so failures surface early instead of at invocation time. It means the tool is wired to a source kind (e.g. mysql, http) that cannot serve Postgres queries.","triggerScenarios":"Running `toolbox` (or AddTool/GetTool resolution) with a tools yaml where a `postgres-list-locks` tool references a `source:` whose registered source type does not satisfy compatibleSource — e.g. source kind mysql, mssql, cloud-sql-mysql, alloydb-mysql, sqlite, or any non-Postgres source.","commonSituations":"Copy-pasting a tool definition into a different source's config without changing `source:`; typo'd or unregistered `sourceKind` falling back to the wrong source; using cloud-sql-mysql with postgres tools; prebuilt config mixing when hand-editing.","solutions":["Point the tool's `source:` field at a source whose kind is postgres, cloud-sql-postgres, alloydb-postgres, or another Postgres-family source (PostgresPool/RunSQL implementer).","Confirm the referenced source is defined in the `sources:` section and its `kind` is a Postgres type.","If you intended a different database, use the equivalent tool for that source (e.g. mysql-list-tables) instead of the postgres tool.","Regenerate from the matching prebuilt config (e.g. postgres prebuilt.yaml) rather than hand-editing cross-source."],"exampleFix":"# before\nsources:\n  my-db:\n    kind: mysql\n    ...\ntools:\n  list-locks:\n    kind: postgres-list-locks\n    source: my-db\n# after\nsources:\n  my-db:\n    kind: postgres\n    ...\ntools:\n  list-locks:\n    kind: postgres-list-locks\n    source: my-db","handlingStrategy":"validation","validationCode":"kind, _ := myConfig.sources[tool.Source].(sources.Source)\npgSrc, ok := kind.(interface {\n    PostgresPool() *pgxpool.Pool\n    RunSQL(context.Context, string, []any) (any, error)\n})\nif !ok {\n    return fmt.Errorf(\"source %q for tool %q must be a Postgres-family source\", tool.Source, tool.Kind)\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":["Keep each tool's `source:` pointing at a source of the matching engine family (postgres tools -> postgres kinds).","Validate the toolbox yaml with `toolbox --prebuilt postgres` templates or a startup smoke test before deploying.","Never share a single tools block across mysql/postgres configs; generate per-engine configs.","Add a CI check that parses the yaml and asserts source kinds against tool kinds."],"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"}