Skip to main content
Glama
michaelyuwh

Enhanced MCP MSSQL Server

by michaelyuwh

mssql_list_tables

Retrieve all table names from a Microsoft SQL Server database to discover database structure and available data sources.

Instructions

List all tables in a database

Input Schema

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

Implementation Reference

  • The handler function for mssql_list_tables tool. Parses connection args, connects to the database, executes a query to list tables from INFORMATION_SCHEMA.TABLES, and returns the result as JSON.
    private async handleListTables(args: any) { const config = ConnectionSchema.parse(args); const pool = await this.getConnection(config); const request = pool.request(); const result = await request.query(` USE [${config.database}]; SELECT TABLE_SCHEMA as schema_name, TABLE_NAME as table_name, TABLE_TYPE as table_type FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_SCHEMA, TABLE_NAME `); return { content: [ { type: 'text', text: JSON.stringify({ server: config.server, database: config.database, tables: result.recordset, }, null, 2), }, ], }; }
  • Input schema definition for the mssql_list_tables tool, specifying connection parameters and database name as required.
    { name: 'mssql_list_tables', description: 'List all tables in a database', 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' }, 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'], },
  • src/index.ts:439-440 (registration)
    Registration of the mssql_list_tables handler in the tool call switch statement.
    case 'mssql_list_tables': return await this.handleListTables(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