Skip to main content
Glama
kuzudb

Kuzu MCP server

Official
by kuzudb

getSchema

Retrieve the database schema of Kuzu, enabling natural language interactions and efficient management of graph data structures within the Kuzu MCP server environment.

Instructions

Get the schema of the Kuzu database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'getSchema' tool. It queries the Kuzu database using `show_tables()`, `TABLE_INFO()`, and `SHOW_CONNECTION()` to extract node tables (with properties including primary keys) and relationship tables (with properties and connectivity to source/destination tables), sorts them, and returns the schema object.
    const getSchema = async (connection) => { const result = await connection.query("CALL show_tables() RETURN *;"); const tables = await result.getAll(); result.close(); const nodeTables = []; const relTables = []; for (const table of tables) { const properties = ( await connection .query(`CALL TABLE_INFO('${table.name}') RETURN *;`) .then((res) => res.getAll()) ).map((property) => ({ name: property.name, type: property.type, isPrimaryKey: property["primary key"], })); if (table.type === TABLE_TYPES.NODE) { delete table["type"]; delete table["database name"]; table.properties = properties; nodeTables.push(table); } else if (table.type === TABLE_TYPES.REL) { delete table["type"]; delete table["database name"]; properties.forEach((property) => { delete property.isPrimaryKey; }); table.properties = properties; const connectivity = await connection .query(`CALL SHOW_CONNECTION('${table.name}') RETURN *;`) .then((res) => res.getAll()); table.connectivity = []; connectivity.forEach(c => { table.connectivity.push({ src: c["source table name"], dst: c["destination table name"], }); }); relTables.push(table); } } nodeTables.sort((a, b) => a.name.localeCompare(b.name)); relTables.sort((a, b) => a.name.localeCompare(b.name)); return { nodeTables, relTables }; };
  • index.js:163-170 (registration)
    Registration of the 'getSchema' tool in the ListToolsRequestSchema handler, specifying name, description, and input schema.
    { name: "getSchema", description: "Get the schema of the Kuzu database", inputSchema: { type: "object", properties: {}, }, }
  • The input schema definition for the 'getSchema' tool: an empty object with no required properties.
    inputSchema: { type: "object", properties: {}, },
  • Invocation of the getSchema handler within the general CallToolRequestSchema handler, serializing the schema to JSON text response.
    } else if (request.params.name === "getSchema") { const schema = await getSchema(conn); return { content: [{ type: "text", text: JSON.stringify(schema, null, 2) }], isError: false, }; }

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/kuzudb/kuzu-mcp-server'

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