Skip to main content
Glama
cwilby

SQL Server MCP

by cwilby

get-tables

Retrieve a comprehensive list of all tables within a Microsoft SQL Server database using the MCP server, enabling efficient database exploration and management.

Instructions

Get a list of all tables in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implements the core logic for the 'get-tables' tool by querying INFORMATION_SCHEMA.TABLES to retrieve and return a list of base tables in the database.
    async getTables() {
        const tables = await database.query(`
            SELECT TABLE_NAME, TABLE_TYPE
            FROM INFORMATION_SCHEMA.TABLES
            WHERE TABLE_TYPE = 'BASE TABLE'
        `);
    
        if (!tables.length) return this.toResult("No tables found in the database.");
    
        return this.toResult(`Tables found in the database:\n${JSON.stringify(tables)}`);
    }
  • Registers the 'get-tables' tool with the MCP server, providing its name, description, and binding it to the getTables handler method.
    server.tool(
        "get-tables",
        "Get a list of all tables in the database",
        tools.getTables.bind(tools)
    );
Install Server

Other Tools

Related 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/cwilby/mcp-node-mssql'

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