get_table_schema
Retrieve property names and types from a specified table in Azure Table Storage to analyze its structure.
Instructions
Get property names and types from a table
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | Name of the table to analyze |
Implementation Reference
- src/index.ts:236-269 (handler)The handler function for the get_table_schema tool. It creates a TableClient for the given table, iterates over all entities, collects unique property names and their types (using typeof), builds a schema map, and returns it as JSON text content.private async handleGetTableSchema(args: GetSchemaArgs) { const tableClient = TableClient.fromConnectionString( this.connectionString, args.tableName ); const propertyMap = new Map<string, Set<string>>(); const iterator = tableClient.listEntities(); for await (const entity of iterator) { Object.entries(entity).forEach(([key, value]) => { if (!propertyMap.has(key)) { propertyMap.set(key, new Set()); } propertyMap.get(key)?.add(typeof value); }); } const schema = Object.fromEntries( Array.from(propertyMap.entries()).map(([key, types]) => [ key, Array.from(types), ]) ); return { content: [ { type: 'text', text: JSON.stringify(schema, null, 2), }, ], }; }
- src/index.ts:115-128 (registration)Registration of the get_table_schema tool in the ListTools response, including name, description, and JSON inputSchema.{ name: 'get_table_schema', description: 'Get property names and types from a table', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: 'Name of the table to analyze', }, }, required: ['tableName'], }, },
- src/index.ts:159-166 (registration)Dispatch case in the CallToolRequestHandler that validates the tableName argument and invokes the handleGetTableSchema method.case 'get_table_schema': const schemaArgs = request.params.arguments as Record<string, unknown>; if (typeof schemaArgs?.tableName !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'tableName is required and must be a string'); } return await this.handleGetTableSchema({ tableName: schemaArgs.tableName });
- src/index.ts:22-24 (schema)TypeScript interface defining the input arguments for the get_table_schema handler.interface GetSchemaArgs { tableName: string; }