list_schemas
List all schemas in a PostgreSQL database to inspect database structure, enabling efficient data organization, analysis, and management.
Instructions
List all schemas in the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:392-416 (handler)The main handler function for the 'list_schemas' tool. It queries the information_schema.schemata to list all schemas and returns the result as JSON.private async handleListSchemas() { await this.ensureConnection(); try { const result = await this.client!.query(` SELECT schema_name FROM information_schema.schemata ORDER BY schema_name `); return { content: [ { type: 'text', text: JSON.stringify(result.rows, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to list schemas: ${getErrorMessage(error)}` ); } }
- src/index.ts:214-218 (schema)Input schema for the 'list_schemas' tool, which takes no parameters.inputSchema: { type: 'object', properties: {}, required: [], },
- src/index.ts:211-219 (registration)Registration of the 'list_schemas' tool in the ListTools response, including name, description, and schema.{ name: 'list_schemas', description: 'List all schemas in the database', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:263-264 (registration)Dispatch case in the CallToolRequest handler that routes to the list_schemas handler.case 'list_schemas': return await this.handleListSchemas();