Skip to main content
Glama

list_tables

Retrieve all tables from a SQL Server database to explore database structure and identify available data sources for querying.

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 executes SQL query to list tables in a database/schema using INFORMATION_SCHEMA.TABLES
    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); }
  • Tool schema definition including input schema for parameters database and schema
    { 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:261-264 (registration)
    Tool registration in the main switch case for handling tool calls, delegates to databaseTools.listTables
    case 'list_tables': return { content: await this.databaseTools.listTables(args.database, args.schema) };
  • index.js:241-243 (registration)
    Registration of list tools endpoint which provides the tool list including list_tables via getAllTools() from registry
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getAllTools() }));
  • Delegating wrapper method in main server class that calls the databaseTools handler
    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