Skip to main content
Glama
michaelyuwh

Enhanced MCP MSSQL Server

by michaelyuwh

mssql_health_check

Monitor MSSQL server health and connectivity while collecting performance metrics to identify database issues and ensure operational stability.

Instructions

Check database server health and connectivity with performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesMSSQL Server hostname or IP address
portNoPort number (default: 1433)
userYesUsername for authentication
passwordYesPassword for authentication
encryptNoUse encrypted connection (default: true)
trustServerCertificateNoTrust server certificate (default: true)
includeMetricsNoInclude performance metrics (default: true)

Implementation Reference

  • The handler function for 'mssql_health_check' that connects to the MSSQL server, performs diagnostic queries (@@VERSION, GETDATE(), database properties), collects health metrics including response time, connection status, and optionally server metrics, and returns structured JSON response or error.
    private async handleHealthCheck(args: any) {
      const config = ConnectionSchema.parse(args);
      const { includeMetrics = true } = args;
      const startTime = Date.now();
    
      try {
        const pool = await this.getConnection(config);
        
        // Test basic connectivity
        const request = pool.request();
        const versionResult = await request.query('SELECT @@VERSION as version');
        const connectionTimeResult = await request.query('SELECT GETDATE() as server_time');
        
        // Get database status if database is specified
        let databaseInfo = null;
        if (config.database) {
          const dbRequest = pool.request();
          const dbResult = await dbRequest.query(`
            SELECT 
              DB_NAME() as database_name,
              DATABASEPROPERTYEX(DB_NAME(), 'Status') as status,
              DATABASEPROPERTYEX(DB_NAME(), 'Collation') as collation,
              DATABASEPROPERTYEX(DB_NAME(), 'Version') as version
          `);
          databaseInfo = dbResult.recordset[0];
        }
    
        const responseTime = Date.now() - startTime;
    
        const healthInfo: any = {
          status: 'healthy',
          server: config.server,
          database: config.database || 'master',
          serverVersion: versionResult.recordset[0]?.version,
          serverTime: connectionTimeResult.recordset[0]?.server_time,
          responseTime: responseTime,
          connectionPoolInfo: {
            connected: pool.connected,
            connecting: pool.connecting,
            healthy: pool.healthy
          }
        };
    
        if (databaseInfo) {
          healthInfo.databaseInfo = databaseInfo;
        }
    
        if (includeMetrics) {
          healthInfo.metrics = {
            ...this.metrics,
            activeConnections: this.connectionPools.size
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(healthInfo, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                status: 'unhealthy',
                server: config.server,
                database: config.database || 'master',
                error: error instanceof Error ? error.message : String(error),
                responseTime: Date.now() - startTime
              }, null, 2),
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:379-395 (registration)
    Registration of the 'mssql_health_check' tool in the ListTools response, defining its name, description, and input schema for parameters like server, port, credentials, encryption options, and includeMetrics flag.
    {
      name: 'mssql_health_check',
      description: 'Check database server health and connectivity with performance metrics',
      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' },
          encrypt: { type: 'boolean', description: 'Use encrypted connection (default: true)', default: true },
          trustServerCertificate: { type: 'boolean', description: 'Trust server certificate (default: true)', default: true },
          includeMetrics: { type: 'boolean', description: 'Include performance metrics (default: true)', default: true },
        },
        required: ['server', 'user', 'password'],
      },
    },
  • src/index.ts:449-450 (registration)
    Switch case registration in the CallToolRequest handler that routes calls to the 'mssql_health_check' tool to its handler method.
    case 'mssql_health_check':
      return await this.handleHealthCheck(args);
  • Zod schema used for parsing and validating connection parameters in the health check handler (and other tools).
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'health and connectivity with performance metrics,' which implies a read-only diagnostic operation, but doesn't specify what metrics are included, whether it's safe to run frequently, or if it requires specific permissions. For a tool with 7 parameters and no 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: 'Check database server health and connectivity with performance metrics.' It's front-loaded with the core purpose and avoids any unnecessary words, 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 complexity (7 parameters, no annotations, no output schema), the description is minimally adequate. It states the purpose clearly but lacks details on behavior, usage context, and output format. Without annotations or an output schema, the agent must rely heavily on the input schema and may struggle with how to interpret results, leaving room for improvement.

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%, meaning all parameters are documented in the input schema with clear descriptions. The description adds no additional parameter information beyond implying that metrics might be included via 'includeMetrics.' Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate for any gaps.

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: 'Check database server health and connectivity with performance metrics.' It specifies the verb ('Check'), resource ('database server'), and scope ('health and connectivity with performance metrics'), making it easy to understand. However, it doesn't explicitly differentiate from siblings like mssql_query or mssql_list_databases, which might also involve connectivity checks, so it's not a perfect 5.

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. It doesn't mention prerequisites, such as needing valid credentials, or compare it to siblings like mssql_list_databases for basic connectivity. Without any explicit when/when-not statements or named alternatives, the agent must infer usage from the purpose alone.

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