Skip to main content
Glama

mcp_preview_data

Preview SQL Server table data with optional filters to quickly examine records before deeper analysis. Specify table name, apply filters, and set row limits to sample database content.

Instructions

Get a preview of data from a SQL Server table with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesFully qualified table name (schema.table), e.g. "dbo.Users"
filtersNoOptional filters as column-value pairs, e.g. {"Status": "Active"}
limitNoMaximum number of rows to return

Implementation Reference

  • Core implementation of the mcp_preview_data tool handler. Executes a parameterized SQL query to preview table data with optional filters and row limit.
    export const mcp_preview_data = async (args: { table_name: string; filters?: object; limit?: number }): Promise<ToolResult<any[]>> => {
      const { table_name, filters, limit = 100 } = args;
      console.log('Executing mcp_preview_data with:', args);
    
      try {
        const pool = getPool();
        const request = pool.request();
    
        const normalizedTableName = normalizeSqlObjectName(table_name);
        let query = `SELECT TOP ${limit} * FROM ${normalizedTableName}`;
    
        if (filters && Object.keys(filters).length > 0) {
          const whereClauses = Object.entries(filters).map(([key, value], index) => {
            const paramName = `param${index}`;
            request.input(paramName, value);
            return `${key} = @${paramName}`;
          });
          query += ` WHERE ${whereClauses.join(' AND ')}`;
        }
    
        const result = await request.query(query);
        return { success: true, data: result.recordset };
      } catch (error: any) {
        console.error('Error in mcp_preview_data:', error);
        return { success: false, error: error.message };
      }
    };
  • JSON schema definition and tool metadata for mcp_preview_data, including input validation schema used for MCP tool registration.
      name: "mcp_preview_data",
      description: "Get a preview of data from a SQL Server table with optional filters",
      inputSchema: {
        type: "object",
        properties: {
          table_name: {
            type: "string",
            description: "Fully qualified table name (schema.table), e.g. \"dbo.Users\""
          },
          filters: {
            type: "object",
            description: "Optional filters as column-value pairs, e.g. {\"Status\": \"Active\"}"
          },
          limit: {
            type: "number",
            description: "Maximum number of rows to return",
            default: 100,
            minimum: 1,
            maximum: 1000
          }
        },
        required: ["table_name"]
      }
    },
  • Export registration of the mcp_preview_data handler function from dataOperations for use in tool collections.
    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';
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'gets a preview' without disclosing behavioral traits like whether it's read-only, potential performance impacts, authentication needs, or rate limits. It lacks details on what 'preview' entails (e.g., sample rows, limited columns) beyond the schema's limit parameter.

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 ('Get a preview of data') and adds key detail ('with optional filters'). There's no wasted wording, making it appropriately sized and easy to parse.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a tool with 3 parameters and potential complexity. It doesn't explain return values, error handling, or how 'preview' differs from full queries, leaving gaps in understanding the tool's behavior and output.

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?

Schema description coverage is 100%, so the schema fully documents parameters like 'table_name' and 'filters'. The description adds minimal value by mentioning 'optional filters' but doesn't elaborate on semantics beyond what the schema provides, such as filter syntax examples or preview-specific constraints.

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 action ('Get a preview') and resource ('data from a SQL Server table'), specifying it's for previewing with optional filters. However, it doesn't distinguish this tool from sibling tools like 'mcp_get_sample_values' or 'mcp_quick_data_analysis', which might offer similar data retrieval functions.

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 mentions 'optional filters' but provides no guidance on when to use this tool versus alternatives like 'mcp_execute_query' for more complex queries or 'mcp_get_sample_values' for sampling. There's no explicit when/when-not usage context or sibling differentiation.

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