Skip to main content
Glama

mcp_get_sample_values

Retrieve sample values from a database column to understand data patterns, validate content, or prepare for analysis. Specify table, column, and limit parameters to extract distinct values.

Instructions

Get sample values from a specific column in a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesFully qualified table name (schema.table), e.g. "dbo.Users"
column_nameYesName of the column to get sample values from
limitNoMaximum number of distinct values to return

Implementation Reference

  • The main execution handler for the mcp_get_sample_values tool. Queries the database for the top distinct values in the specified column, grouped by value with frequency counts, ordered by frequency descending.
    export const mcp_get_sample_values = async (args: {
      table_name: string;
      column_name: string;
      limit?: number
    }): Promise<ToolResult<any[]>> => {
      const { table_name, column_name, limit = 10 } = args;
      console.log('Executing mcp_get_sample_values with:', args);
    
      try {
        const pool = getPool();
        const normalizedTableName = normalizeSqlObjectName(table_name);
        
        const query = `
          SELECT TOP ${limit} [${column_name}] AS value, COUNT(*) AS frequency
          FROM ${normalizedTableName}
          WHERE [${column_name}] IS NOT NULL
          GROUP BY [${column_name}]
          ORDER BY COUNT(*) DESC, [${column_name}]
        `;
        
        const result = await pool.request().query(query);
        return { success: true, data: result.recordset };
      } catch (error: any) {
        console.error(`Error in mcp_get_sample_values: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
  • MCP tool schema definition specifying input parameters, descriptions, types, and requirements.
    {
      name: "mcp_get_sample_values",
      description: "Get sample values from a specific column in a table",
      inputSchema: {
        type: "object",
        properties: {
          table_name: {
            type: "string",
            description: "Fully qualified table name (schema.table), e.g. \"dbo.Users\""
          },
          column_name: {
            type: "string",
            description: "Name of the column to get sample values from"
          },
          limit: {
            type: "number",
            description: "Maximum number of distinct values to return",
            default: 10
          }
        },
        required: ["table_name", "column_name"]
      }
    },
  • src/tools.ts:189-211 (registration)
    The tool is registered in the MCP_MSQL_TOOLS array used by listTools handler.
    {
      name: "mcp_get_sample_values",
      description: "Get sample values from a specific column in a table",
      inputSchema: {
        type: "object",
        properties: {
          table_name: {
            type: "string",
            description: "Fully qualified table name (schema.table), e.g. \"dbo.Users\""
          },
          column_name: {
            type: "string",
            description: "Name of the column to get sample values from"
          },
          limit: {
            type: "number",
            description: "Maximum number of distinct values to return",
            default: 10
          }
        },
        required: ["table_name", "column_name"]
      }
    },
  • src/server.ts:97-99 (registration)
    Dispatcher switch case that routes calls to the mcp_get_sample_values handler.
    case 'mcp_get_sample_values':
        result = await toolHandlers.mcp_get_sample_values(input as any);
        break;
  • Re-export of the handler from dataOperations.ts to centralize tool exports.
      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, the description carries the full burden of behavioral disclosure. It states the tool 'gets sample values' but doesn't clarify whether this is a read-only operation, if it requires specific permissions, how it handles large datasets, or what the return format looks like. This leaves significant gaps for a tool that interacts with database tables.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand at a glance.

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 the complexity of database operations and the lack of both annotations and an output schema, the description is insufficient. It doesn't address behavioral aspects like safety, permissions, or return format, leaving the agent with incomplete context for proper tool invocation.

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 input schema already fully documents all three parameters. The description adds no additional meaning beyond what's in the schema—it doesn't explain relationships between parameters or provide usage examples. This meets the baseline for high schema coverage.

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 sample values') and target ('from a specific column in a table'), making the purpose immediately understandable. It distinguishes this from siblings like mcp_get_column_stats (statistics) and mcp_preview_data (full data preview), though it doesn't explicitly name these alternatives.

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?

No guidance is provided on when to use this tool versus alternatives like mcp_get_column_stats or mcp_preview_data. The description implies usage for sampling column values but offers no context about prerequisites, typical scenarios, or exclusions.

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