list_schemas
Retrieve all database schemas to understand the structure and organization of PostgreSQL databases for efficient data management and query planning.
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 ensures a database connection, queries the information_schema.schemata for all schema names, and returns the results 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:263-264 (registration)Dispatch registration in the CallToolRequestSchema handler switch statement, routing 'list_schemas' calls to the handleListSchemas method.case 'list_schemas': return await this.handleListSchemas();
- src/index.ts:211-219 (schema)Tool registration in the ListToolsRequestSchema response, defining the name, description, and empty input schema for 'list_schemas'.{ name: 'list_schemas', description: 'List all schemas in the database', inputSchema: { type: 'object', properties: {}, required: [], }, },