#!/usr/bin/env python3 """Quick script to show all tables and their details.""" import asyncio import os from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client async def main(): server_params = StdioServerParameters( command="python3", args=["pg_mcp_server/server.py"], env=os.environ.copy(), ) async with stdio_client(server_params) as (read, write): async with ClientSession(read, write) as session: await session.initialize() print("=" * 70) print("📊 DATABASE TABLES") print("=" * 70) # Get all tables schema = await session.call_tool("get_schema", {}) print(schema.content[0].text) # Analyze each table tables = ["users", "products", "orders", "order_items"] for table in tables: print(f"\n{'=' * 70}") print(f"📈 TABLE STATS: {table.upper()}") print("=" * 70) stats = await session.call_tool("get_table_stats", { "table_name": table, "sample_size": 3 }) print(stats.content[0].text) if __name__ == "__main__": os.environ["PG_CONNECTION_STRING"] = "postgresql://postgres:demo@localhost:5432/shop" asyncio.run(main())