Skip to main content
Glama
sam2332

SQLite MCP Server

by sam2332

describe_table

Retrieve the schema and structure of a specific table in an SQLite database for analyzing or verifying its layout using the MCP server.

Instructions

Get the schema/structure of a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesName of the table to describe

Implementation Reference

  • The handler function that implements the describe_table tool. It uses PRAGMA table_info to fetch column information and formats it into a schema string.
    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)}`); } }
  • The input schema for the describe_table tool, requiring a 'table_name' string parameter.
    inputSchema: { type: "object", properties: { table_name: { type: "string", description: "Name of the table to describe", }, }, required: ["table_name"], },
  • src/index.ts:86-99 (registration)
    Registration of 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"], }, },
  • src/index.ts:168-169 (registration)
    The switch case in the CallToolRequestHandler that routes calls to the describeTable handler.
    case "describe_table": return await this.describeTable(args as { table_name: string });

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