Skip to main content
Glama
avantifellows

Avanti Fellows PostgreSQL MCP Server

Official

sample_data

Retrieve sample rows from PostgreSQL tables to understand data structure without writing queries. Specify table name, schema, and row limit for quick data inspection.

Instructions

Get sample rows from a table.

Useful for understanding what data looks like without writing a full query. Args: table_name: Name of the table schema_name: Schema name (default: public) limit: Number of rows to return (default: 10, max: 100) Returns: JSON array of sample rows

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
schema_nameNopublic
limitNo

Implementation Reference

  • The handler function for the 'sample_data' MCP tool. It is decorated with @mcp.tool() for registration and implements fetching up to 100 sample rows from a PostgreSQL table, serializing them to JSON.
    @mcp.tool() async def sample_data(table_name: str, schema_name: str = "public", limit: int = 10) -> str: """Get sample rows from a table. Useful for understanding what data looks like without writing a full query. Args: table_name: Name of the table schema_name: Schema name (default: public) limit: Number of rows to return (default: 10, max: 100) Returns: JSON array of sample rows """ limit = min(limit, 100) # Cap at 100 rows # Use identifier quoting to prevent SQL injection sql = f'SELECT * FROM "{schema_name}"."{table_name}" LIMIT {limit}' try: async with get_connection() as conn: rows = await conn.fetch(sql) results = [] for row in rows: results.append({k: _serialize_value(v) for k, v in dict(row).items()}) return json.dumps(results, indent=2, default=str) except Exception as e: return json.dumps({"error": str(e)})

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/avantifellows/mcp-postgres'

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