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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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)})
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the tool's read-only nature through context ('Get sample rows') and mentions the limit constraint ('max: 100'), but doesn't cover other behavioral aspects like error conditions, permissions needed, or performance characteristics that would be helpful for an agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It starts with the core purpose, provides usage context, then details parameters and return values in clear sections. Every sentence adds value with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, 1 required), no annotations, but with an output schema (implied by 'Returns: JSON array of sample rows'), the description is reasonably complete. It covers purpose, usage, parameters, and returns, though additional behavioral context would improve completeness for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant value beyond the input schema, which has 0% description coverage. It provides clear explanations for all three parameters including defaults and constraints (e.g., 'default: public', 'default: 10, max: 100'), which the schema only indicates through titles and default values without explanation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('sample rows from a table'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'query' or 'describe_table', which could also help understand data structure.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('for understanding what data looks like without writing a full query'), which implicitly distinguishes it from 'query' (for full queries) and 'describe_table' (for schema info). However, it doesn't explicitly state when NOT to use it or name specific alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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