Skip to main content
Glama
seek-your-way-out

Cloudflare D1 Database MCP Server

d1_list_tables

Retrieve a list of all tables in your Cloudflare D1 database to understand database structure and plan SQL operations.

Instructions

List tables available in the Cloudflare D1 database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for the 'd1_list_tables' tool in the CallToolRequestSchema. It calls client.listTables() and formats the result as JSON text response.
    } else if (name === "d1_list_tables") { const tables = await client.listTables(); return { content: [ { type: "text", text: JSON.stringify(tables, null, 2) } ] };
  • src/server.ts:50-58 (registration)
    Tool registration in the ListToolsRequestSchema handler, including name, description, and empty input schema.
    { name: "d1_list_tables", description: "List tables available in the Cloudflare D1 database.", inputSchema: { type: "object", properties: {}, additionalProperties: false } }
  • Implementation of listTables() method in D1Client, which queries sqlite_master for table names using a SQL statement and processes the result.
    async listTables(): Promise<string[]> { const sql = `SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;`; const result = await this.executeQuery(sql); if (!result.success) { const error = result.errors?.[0]?.message ?? "Unknown D1 error"; throw new Error(`Failed to list tables: ${error}`); } const rows = Array.isArray(result.result) ? result.result : []; const firstResult = Array.isArray(rows[0]) ? rows[0] : rows; if (!Array.isArray(firstResult)) { return []; } // D1 returns rows as array of objects { name: string } return firstResult .filter((item): item is { name: string } => typeof item === "object" && item !== null && "name" in item) .map((row) => row.name); }

Other 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/seek-your-way-out/cloudflare-sywo-mcp-server'

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