Postgresql MCP server

Connect Postgresql to Claude, ChatGPT, Cursor, Claude Code, Codex, Gemini, GitHub Copilot and any other MCP client, for your whole team. Metorial adds security, governance, and tracing, and gives everyone one Magic MCP URL to connect.

What you can do with the Postgresql MCP server

Ask your agent in plain language. Each of these maps to a real tool on the server.

  • Use the list tables tool in Postgresql
  • Use the delete rows tool in Postgresql
  • Use the list schemas tool in Postgresql
  • Use the insert rows tool in Postgresql
  • Use the manage table tool in Postgresql
  • Use the describe table tool in Postgresql

How teams use Postgresql with agents

PostgreSQL is the database behind most products. Connecting it lets an agent explore schemas, answer questions with SQL and, where you allow it, insert or update rows and manage tables and indexes.

Answer data questions

Turn a question into a SELECT query and return the rows, with the SQL shown.

Explore a schema

List schemas and tables and describe columns before writing a query.

Support fixes

Update a single record, such as a stuck order status, with a reviewed query.

Database upkeep

Add an index for a slow query or create a view for a recurring report.

Tools to start with

  • Select Query: Read-only queries.
  • Describe Table: Columns, types and constraints.
  • Manage Indexes: Create or drop indexes.

Sign-in and permissions

PostgreSQL connects with connection parameters or a connection string. Use a dedicated database role, read-only unless the agent needs to write, and make sure the database accepts connections from Metorial, or run Metorial in your own cloud.

Sign-in options on Metorial: Connection Parameters, Connection String.

Supported Tools

list_tables

List Tables

List all tables in the PostgreSQL database, optionally filtered by schema. Returns table names, schemas, row estimates, and size information. Also supports listing views and materialized views.

delete_rows

Delete Rows

Delete rows from a PostgreSQL table based on a WHERE condition. Supports returning the deleted rows and requires explicit confirmation for full-table deletes.

list_schemas

List Schemas

List all schemas in the PostgreSQL database with their table counts and sizes. Useful for exploring the database structure and understanding the organization of tables across schemas.

insert_rows

Insert Rows

Insert one or more rows into a PostgreSQL table. Provide the data as an array of objects where keys are column names and values are the data to insert. Supports inserting multiple rows in a single operation and can optionally return the inserted rows.

manage_table

Manage Table

Create, alter, or drop a PostgreSQL table. Supports creating tables with columns, constraints, and foreign keys. For altering tables, supports adding columns, dropping columns, renaming columns, altering column types, and renaming the table.

describe_table

Describe Table

Get detailed schema information for a specific table, including columns, data types, constraints, indexes, and foreign keys. Useful for understanding table structure before building queries or modifying schemas.

manage_roles

Manage Roles

Manage PostgreSQL roles and their privileges. Supports creating and dropping roles, as well as granting and revoking privileges on databases, schemas, tables, and other objects.

manage_indexes

Manage Indexes

Create or drop indexes on PostgreSQL tables. Supports B-tree, Hash, GIN, GiST, and other index types. Can create unique indexes, partial indexes with WHERE conditions, and multi-column indexes.

update_rows

Update Rows

Update rows in a PostgreSQL table based on a WHERE condition. Specify the columns to update and their new values. Supports returning updated rows and allows complex WHERE conditions.

execute_query

Execute SQL Query

Execute an arbitrary SQL query against the PostgreSQL database. Supports all SQL operations including SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, and more. Returns column metadata and result rows for SELECT queries, or affected row counts for DML statements. Supports complex queries with joins, subqueries, CTEs, window functions, and aggregations.

manage_schemas

Manage Schemas

Create, rename, or drop PostgreSQL schemas. Schemas are namespaces for tables, views, functions, and other database objects.

manage_views

Manage Views

Create and drop PostgreSQL views or materialized views, and refresh materialized views.

select_query

Select Query

Run a read-only SELECT query against the PostgreSQL database. Use this tool for data retrieval, reporting, analytics, joins, subqueries, read-only CTEs, window functions, and aggregations. Rejects non-SELECT SQL and runs inside a PostgreSQL READ ONLY transaction so data-changing statements are blocked. Use execute_query only when you intentionally need broader SQL operations such as INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP.

Connect Postgresql to your AI client

Every client uses the same Magic MCP URL, and so does any other MCP client. Add it once and sign in with SSO.

  1. Enable Postgresql in Metorial. In your Metorial portal, enable the Postgresql MCP server and sign in with the account that owns the data. Access stays governed by your team policies.
  2. Add a custom connector. Open Customize, then Connectors. Select Add, then Custom, then Web.
  3. Paste your Metorial MCP URL. Name it Metorial, paste your Magic MCP URL (<your-magic-mcp-url>) and continue.
  4. Sign in. Select Add and sign in to load Postgresql tools.

Run Postgresql through the Metorial gateway

One governed layer for every app your agents reach, not a separate connector per tool.

  • Give Postgresql and every other app to your whole team through one MCP gateway, behind your SSO.
  • Scope which teams and agents can use Postgresql tools with role-based access control, and trace every call.
  • Prefer to run it yourself? Metorial is open source and self-hostable.

More integrations teams use with Postgresql

Google Sheets

Create, read, and update spreadsheets and their cell data. Read and write values to individual cells, ranges, or multiple ranges using A1 notation or named ranges. Apply cell formatting including text styles, backgrounds, borders, number formats, and conditional formatting. Manage sheets (tabs) within a spreadsheet—add, delete, copy, rename, and reorder them. Create and manage embedded charts, pivot tables, filter views, data validation rules, protected ranges, named ranges, and merged cells. Perform batch operations to apply multiple updates atomically.

GitHub

Manage repositories, issues, and pull requests. Create and configure branches, star repositories, review code, and merge changes. Automate CI/CD workflows with GitHub Actions, manage workflow runs, secrets, and artifacts. Track issues with labels, milestones, and assignees. Search across code, repositories, issues, and users. Manage organizations, teams, and memberships. Create and manage projects, gists, packages, deployments, and environments. Access security alerts including code scanning, secret scanning, and Dependabot alerts. Read and write file contents in repositories. Manage webhooks, notifications, and codespaces.

Salesforce

Manage CRM data including Accounts, Contacts, Leads, Opportunities, Cases, and custom objects. Create, read, update, and delete records. Query data using SOQL and search across objects using SOSL. Perform bulk data operations for large-scale imports, exports, and migrations. Execute composite requests to batch multiple operations in a single API call. Access analytics, reports, and dashboards. Manage files and attachments associated with records. Interact with Chatter feeds, posts, and groups for social collaboration. Manage org metadata including custom objects, fields, layouts, and workflows. Query data using GraphQL for precise data retrieval across related objects.

Sharepoint

Manage SharePoint sites, document libraries, lists, and files. Create, read, update, and delete lists and list items with custom columns. Resolve site users to numeric Person/Group LookupId values. Upload, download, move, copy, and version files in document libraries. Search across sites, files, folders, lists, and list items using Microsoft Search. Manage permissions at site, list, and item levels with granular access control. Define and manage content types and site columns. Retrieve site properties and search for sites across Microsoft 365.

Airtable

Create, read, update, and delete records in Airtable bases and tables. Manage base schemas including creating tables and fields. Filter records using formulas, sort by fields, and scope queries to specific views. Upsert records to find, create, or update in a single call. Upload attachments to records, read and write record comments, list accessible bases, and receive real-time base change events through webhooks.

Google Drive

Upload, download, create, copy, move, rename, trash, and permanently delete files and folders in Google Drive. Search for files using complex queries filtering by name, MIME type, owner, modification date, labels, and other metadata. Share files and folders with specific users, groups, or domains with role-based permissions (owner, writer, commenter, reader). Manage shared drives and their members. Export Google Workspace files (Docs, Sheets, Slides) to standard formats like PDF, DOCX, and XLSX. Track file revision history and restore earlier versions. Create, read, update, and delete threaded comments and replies on files. Read label definitions and search files by label. Browse the Drive apps installed for your account. Store app-specific data in a hidden per-user folder.

Technical notes for Postgresql

Query, insert, update, and delete data in PostgreSQL relational databases. Explore schemas and tables, manage schemas, tables, indexes, views, materialized views, and database roles, and poll tables for row changes using timestamp or incrementing columns.

Frequently asked questions

Common questions about connecting Postgresql to AI agents with Metorial.

  1. How many tools does the Postgresql MCP server have?
    The Postgresql MCP server exposes 13 tools, including List Tables, Delete Rows, List Schemas. Each one is governed and traced through Metorial.
  2. Postgresql exposes tools your agents call on demand; it does not publish event triggers yet. Everything still runs through one governed MCP URL.
  3. Any MCP client, including VS Code, Windsurf, Zed, OpenCode and Grok. Each one reaches the Postgresql MCP server through the same Metorial URL.
  4. Use role-based access control to decide which teams, users, and agents can use Postgresql and which of its tools they can call.
  5. Yes. Metorial is open source, so you can run the Postgresql MCP server yourself or use the hosted gateway.

Connect Postgresql to production AI agents

See how Metorial gives your team governed access to Postgresql, with tracing and security controls built in.