Skip to main content
Glama
sam2332

SQLite MCP Server

by sam2332

list_tables

Retrieve all table names from a connected SQLite database to understand its structure and available data sources.

Instructions

List all tables in the connected database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the list_tables tool. It checks for a connected database, queries sqlite_master for user-created tables, formats them into a comma-separated list, and returns the result as a text content response.
    private async listTables(): Promise<CallToolResult> { if (!this.db) { throw new Error("No database connected. Use connect_database first."); } try { const tables = this.db .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name") .all() as { name: string }[]; const tableList = tables.map(t => t.name).join(", "); return { content: [ { type: "text", text: `Tables in database (${tables.length}): ${tableList || "No tables found"}`, } satisfies TextContent, ], }; } catch (error) { throw new Error(`Failed to list tables: ${error instanceof Error ? error.message : String(error)}`); } }
  • src/index.ts:78-85 (registration)
    Registration of the list_tables tool in the ListToolsRequestHandler. Includes the tool name, description, and input schema (empty object since no parameters required).
    { name: "list_tables", description: "List all tables in the connected database", inputSchema: { type: "object", properties: {}, }, },
  • Input schema definition for the list_tables tool, which is an empty object indicating no input parameters are required.
    inputSchema: { type: "object", properties: {}, },
  • src/index.ts:165-166 (registration)
    Switch case in the CallToolRequestHandler that dispatches calls to the list_tables tool by invoking the listTables() handler method.
    case "list_tables": return await this.listTables();

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/sam2332/mcp-quick-sqlite3'

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