Skip to main content
Glama

list_table

Lists tables in an MSSQL database, optionally filtering by specific schemas, to streamline database exploration and management tasks.

Instructions

Lists tables in an MSSQL Database, or list tables in specific schemas

Input Schema

NameRequiredDescriptionDefault
parametersNoSchemas to filter by (optional)

Input Schema (JSON Schema)

{ "properties": { "parameters": { "description": "Schemas to filter by (optional)", "items": { "type": "string" }, "minItems": 0, "type": "array" } }, "required": [], "type": "object" }

Implementation Reference

  • Executes a SQL query against INFORMATION_SCHEMA.TABLES to list all base tables, optionally filtered by specific schemas provided in the parameters array.
    async run(params: any) { try { const { parameters } = params; const request = new sql.Request(); const schemaFilter = parameters && parameters.length > 0 ? `AND TABLE_SCHEMA IN (${parameters.map((p: string) => `'${p}'`).join(", ")})` : ""; const query = `SELECT TABLE_SCHEMA + '.' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ${schemaFilter} ORDER BY TABLE_SCHEMA, TABLE_NAME`; const result = await request.query(query); return { success: true, message: `List tables executed successfully`, items: result.recordset, }; } catch (error) { console.error("Error listing tables:", error); return { success: false, message: `Failed to list tables: ${error}`, }; } }
  • Input schema defining an optional array of schema names to filter the listed tables.
    inputSchema = { type: "object", properties: { parameters: { type: "array", description: "Schemas to filter by (optional)", items: { type: "string" }, minItems: 0 }, }, required: [], } as any;
  • src/index.ts:88-88 (registration)
    Instantiates the ListTableTool instance used throughout the server.
    const listTableTool = new ListTableTool();
  • src/index.ts:109-113 (registration)
    Registers the listTableTool in the list of available tools for ListToolsRequest, conditionally based on read-only mode.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: isReadOnly ? [listTableTool, readDataTool, describeTableTool] // todo: add searchDataTool to the list of tools available in readonly mode once implemented : [insertDataTool, readDataTool, describeTableTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool], // add all new tools here }));
  • src/index.ts:135-137 (registration)
    Dispatches calls to the list_table tool by matching the tool name and invoking its run method in the CallToolRequest handler.
    case listTableTool.name: result = await listTableTool.run(args); break;

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/EvilPhatBoi/McpSqlServer'

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