postgres

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL database adapter for CoreMCP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dsn string) (core.Source, error)

New creates a new PostgreSQL adapter. DSN format: postgresql://user:password@host:port/dbname?sslmode=disable

Types

type PostgresAdapter

type PostgresAdapter struct {
	// contains filtered or unexported fields
}

PostgresAdapter implements the core.Source interface for PostgreSQL.

func (*PostgresAdapter) Close

func (p *PostgresAdapter) Close(_ context.Context) error

func (*PostgresAdapter) Connect

func (p *PostgresAdapter) Connect(ctx context.Context) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL