Skip to main content
Glama

list_tables

Retrieve all tables in a SQL Server database to explore schema structure and identify available data sources for queries and analysis.

Instructions

List all tables in a specific database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (optional, uses current database if not specified)
schemaNoSchema name (optional, defaults to dbo)

Implementation Reference

  • Core handler function that constructs and executes SQL query to list tables in a database/schema
    async listTables(database = null, schema = 'dbo') { let query; if (database) { query = ` SELECT t.TABLE_SCHEMA as schema_name, t.TABLE_NAME as table_name, t.TABLE_TYPE as table_type FROM [${database}].INFORMATION_SCHEMA.TABLES t WHERE t.TABLE_SCHEMA = '${schema}' ORDER BY t.TABLE_SCHEMA, t.TABLE_NAME `; } else { query = ` SELECT t.TABLE_SCHEMA as schema_name, t.TABLE_NAME as table_name, t.TABLE_TYPE as table_type FROM INFORMATION_SCHEMA.TABLES t WHERE t.TABLE_SCHEMA = '${schema}' ORDER BY t.TABLE_SCHEMA, t.TABLE_NAME `; } const result = await this.executeQuery(query, 'list_tables'); return this.formatResults(result); }
  • index.js:261-264 (registration)
    Tool dispatch/registration in the main MCP server switch statement, calling the databaseTools handler
    case 'list_tables': return { content: await this.databaseTools.listTables(args.database, args.schema) };
  • Tool schema definition including input validation schema for list_tables
    name: 'list_tables', description: 'List all tables in a specific database', inputSchema: { type: 'object', properties: { database: { type: 'string', description: 'Database name (optional, uses current database if not specified)' }, schema: { type: 'string', description: 'Schema name (optional, defaults to dbo)' } } }
  • index.js:241-242 (registration)
    Registration of the tool list handler which provides all tools including list_tables via tool-registry.js
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getAllTools()
  • Wrapper handler method on the main server class for testing/compatibility purposes, delegates to databaseTools.listTables
    async listTables(...args) { try { return { content: await this.databaseTools.listTables(...args) }; } catch (error) { throw new McpError(ErrorCode.InternalError, error.message); }

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/egarcia74/warp-sql-server-mcp'

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