list_tables
Lists all user-created tables in the connected SQLite database.
Instructions
List all user-created tables in the database.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:310-317 (handler)Handler for the 'list_tables' tool. Executes a SQL query against sqlite_master to retrieve all user-created table names (excluding sqlite_% system tables) and returns them as a JSON array of names.
case 'list_tables': { const rows = db.all( "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name" ) as { name: string }[]; return { content: [{ type: 'text', text: JSON.stringify(rows.map(r => r.name), null, 2) }], }; } - src/index.ts:244-249 (schema)Schema definition for the 'list_tables' tool. Defines the tool name, description, and input schema (empty object, no parameters required). Registered as part of the ListTools handler.
name: 'list_tables', description: 'List all user-created tables in the database.', inputSchema: { type: 'object' as const, properties: {}, }, - src/index.ts:197-274 (registration)Registration of the 'list_tables' tool via the ListToolsRequestSchema handler. The tool is listed along with read_query, write_query, create_table, drop_table, describe_table, and append_insight.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'read_query', description: 'Execute a read-only SQL query (SELECT, WITH/CTE, or EXPLAIN). Use this for fetching data.', inputSchema: { type: 'object' as const, properties: { query: { type: 'string', description: 'The SELECT SQL query to execute' }, }, required: ['query'], }, }, { name: 'write_query', description: 'Execute a data modification query (INSERT, UPDATE, DELETE, REPLACE). Returns affected row count.', inputSchema: { type: 'object' as const, properties: { query: { type: 'string', description: 'The SQL modification query to execute' }, }, required: ['query'], }, }, { name: 'create_table', description: 'Create a new table in the database with a full CREATE TABLE SQL statement.', inputSchema: { type: 'object' as const, properties: { query: { type: 'string', description: 'CREATE TABLE SQL statement' }, }, required: ['query'], }, }, { name: 'drop_table', description: 'Drop (delete) a table from the database. This action is irreversible.', inputSchema: { type: 'object' as const, properties: { table_name: { type: 'string', description: 'Name of the table to drop' }, }, required: ['table_name'], }, }, { name: 'list_tables', description: 'List all user-created tables in the database.', inputSchema: { type: 'object' as const, properties: {}, }, }, { name: 'describe_table', description: 'Get the schema of a table: columns, types, constraints, indexes, and foreign keys.', inputSchema: { type: 'object' as const, properties: { table_name: { type: 'string', description: 'Name of the table to describe' }, }, required: ['table_name'], }, }, { name: 'append_insight', description: 'Add a business insight to the insights memo resource. Useful for recording observations from analysis.', inputSchema: { type: 'object' as const, properties: { insight: { type: 'string', description: 'The business insight to record' }, }, required: ['insight'], }, }, ], }));