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';

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