list_schemas
Retrieve all database schemas to explore PostgreSQL database structure and understand table relationships.
Instructions
List all schemas in the database
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_schemas"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:310-335 (handler)The main handler function for the 'list_schemas' tool. It connects to the PostgreSQL database, queries the information_schema.schemata to list all schemas (excluding system schemas), formats the result as a bulleted list, and returns it in the MCP content format.
async listSchemas() { const client = await this.connectToDatabase(); try { const query = ` SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('information_schema', 'pg_catalog', 'pg_toast') ORDER BY schema_name; `; const result = await client.query(query); return { content: [ { type: 'text', text: `Available schemas:\n\n` + result.rows.map(row => `• ${row.schema_name}`).join('\n'), }, ], }; } finally { await client.end(); } } - src/index.js:112-115 (schema)Input schema definition for the 'list_schemas' tool, specifying an empty object (no input parameters required).
inputSchema: { type: 'object', properties: {}, }, - src/index.js:109-116 (registration)Tool registration in the ListToolsRequestSchema response, defining the name, description, and input schema for 'list_schemas'.
{ name: 'list_schemas', description: 'List all schemas in the database', inputSchema: { type: 'object', properties: {}, }, }, - src/index.js:154-155 (registration)Dispatcher case in the CallToolRequestSchema handler that routes calls to the listSchemas() method.
case 'list_schemas': return await this.listSchemas();