Skip to main content
Glama
sbfulfil

PostgreSQL MCP Server

by sbfulfil

list_schemas

Retrieve all database schemas to explore PostgreSQL database structure and understand table relationships.

Instructions

List all schemas in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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();
      }
    }
  • 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();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sbfulfil/pg-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server