Skip to main content
Glama
michaelyuwh

Enhanced MCP MSSQL Server

by michaelyuwh

mssql_list_databases

Retrieve a list of all accessible databases on a Microsoft SQL Server to identify available data sources and manage connections.

Instructions

List all databases the user has access to

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)

Implementation Reference

  • The main handler function that connects to the MSSQL server using the provided connection config, executes a query against sys.databases to list accessible databases, and returns the results as JSON.
    private async handleListDatabases(args: any) {
      const config = ConnectionSchema.parse(args);
      const pool = await this.getConnection(config);
      
      const request = pool.request();
      const result = await request.query(`
        SELECT name as database_name
        FROM sys.databases
        WHERE state = 0  -- Only online databases
        ORDER BY name
      `);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              server: config.server,
              databases: result.recordset,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:272-287 (registration)
    Registration of the mssql_list_databases tool in the ListTools response, including name, description, and input schema definition.
    {
      name: 'mssql_list_databases',
      description: 'List all databases the user has access to',
      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 },
        },
        required: ['server', 'user', 'password'],
      },
    },
  • Zod schema for parsing connection configuration, used in the handler to validate tool inputs.
    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'),
    });
  • src/index.ts:437-438 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes calls to the mssql_list_databases handler function.
    case 'mssql_list_databases':
      return await this.handleListDatabases(args);
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. While it indicates this is a read operation ('List'), it doesn't describe what the output looks like (e.g., format, structure, or pagination), authentication requirements beyond the parameters, or any rate limits or constraints. This leaves significant gaps for a tool with connection parameters.

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 front-loaded and wastes no space, making it easy for an agent to parse quickly.

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 a database listing tool with connection parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the return format, error handling, or how 'access' is determined, leaving the agent with incomplete information to use the tool effectively.

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?

The description adds no parameter-specific information beyond what's already in the schema, which has 100% coverage with detailed descriptions for all 6 parameters. The baseline score of 3 reflects adequate schema documentation, but the description doesn't compensate with additional context like parameter interactions or usage examples.

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 ('List all databases') and the resource ('databases the user has access to'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'mssql_list_tables', which also lists resources but at a different level (tables vs databases).

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 like 'mssql_list_tables' or 'mssql_query'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to infer usage from the tool name 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