Skip to main content
Glama
michaelyuwh

Enhanced MCP MSSQL Server

by michaelyuwh

mssql_sample_data

Retrieve sample data from MSSQL Server tables to preview content and structure for analysis or testing purposes.

Instructions

Get sample data from a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesMSSQL Server hostname or IP address
portNoPort number (default: 1433)
userYesUsername for authentication
passwordYesPassword for authentication
databaseYesDatabase name
tableYesTable name
limitNoNumber of sample rows (default: 10)
encryptNoUse encrypted connection (default: true)
trustServerCertificateNoTrust server certificate (default: true)

Implementation Reference

  • Executes the tool logic: parses arguments, connects to MSSQL, queries sample data with SELECT TOP ${limit} * FROM [table], returns JSON with results.
    private async handleSampleData(args: any) {
      const config = ConnectionSchema.parse(args);
      const { table, limit = 10 } = args;
      const pool = await this.getConnection(config);
      
      const request = pool.request();
      const result = await request.query(`
        USE [${config.database}];
        SELECT TOP ${limit} * FROM [${table}]
      `);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              server: config.server,
              database: config.database,
              table: table,
              sampleSize: result.recordset.length,
              data: result.recordset,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:342-360 (registration)
    Registers the mssql_sample_data tool in the list of available tools, including name, description, and input schema.
    {
      name: 'mssql_sample_data',
      description: 'Get sample data from a table',
      inputSchema: {
        type: 'object',
        properties: {
          server: { type: 'string', description: 'MSSQL Server hostname or IP address' },
          port: { type: 'number', description: 'Port number (default: 1433)', default: 1433 },
          user: { type: 'string', description: 'Username for authentication' },
          password: { type: 'string', description: 'Password for authentication' },
          database: { type: 'string', description: 'Database name' },
          table: { type: 'string', description: 'Table name' },
          limit: { type: 'number', description: 'Number of sample rows (default: 10)', default: 10 },
          encrypt: { type: 'boolean', description: 'Use encrypted connection (default: true)', default: true },
          trustServerCertificate: { type: 'boolean', description: 'Trust server certificate (default: true)', default: true },
        },
        required: ['server', 'user', 'password', 'database', 'table'],
      },
    },
  • src/index.ts:445-446 (registration)
    Dispatches tool calls to the handleSampleData handler in the switch statement.
    case 'mssql_sample_data':
      return await this.handleSampleData(args);
  • Zod schema used to parse and validate connection parameters for the tool.
    const ConnectionSchema = z.object({
      server: z.string().describe('MSSQL Server hostname or IP address'),
      port: z.number().default(1433).describe('Port number (default: 1433)'),
      user: z.string().describe('Username for authentication'),
      password: z.string().describe('Password for authentication'),
      database: z.string().optional().describe('Database name (optional)'),
      encrypt: z.boolean().default(true).describe('Use encrypted connection'),
      trustServerCertificate: z.boolean().default(true).describe('Trust server certificate'),
    });
Behavior2/5

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

With no annotations, the description carries full burden but only states basic functionality. It doesn't disclose behavioral traits like whether this is a read-only operation, potential performance impacts, authentication requirements beyond parameters, or how sample rows are selected (e.g., random vs. first N). The description is minimal and lacks critical context for safe use.

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 with zero waste. It's appropriately sized and front-loaded, though it could benefit from more detail given the tool's complexity.

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 tool's complexity (9 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain return values, error handling, or how 'sample data' is defined, leaving significant gaps for an AI agent to use it correctly.

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 all 9 parameters. The description adds no meaning beyond what the schema provides—it doesn't explain parameter interactions, default behaviors, or usage examples. Baseline 3 is appropriate when schema does all the work.

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 sample data from a table' clearly states the verb ('Get') and resource ('sample data from a table'), but it's vague about scope and doesn't distinguish from siblings like 'mssql_query' or 'mssql_describe_table'. It doesn't specify what 'sample' means or how it differs from a full query.

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 'mssql_query' for custom queries or 'mssql_describe_table' for schema info. The description implies a simple data retrieval but doesn't specify use cases, prerequisites, 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/michaelyuwh/mcp-mssql-connector'

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