list_tables
Discover available data by retrieving all tables from the Avanti Fellows PostgreSQL database, excluding system schemas, to understand database structure.
Instructions
List all tables in the database.
Returns tables from all schemas (excluding system schemas).
Use this to discover what data is available.
Returns:
JSON array of tables with schema, name, and type
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_postgres/server.py:75-100 (handler)The core handler function for the 'list_tables' MCP tool. Decorated with @mcp.tool() for automatic registration. Executes a fixed SQL query against information_schema.tables to list all non-system tables, formats results as JSON, and handles errors.@mcp.tool() async def list_tables() -> str: """List all tables in the database. Returns tables from all schemas (excluding system schemas). Use this to discover what data is available. Returns: JSON array of tables with schema, name, and type """ sql = """ SELECT table_schema, table_name, table_type FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') ORDER BY table_schema, table_name """ try: async with get_connection() as conn: rows = await conn.fetch(sql) results = [dict(row) for row in rows] return json.dumps(results, indent=2) except Exception as e: return json.dumps({"error": str(e)})