Skip to main content
Glama

mcp_quick_data_analysis

Perform quick statistical analysis on database tables to get row counts, column distributions, and top values for data exploration.

Instructions

Quick statistical analysis of a table including row count, column distributions, and top values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesFully qualified table name (schema.table), e.g. "dbo.Users" or "sales.OrderItems"
sample_sizeNoSample size for statistics calculation

Implementation Reference

  • Core handler function that performs quick data analysis: fetches column metadata, row count, and data preview using parallel SQL queries on sys.columns and the table.
    export const mcp_quick_data_analysis = async (args: {
      table_name: string;
      limit?: number
    }): Promise<ToolResult<{
      preview_data: any[];
      column_count: number;
      row_count: number;
      columns_info: any[];
    }>> => {
      const { table_name, limit = 100 } = args;
      console.log('Executing mcp_quick_data_analysis with:', args);
    
      try {
        const pool = getPool();
        const normalizedTableName = normalizeSqlObjectName(table_name);
        
        // Get table column information
        const columnsQuery = `
          SELECT 
            c.name AS column_name,
            t.name AS data_type,
            c.max_length,
            c.precision,
            c.scale,
            c.is_nullable,
            c.is_identity
          FROM 
              sys.columns c
          INNER JOIN 
              sys.types t ON c.user_type_id = t.user_type_id
          WHERE 
              c.object_id = OBJECT_ID(@table_name)
          ORDER BY 
              c.column_id;
        `;
        
        // Get row count
        const countQuery = `
          SELECT COUNT(*) AS row_count FROM ${normalizedTableName}
        `;
        
        // Get preview data
        const previewQuery = `
          SELECT TOP ${limit} * FROM ${normalizedTableName} ORDER BY (SELECT NULL)
        `;
        
        // Execute all queries in parallel
        const [columnsResult, countResult, previewResult] = await Promise.all([
          pool.request().input('table_name', normalizedTableName).query(columnsQuery),
          pool.request().query(countQuery),
          pool.request().query(previewQuery)
        ]);
        
        return {
          success: true,
          data: {
            preview_data: previewResult.recordset,
            column_count: columnsResult.recordset.length,
            row_count: countResult.recordset[0]?.row_count || 0,
            columns_info: columnsResult.recordset
          }
        };
      } catch (error: any) {
        console.error(`Error in mcp_quick_data_analysis: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
  • Input schema definition for the mcp_quick_data_analysis tool, specifying table_name (required) and optional sample_size.
    {
      name: "mcp_quick_data_analysis",
      description: "Quick statistical analysis of a table including row count, column distributions, and top values",
      inputSchema: {
        type: "object",
        properties: {
          table_name: {
            type: "string",
            description: "Fully qualified table name (schema.table), e.g. \"dbo.Users\" or \"sales.OrderItems\""
          },
          sample_size: {
            type: "number",
            description: "Sample size for statistics calculation",
            default: 1000
          }
        },
        required: ["table_name"]
      }
    },
  • Export statement registering the mcp_quick_data_analysis handler from dataOperations for use in other modules.
    export {
      mcp_preview_data,      // Data preview with filters
      mcp_preview_data_enhanced, // Para compatibilidad con server.ts
      mcp_get_column_stats,   // Column statistics
      mcp_get_column_stats_enhanced, // Para compatibilidad con server.ts
      mcp_quick_data_analysis, // Quick table analysis
      mcp_get_sample_values   // Sample values from column
    } from './dataOperations.js';
  • src/server.ts:103-104 (registration)
    Server dispatch case that invokes the mcp_quick_data_analysis tool handler via toolHandlers.
    case 'mcp_quick_data_analysis':
        result = await toolHandlers.mcp_quick_data_analysis(input as any);
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 mentions 'quick' analysis and sample-based statistics, which hints at performance characteristics, but doesn't clarify critical aspects like whether this is a read-only operation, potential impact on database performance, error handling, or output format. For a statistical analysis tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence that front-loads the core purpose ('Quick statistical analysis of a table') and lists key outputs. There's no wasted verbiage or redundancy, making it highly concise and well-structured for quick comprehension.

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 (statistical analysis with sampling), lack of annotations, and no output schema, the description is minimally adequate. It covers the what (analysis types) but misses the how (behavioral traits) and why (usage context). It doesn't explain return values or error conditions, leaving the agent to infer from the tool name and parameters alone.

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

Parameters3/5

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

The description doesn't explicitly mention parameters, but it implies the need for a table name through context ('analysis of a table'). The input schema has 100% description coverage, with clear documentation for both 'table_name' and 'sample_size'. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description adds minimal value beyond what's already in the structured schema.

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: 'Quick statistical analysis of a table including row count, column distributions, and top values.' It specifies the verb ('analysis') and resource ('table'), and lists specific statistical outputs. However, it doesn't explicitly differentiate from sibling tools like 'mcp_get_column_stats' or 'mcp_table_analysis', which likely offer similar functionality.

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 multiple sibling tools that appear related (e.g., 'mcp_get_column_stats', 'mcp_table_analysis', 'mcp_preview_data'), there's no indication of what makes this 'quick' analysis distinct or when it's preferred over other options. No exclusions or prerequisites are mentioned.

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/hendrickcastro/MCPQL'

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