list_schemas
Retrieve and display all schemas within a PostgreSQL database, enabling users to explore database structure and metadata for improved database navigation and analysis.
Instructions
List all schemas in the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:310-335 (handler)The handler function for 'list_schemas' tool. Connects to the PostgreSQL database, queries information_schema.schemata excluding system schemas, and returns a formatted text list of available schemas.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:109-116 (registration)Registration of the 'list_schemas' tool in the ListToolsRequestSchema handler response, including name, description, and input schema (empty object).{ name: 'list_schemas', description: 'List all schemas in the database', inputSchema: { type: 'object', properties: {}, }, },
- src/index.js:112-115 (schema)Input schema definition for the 'list_schemas' tool: an empty object with no required parameters.inputSchema: { type: 'object', properties: {}, },
- src/index.js:154-155 (registration)Dispatch/registration case in the CallToolRequestSchema handler's switch statement that invokes the listSchemas method.case 'list_schemas': return await this.listSchemas();