Skip to main content
Glama
sam2332

SQLite MCP Server

by sam2332

describe_table

Retrieve the schema and structure of a specific SQLite database table to understand its columns, data types, and constraints.

Instructions

Get the schema/structure of a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesName of the table to describe

Implementation Reference

  • Executes the describe_table tool: checks database connection, runs PRAGMA table_info(?), formats columns with types, nullability, PK, defaults, and returns formatted schema text.
    private async describeTable(args: { table_name: string }): Promise<CallToolResult> { if (!this.db) { throw new Error("No database connected. Use connect_database first."); } try { const columns = this.db .prepare("PRAGMA table_info(?)") .all(args.table_name) as { cid: number; name: string; type: string; notnull: number; dflt_value: any; pk: number; }[]; if (columns.length === 0) { throw new Error(`Table '${args.table_name}' not found`); } const schema = columns .map(col => { const nullable = col.notnull === 0 ? "NULL" : "NOT NULL"; const pk = col.pk > 0 ? " PRIMARY KEY" : ""; const defaultVal = col.dflt_value !== null ? ` DEFAULT ${col.dflt_value}` : ""; return ` ${col.name} ${col.type} ${nullable}${pk}${defaultVal}`; }) .join("\n"); return { content: [ { type: "text", text: `Table: ${args.table_name}\n\nSchema:\n${schema}`, } satisfies TextContent, ], }; } catch (error) { throw new Error(`Failed to describe table: ${error instanceof Error ? error.message : String(error)}`); } }
  • src/index.ts:86-99 (registration)
    Registers the describe_table tool in the ListTools response, including name, description, and input schema.
    { name: "describe_table", description: "Get the schema/structure of a specific table", inputSchema: { type: "object", properties: { table_name: { type: "string", description: "Name of the table to describe", }, }, required: ["table_name"], }, },
  • Defines the input schema for describe_table: object with required 'table_name' string property.
    inputSchema: { type: "object", properties: { table_name: { type: "string", description: "Name of the table to describe", }, }, required: ["table_name"], },
  • Dispatches call_tool requests for describe_table to the describeTable method.
    case "describe_table": return await this.describeTable(args as { table_name: string });

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