Skip to main content
Glama
rickyb30

DataPilot MCP Server

by rickyb30

get_table_sample

Extract a data sample from a specified table to preview content, structure, and quality before analysis or processing.

Instructions

Get a sample of data from a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYes
errorNo
columnsYes
successYes
query_idNo
row_countYes
warehouse_usedNo
execution_time_msNo

Implementation Reference

  • Primary MCP tool handler registered with @mcp.tool(). Handles context logging, error handling, and delegates to SnowflakeClient.get_table_sample.
    @mcp.tool()
    async def get_table_sample(table_name: str, limit: int = 10, ctx: Context = None) -> QueryResult:
        """Get a sample of data from a table"""
        await ctx.info(f"Getting sample data from table: {table_name} (limit: {limit})")
        
        try:
            client = await get_snowflake_client()
            result = await client.get_table_sample(table_name, limit)
            
            if result.success:
                await ctx.info(f"Retrieved {result.row_count} sample rows")
            else:
                await ctx.error(f"Failed to get sample: {result.error}")
            
            return result
            
        except Exception as e:
            logger.error(f"Error getting table sample: {str(e)}")
            await ctx.error(f"Failed to get table sample: {str(e)}")
            return QueryResult(
                success=False,
                data=[],
                columns=[],
                row_count=0,
                error=str(e)
            )
  • Core helper method in SnowflakeClient class that constructs the SQL query for sampling table data and executes it using the client's execute_query method.
    async def get_table_sample(self, table_name: str, limit: int = 10) -> QueryResult:
        """Get a sample of data from a table"""
        query = f"SELECT * FROM {table_name} LIMIT {limit}"
        return await self.execute_query(query)
  • Pydantic model defining the output schema (QueryResult) returned by the get_table_sample tool.
    class QueryResult(BaseModel):
        """Result of a SQL query execution"""
        success: bool
        data: List[Dict[str, Any]]
        columns: List[str]
        row_count: int
        execution_time_ms: Optional[int] = None
        query_id: Optional[str] = None
        warehouse_used: Optional[str] = None
        error: Optional[str] = None
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action but doesn't cover critical traits like whether this is a read-only operation, if it requires specific permissions, how sampling is performed (e.g., random vs. first rows), or any rate limits. The description is minimal and leaves key behaviors unspecified.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words, making it appropriately concise. It's front-loaded with the core action, though it could benefit from slightly more detail given the lack of annotations and low schema coverage. Overall, it's well-structured but under-specified.

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

Completeness3/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 (2 parameters, no annotations) and the presence of an output schema, the description is minimally adequate. The output schema likely covers return values, reducing the need for description details. However, with 0% schema coverage and no annotations, the description should do more to explain parameters and behavior, making it borderline complete.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'table' and 'sample' but doesn't explain the 'table_name' parameter's format or scope, nor the 'limit' parameter's role in defining sample size. The description adds minimal meaning beyond the bare schema, failing to clarify parameter usage effectively.

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

Purpose3/5

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

The description 'Get a sample of data from a table' clearly states the verb ('Get') and resource ('data from a table'), making the purpose understandable. However, it's vague about what constitutes a 'sample' and doesn't differentiate from siblings like 'describe_table' or 'execute_sql' that might also retrieve table data. It avoids tautology but lacks specificity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'execute_sql' for custom queries or 'describe_table' for metadata, there's no indication of context, prerequisites, or exclusions. It implies usage for sampling data but offers no comparative advice.

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/rickyb30/datapilot-mcp-server'

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