get_database_schema
Retrieve Oracle database schema details including table lists and column information for specific tables to understand database structure and relationships.
Instructions
Get database schema information. If tableName is provided, returns column details for that table. Otherwise, returns a list of all accessible tables.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | No | Optional table name to get column information for |
Implementation Reference
- src/tools/getSchema.ts:15-37 (handler)The main handler function that implements the logic for the 'get_database_schema' tool. It validates the input, queries the database schema (delegating to getSchema helper), logs activity, and returns a structured success or error response.export async function getDatabaseSchema(input: GetSchemaInput = {}) { try { const validated = GetSchemaSchema.parse(input); logger.info('Getting database schema via MCP tool', { tableName: validated.tableName || 'all tables', }); const result = await getSchema(validated.tableName); return { success: true, data: result, }; } catch (err: any) { logger.error('Get schema tool failed', { error: err.message }); return { success: false, error: err.message || 'Unknown error occurred', }; } }
- src/tools/getSchema.ts:6-10 (schema)Zod input schema and TypeScript type definition for the 'get_database_schema' tool, defining optional tableName parameter.export const GetSchemaSchema = z.object({ tableName: z.string().optional(), }); export type GetSchemaInput = z.infer<typeof GetSchemaSchema>;
- src/server.ts:61-74 (registration)MCP tool registration entry listing 'get_database_schema' with its description and JSON input schema, used by the server to advertise available tools.{ name: 'get_database_schema', description: 'Get database schema information. If tableName is provided, returns column details for that table. Otherwise, returns a list of all accessible tables.', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: 'Optional table name to get column information for', }, }, }, },