Skip to main content
Glama

get_db_schema

Retrieve the complete database schema showing all tables and their structures for analysis and query planning.

Instructions

Get the schema for all tables in the database

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • Core handler logic for the get_db_schema tool: executes SQL query to fetch CREATE TABLE statements for all user tables from sqlite_master.
    export async function dbSchema(client: Client): Promise<string[]> { const result = await client.execute({ sql: "SELECT sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'", args: [], }); return result.rows.map((row) => row.sql as string); }
  • src/index.ts:66-81 (registration)
    Registers the get_db_schema tool with FastMCP server, defining empty input schema (z.object({})), description, and thin execute wrapper that calls dbSchema and formats response.
    server.addTool({ name: "get_db_schema", description: "Get the schema for all tables in the database", parameters: z.object({}), execute: async () => { try { const schema = await dbSchema(db); return content(JSON.stringify({ schema }, null, 2)); } catch (error) { return content( `Error getting schema: ${error instanceof Error ? error.message : String(error)}`, true, ); } }, });
  • Input schema for get_db_schema tool: empty object (no parameters).
    parameters: z.object({}),
  • Helper function to format tool responses as MCP content objects, used in get_db_schema execute.
    export function content( text: string, error = false, ): { content: TextContent[]; isError: boolean } { return { content: [{ type: "text", text }], isError: error, }; }

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