Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL database adapter for CoreMCP.
Index ¶
- func New(dsn string) (core.Source, error)
- type PostgresAdapter
- func (p *PostgresAdapter) Close(_ context.Context) error
- func (p *PostgresAdapter) Connect(ctx context.Context) error
- func (p *PostgresAdapter) ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*core.QueryResult, error)
- func (p *PostgresAdapter) ExecuteQuery(ctx context.Context, query string, args ...any) (*core.QueryResult, error)
- func (p *PostgresAdapter) GetProcedures(ctx context.Context) ([]core.StoredProcedure, error)
- func (p *PostgresAdapter) GetSchema(ctx context.Context) ([]core.TableSchema, error)
- func (p *PostgresAdapter) GetViews(ctx context.Context) ([]core.ViewSchema, error)
- func (p *PostgresAdapter) Name() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PostgresAdapter ¶
type PostgresAdapter struct {
// contains filtered or unexported fields
}
PostgresAdapter implements the core.Source interface for PostgreSQL.
func (*PostgresAdapter) ExecuteProcedure ¶
func (p *PostgresAdapter) ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*core.QueryResult, error)
ExecuteProcedure calls a stored procedure or function by name with named parameters. Parameters are passed as positional args ($1, $2, ...) sorted alphabetically by name. Attempts CALL first (PG 11+ PROCEDURE), falls back to SELECT * FROM for functions.
func (*PostgresAdapter) ExecuteQuery ¶
func (p *PostgresAdapter) ExecuteQuery(ctx context.Context, query string, args ...any) (*core.QueryResult, error)
ExecuteQuery runs a SQL query against the PostgreSQL database. PostgreSQL natively supports LIMIT N so no rewrite is needed.
func (*PostgresAdapter) GetProcedures ¶
func (p *PostgresAdapter) GetProcedures(ctx context.Context) ([]core.StoredProcedure, error)
GetProcedures retrieves stored procedures and functions from the database. Both FUNCTION and PROCEDURE routine types are returned (PG 11+ has native PROCEDUREs).
func (*PostgresAdapter) GetSchema ¶
func (p *PostgresAdapter) GetSchema(ctx context.Context) ([]core.TableSchema, error)
GetSchema retrieves all user tables with columns, PKs, FKs, and column comments. Column comments are sourced from pg_description (COMMENT ON COLUMN).
func (*PostgresAdapter) GetViews ¶
func (p *PostgresAdapter) GetViews(ctx context.Context) ([]core.ViewSchema, error)
GetViews retrieves all user-defined views with their column definitions.
func (*PostgresAdapter) Name ¶
func (p *PostgresAdapter) Name() string