describe_table
Retrieve the structure of a specified table in MySQL or MongoDB databases using the MCP-MongoDB-MySQL-Server interface, enabling schema analysis and management.
Instructions
Get table structure
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name |
Input Schema (JSON Schema)
{
"properties": {
"table": {
"description": "Table name",
"type": "string"
}
},
"required": [
"table"
],
"type": "object"
}
Implementation Reference
- src/index.ts:776-799 (handler)The handler function that ensures DB connection, validates table arg, executes DESCRIBE query, and returns table structure as JSON.private async handleDescribeTable(args: any) { await this.ensureConnection(); if (!args.table) { throw new McpError(ErrorCode.InvalidParams, 'Table name is required'); } try { const [rows] = await this.connection!.query('DESCRIBE ??', [args.table]); return { content: [ { type: 'text', text: JSON.stringify(rows, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to describe table: ${getErrorMessage(error)}` ); } }
- src/index.ts:313-321 (schema)Input schema defining the required 'table' parameter as a string.inputSchema: { type: 'object', properties: { table: { type: 'string', description: 'Table name', }, }, required: ['table'],
- src/index.ts:310-322 (registration)Tool registration in the list of tools provided by ListToolsRequestHandler, including name, description, and schema.{ name: 'describe_table', description: 'Get table structure', inputSchema: { type: 'object', properties: { table: { type: 'string', description: 'Table name', }, }, required: ['table'], },
- src/index.ts:545-546 (helper)Dispatcher switch case that routes CallToolRequest for 'describe_table' to the handler function.case 'describe_table': return await this.handleDescribeTable(request.params.arguments);