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

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