Postgres MCP server
Connect PostgreSQL to Claude with a hosted MCP server
Give Claude Desktop, Cursor and other MCP-compatible clients tools for working with live PostgreSQL data. Connect your database once, choose a table, and use its hosted MCP endpoint without building your own server.
- Hosted MCP endpoint for PostgreSQL
- Table-scoped links and discoverable tools
- Claude Desktop and Cursor configuration
- Database credentials stay server-side
Step by step: from database to endpoints
1.Connect your PostgreSQL database
Add a saved server in InstantAPI and choose PostgreSQL. Enter your host, port and database credentials; PostgreSQL commonly uses port 5432. Use the connection details required by your hosting provider and ensure its firewall permits the connection. Start with a test database and a dedicated read-only account if the first task is reporting.
2.Select a table and get its MCP endpoint
Open your database in Object Explorer, choose a schema and table, then open the MCP tab. Review the available tools and copy the table's MCP TinyURL. Use the link ending in /mcp, not the REST endpoint ending in /rows. Check the selected columns and permissions before sharing access with an agent.
3.Configure Claude or Cursor and test a read
Replace YOUR_TABLE_CODE in the example below with the code from your generated MCP link. Merge the configuration with any existing servers and reconnect the client as required. Inspect discovered tools, then ask it to list two rows without changing data. Confirm the results before allowing any write operation.
Claude Desktop configuration example
For Claude Desktop's local server configuration, mcp-remote bridges the hosted endpoint to the client. Install Node.js so npx is available, then add this entry to claude_desktop_config.json through the client's Developer settings. The code is a template: replace YOUR_TABLE_CODE with your own generated code. If your client provides a remote connector interface, use the same MCP URL there instead.
Use the same endpoint in Cursor
Cursor accepts a remote URL entry in .cursor/mcp.json or its global MCP configuration. Keep the endpoint private and check the MCP connection status before starting an agent task. You do not need to place your PostgreSQL password in this file.
Tools your agent can use
The workspace exposes crud_list_rows for paged reads, crud_create_row for inserts, crud_update_row for updates by primary key, and crud_delete_row for deletion by primary key. Published Custom APIs use run_custom_api with a slug and parameters. Review the tools/list response and input schemas in your connected client rather than assuming identical arguments for every resource.
A practical first task is: ‘List two rows from this table, summarize the fields returned, and do not modify data.’ For a recurring report, publish a focused parameterized Custom API rather than giving the agent a broader resource than it needs. Tool results come from the connected data source; review them before using them in a decision or follow-up action.
Secure PostgreSQL access for AI clients
A short link hides database and table names, but it is still an access link. Keep it out of public code and use a database account with the smallest useful permission set. Read-only database permissions are stronger than a prompt asking the agent not to make changes. Review Custom API definitions for sensitive fields and unexpected joins.
When enabling writes, use a non-production test first and inspect the arguments for each operation. Client confirmation controls can help review destructive actions, but they do not replace database permissions. Connecting an MCP server does not bypass your provider's firewall or create a tunnel into a private network.
Frequently asked questions
- What is a Postgres MCP server?
- A Model Context Protocol server gives an AI client structured tools for working with PostgreSQL data. The client discovers the available tools and their input schemas, then calls them to retrieve current records or perform permitted operations. InstantAPI hosts the endpoint, so you do not need to implement a separate MCP service.
- Does this work with Claude Desktop and Cursor?
- Yes, through an MCP-compatible client configuration. Claude Desktop can connect using the mcp-remote bridge shown below, which requires Node.js and npx. Cursor supports remote MCP URL entries. Client versions and account settings can affect configuration and remote connection options.
- Which PostgreSQL connection details do I need?
- Use your PostgreSQL hostname, port, database and credentials. The usual port is 5432, but use your provider's actual connection details. The service must be able to reach the database; firewall rules and private-only networking still apply. Test connectivity before adding the endpoint to your AI client.
- Can Claude access every table in my database?
- A table MCP link is scoped to the selected table, rather than the entire database. Only share the resources needed for the task. A published Custom API can intentionally query additional tables, so review its SQL and output separately. Use a dedicated least-privilege database account to constrain operations.
- Can I make the connection read-only?
- Use a database account that has read permissions and no insert, update or delete permissions on the exposed objects. Database permissions are the enforcement boundary; asking the model not to write is not sufficient. Also inspect discovered tools and use client approval controls where available.
- Are my database credentials included in the MCP URL?
- No. Credentials remain server-side and are not embedded in the generated MCP link. However, the link provides access to its scoped resource, so treat it as sensitive. Do not commit it to public repositories or share it in public conversations.
- Can I expose a report instead of a whole table?
- Yes. Publish a parameterized Custom API for a focused report or query, then use its MCP endpoint. The agent supplies parameters to the saved operation. Review the query's scope and returned fields before sharing it, especially when it joins tables containing sensitive information.