Prerequisites

To get the most out of this guide, you’ll need to:

1. Create a Postgres MCP Server

Use the following endpoint to create a new remote Postgres MCP server instance:

Request

curl --request POST \
  --url https://api.klavis.ai/mcp-server/instance/create \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "serverName": "Postgres",
  "userId": "<YOUR_USER_ID>",
  "platformName": "<YOUR_PLATFORM_NAME>"
}'

Response

{
  "serverUrl": "https://postgres-mcp-server.klavis.ai/sse?instance_id=<instance-id>",
  "instanceId": "<instance-id>"
}
serverUrl specifies the endpoint of the Postgres MCP server, which allows you to interact with PostgreSQL databases.
instanceId is used for authentication and identification of your server instance.

2. Configure Postgres Connection

To connect to your PostgreSQL database, you need to configure the MCP server with your database credentials. They are usually in the form of postgresql://<user>:<password>@<host>:<port>/<database_name>.

Setting up Postgres Connection

curl --request POST \
  --url https://api.klavis.ai/mcp-server/instance/set-auth-token \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "instanceId": "<string>",
  "authToken": "<string>"
}'

Response

{
  "success": true,
  "message": "<string>"
}

Explore MCP Server Tools