/** * postgres-mcp - PostgreSQL Adapter * * Main PostgreSQL database adapter with connection pooling, * query execution, and tool registration. * * Transaction operations are in ./transaction-operations.ts. */ import type { PoolClient } from "pg"; import { DatabaseAdapter } from "../database-adapter.js"; import { ConnectionPool } from "../../pool/connection-pool.js"; import type { DatabaseConfig, QueryResult, SchemaInfo, TableInfo, IndexInfo, HealthStatus, AdapterCapabilities, ToolDefinition, ResourceDefinition, PromptDefinition, ToolGroup } from "../../types/index.js"; import type { BackupManager } from "../../audit/backup-manager.js"; export declare class PostgresAdapter extends DatabaseAdapter { readonly type: "postgresql"; readonly name = "PostgreSQL Adapter"; readonly version: string; private pool; private activeTransactions; private backupManager; private cachedToolDefinitions; private metadataCache; private cacheTtlMs; /** * Invalidate cached metadata for a specific table. * Called after DDL operations that change table structure. */ invalidateTableCache(tableName: string, schemaName?: string): void; /** * Invalidate all schema-related metadata caches. * Used when the specific affected table cannot be determined. */ invalidateSchemaCache(): void; connect(config: DatabaseConfig): Promise; disconnect(): Promise; getHealth(): Promise; executeReadQuery(sql: string, params?: unknown[]): Promise; executeWriteQuery(sql: string, params?: unknown[]): Promise; executeQuery(sql: string, params?: unknown[]): Promise; /** * Execute a query on a specific connection (for transactions) */ executeOnConnection(client: PoolClient, sql: string, params?: unknown[]): Promise; beginTransaction(isolationLevel?: string, readOnly?: boolean): Promise; commitTransaction(transactionId: string): Promise; rollbackTransaction(transactionId: string): Promise; createSavepoint(transactionId: string, savepointName: string): Promise; releaseSavepoint(transactionId: string, savepointName: string): Promise; rollbackToSavepoint(transactionId: string, savepointName: string): Promise; /** * Get connection for a transaction */ getTransactionConnection(transactionId: string): PoolClient | undefined; /** * Get all active transaction IDs * Used by code mode to track transactions started during execution */ getActiveTransactionIds(): string[]; /** * Rollback and cleanup a specific transaction by ID * Used for cleaning up orphaned transactions after code mode errors */ cleanupTransaction(transactionId: string): Promise; /** * Cache helpers object for schema operation functions */ private get cacheHelpers(); getSchema(): Promise; /** * Get all indexes across all user tables in a single query * Performance optimization: eliminates N+1 query pattern * Public so it can be used by pg_get_indexes when no table is specified */ getAllIndexes(): Promise; listTables(): Promise; describeTable(tableName: string, schemaName?: string): Promise; listSchemas(): Promise; /** * Get indexes for a table */ getTableIndexes(tableName: string, schemaName?: string): Promise; /** * Check if an extension is available */ isExtensionAvailable(extensionName: string): Promise; getCapabilities(): AdapterCapabilities; getSupportedToolGroups(): ToolGroup[]; getToolDefinitions(): ToolDefinition[]; getResourceDefinitions(): ResourceDefinition[]; getPromptDefinitions(): PromptDefinition[]; /** * Get the connection pool (for monitoring tools) */ getPool(): ConnectionPool | null; /** * Set the backup manager reference for audit backup tools. * Called by PostgresMcpServer after creating the BackupManager. */ setBackupManager(manager: BackupManager): void; } //# sourceMappingURL=postgres-adapter.d.ts.map