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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:101-145 (handler)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: {}, }, }
- index.js:166-169 (schema)The input schema definition for the 'getSchema' tool: an empty object with no required properties.inputSchema: { type: "object", properties: {}, },
- index.js:191-197 (handler)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, }; }