Description
The Get SQL Schema tool retrieves the SQL schema of the database in a filtered format. It reads the schema from a JSON file, excludes certain tables and properties, and returns a cleaned schema. This enables agents to understand the structure of the database without exposing sensitive or unnecessary fields.
File Location: prisma/json-schema/json-schema.json
The JSON schema file contains the database structure as exported by Prisma.
Arguments
- No arguments: This tool does not require any arguments.
Example Configuration
export const getSQLSchema = {
type: "function" as const,
function: {
name: "get_sql_schema",
description: "Get the SQL schema of the database",
},
};
Processing and Exclusions
- Schema Reading: The function reads the schema from the JSON file located at
prisma/json-schema/json-schema.json.
- Excluded Properties: Properties such as
id, createdAt, updatedAt, and others are removed from the schema to prevent unnecessary exposure.
- Excluded Tables: Certain tables, like
_prisma_migrations, Invitation, and Session, are excluded entirely from the returned schema.
- Schema Cleaning: The function iterates over the schema, removing specified properties and tables before returning the final, filtered schema.
Response Handling
- Successful Response: If the schema is successfully read and filtered, the function returns an object containing:
schema: The cleaned schema with excluded properties and tables removed.
- Error Handling: If the schema file cannot be read or parsed, an error is logged, and an error message is returned.
Example Response
{
"schema": {
"User": {
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" },
"address": { "type": "string" }
// Additional properties, excluding specified fields
}
},
"Product": {
"properties": {
"name": { "type": "string" },
"price": { "type": "number" }
// Additional properties, excluding specified fields
}
}
// Additional tables, excluding specified tables
}
}