Skip to main content
Glama
sam2332

SQLite MCP Server

by sam2332

list_tables

Retrieve a list of all tables in an SQLite database to identify and manage data structures efficiently.

Instructions

List all tables in the connected database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'list_tables' tool. It checks if a database is connected, queries the sqlite_master table to list all user tables (excluding internal ones), formats the list, and returns it as a CallToolResult.
    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)
    Tool registration definition returned by ListToolsRequestHandler, specifying the tool name, description, and input schema (empty properties, no arguments required).
    { name: "list_tables", description: "List all tables in the connected database", inputSchema: { type: "object", properties: {}, }, },
  • Dispatcher switch case in CallToolRequestHandler that invokes the listTables handler when the 'list_tables' tool is called.
    case "list_tables": return await this.listTables();

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

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