Skip to main content
Glama

describe_table

Retrieve schema details for a specified table in a Turso database, including column names, data types, and constraints.

Instructions

View schema information for a specific table

Input Schema

NameRequiredDescriptionDefault
table_nameYes

Input Schema (JSON Schema)

{ "properties": { "table_name": { "minLength": 1, "type": "string" } }, "required": [ "table_name" ], "type": "object" }

Implementation Reference

  • Core handler function that implements the logic for describing a table: validates table name, executes PRAGMA table_info query, handles errors, and maps rows to TableColumn objects.
    export async function describeTable( tableName: string, client: Client, ): Promise<TableColumn[]> { if (!/^[a-zA-Z0-9_]+$/.test(tableName)) { throw new Error( "Invalid table name. Only alphanumeric characters and underscores are allowed.", ); } const result = await client.execute({ sql: `PRAGMA table_info(${tableName})`, args: [], }); if (result.rows.length === 0) { throw new Error(`Table '${tableName}' not found`); } return result.rows.map((row) => ({ name: row.name as string, type: row.type as string, notnull: row.notnull as number, dflt_value: row.dflt_value as string | null, pk: row.pk as number, })); }
  • Input schema for the describe_table tool using Zod, defining the required 'table_name' parameter.
    parameters: z.object({ table_name: z .string() .describe("Name of the table to describe") .min(1, "Table name is required"), }),
  • Zod schema and TypeScript type definition for TableColumn, used as the return type structure for describeTable.
    export const TableColumnSchema = z.object({ name: z.string(), type: z.string(), notnull: z.number(), dflt_value: z.union([z.string(), z.null()]), pk: z.number(), }); export type TableColumn = z.infer<typeof TableColumnSchema>;
  • src/index.ts:83-105 (registration)
    Registration of the 'describe_table' MCP tool with FastMCP server, including name, description, input schema, and thin wrapper execute handler that delegates to describeTable utility.
    server.addTool({ name: "describe_table", description: "View schema information for a specific table", parameters: z.object({ table_name: z .string() .describe("Name of the table to describe") .min(1, "Table name is required"), }), execute: async ({ table_name }) => { try { logger.info(`Executing describe_table for table: ${table_name}`); const schema = await describeTable(table_name, db); return content(JSON.stringify({ schema }, null, 2)); } catch (error) { logger.error(`Failed to describe table ${table_name}`, error); return content( `Error describing table: ${error instanceof Error ? error.message : String(error)}`, true, ); } }, });

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/nbbaier/mcp-turso'

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