Databases

Connect a public PostgreSQL or MySQL database in read-only mode. Platica creates 4 tools: list tables, read columns, run SELECT queries, and paginate results. Connect the tools to the agents that need them.

Quick example

// 1. Connect the database (the password is stored encrypted as a secret)
const db = await platic.tools.databases.create({
  name: 'store',
  description: 'Orders and customers of the online store.',
  connectionString: process.env.STORE_DATABASE_URL!,
  hiddenColumns: ['customers.phone']
});

// 2. Test the connection and connect the query tool to your agent
const test = await platic.tools.databases.test(db.id);
if (test.connected) {
  const queryTool = db.tools.find((t) => t.tool === 'query')!;
  await platic.agents.tools.connect(agentId, queryTool.id);
}

What you need to know

  • Read-only: it runs one SELECT per query in a read-only transaction. Use a read-only database user too.
  • Hidden data: hiddenTables and hiddenColumns hide the selected tables and columns. On a table with hidden columns, select the columns instead of using SELECT *.
  • Secure password: it goes in password, connectionString, or passwordSecretId and is never returned. If you change the host, port, or SSL, it goes to needs_authorization and you must send it again.
  • Public hosts and Supabase: local and private hosts are rejected. On Supabase use the Session pooler (the direct connection only uses IPv6).
  • Limits: 20 connections per workspace, 1 to 200 rows per page (50 by default), 1 to 30 s timeout (5 s by default), 500 hidden tables/columns, and 10,000 characters per query.
  • Permissions: requires Integrations (and write permission with OAuth to create, change, or query).

Endpoints

MethodEndpointWhat it does
GET / POST/v1/tools/databasesList, or connect, a database
GET / PATCH / DELETE/v1/tools/databases/{databaseId}Get, update, or delete
POST/v1/tools/databases/{databaseId}/testTest the connection
GET/v1/tools/databases/{databaseId}/schemaSee tables and columns
POST/v1/tools/databases/{databaseId}/queryRun a SELECT or ask for the next page
POST/v1/tools/databases/{databaseId}/enableEnable, or pause, the connection

Errors are in Errors and AI tools in Databases MCP.