get_autonumber_column
Retrieve detailed information about an AutoNumber column configuration including current format, properties, and settings in Microsoft Dataverse tables.
Instructions
Retrieves detailed information about an AutoNumber column including its current format, properties, and configuration.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| columnLogicalName | Yes | Logical name of the AutoNumber column to retrieve | |
| entityLogicalName | Yes | Logical name of the table |
Implementation Reference
- src/tools/autonumber-tools.ts:306-364 (handler)The main handler function that executes the tool logic: fetches column metadata via Dataverse API, validates it's an AutoNumber column, extracts properties like format, maxLength, etc., and returns structured information or error response.async (params) => { try { const column = await client.getMetadata( `EntityDefinitions(LogicalName='${params.entityLogicalName}')/Attributes(LogicalName='${params.columnLogicalName}')` ); // Check if it's an AutoNumber column if (column.AttributeType !== 'String' || !column.AutoNumberFormat) { return { content: [ { type: "text", text: `The specified column '${params.columnLogicalName}' is not an AutoNumber column.\n\nAttribute Type: ${column.AttributeType}\nHas AutoNumber Format: ${!!column.AutoNumberFormat}` } ], isError: true }; } const columnInfo = { logicalName: column.LogicalName, schemaName: column.SchemaName, displayName: column.DisplayName?.UserLocalizedLabel?.Label || column.DisplayName?.LocalizedLabels?.[0]?.Label, description: column.Description?.UserLocalizedLabel?.Label || column.Description?.LocalizedLabels?.[0]?.Label, autoNumberFormat: column.AutoNumberFormat, attributeType: column.AttributeType, format: column.Format, maxLength: column.MaxLength, requiredLevel: column.RequiredLevel?.Value, isAuditEnabled: column.IsAuditEnabled?.Value, isValidForAdvancedFind: column.IsValidForAdvancedFind?.Value, isValidForCreate: column.IsValidForCreate?.Value, isValidForUpdate: column.IsValidForUpdate?.Value, isCustomAttribute: column.IsCustomAttribute?.Value, isManaged: column.IsManaged?.Value, metadataId: column.MetadataId }; return { content: [ { type: "text", text: `AutoNumber column information for '${params.columnLogicalName}' in table '${params.entityLogicalName}':\n\n${JSON.stringify(columnInfo, null, 2)}` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error retrieving AutoNumber column: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- Input schema definition for the tool, specifying required parameters: entityLogicalName and columnLogicalName using Zod validation.{ title: 'Get AutoNumber Column', description: 'Retrieves detailed information about an AutoNumber column including its current format, properties, and configuration.', inputSchema: { entityLogicalName: z.string().describe('Logical name of the table'), columnLogicalName: z.string().describe('Logical name of the AutoNumber column to retrieve') } },
- src/tools/autonumber-tools.ts:295-366 (registration)Registration function that calls server.registerTool to add the 'get_autonumber_column' tool with its schema and handler.export function getAutoNumberColumnTool(server: McpServer, client: DataverseClient) { server.registerTool( 'get_autonumber_column', { title: 'Get AutoNumber Column', description: 'Retrieves detailed information about an AutoNumber column including its current format, properties, and configuration.', inputSchema: { entityLogicalName: z.string().describe('Logical name of the table'), columnLogicalName: z.string().describe('Logical name of the AutoNumber column to retrieve') } }, async (params) => { try { const column = await client.getMetadata( `EntityDefinitions(LogicalName='${params.entityLogicalName}')/Attributes(LogicalName='${params.columnLogicalName}')` ); // Check if it's an AutoNumber column if (column.AttributeType !== 'String' || !column.AutoNumberFormat) { return { content: [ { type: "text", text: `The specified column '${params.columnLogicalName}' is not an AutoNumber column.\n\nAttribute Type: ${column.AttributeType}\nHas AutoNumber Format: ${!!column.AutoNumberFormat}` } ], isError: true }; } const columnInfo = { logicalName: column.LogicalName, schemaName: column.SchemaName, displayName: column.DisplayName?.UserLocalizedLabel?.Label || column.DisplayName?.LocalizedLabels?.[0]?.Label, description: column.Description?.UserLocalizedLabel?.Label || column.Description?.LocalizedLabels?.[0]?.Label, autoNumberFormat: column.AutoNumberFormat, attributeType: column.AttributeType, format: column.Format, maxLength: column.MaxLength, requiredLevel: column.RequiredLevel?.Value, isAuditEnabled: column.IsAuditEnabled?.Value, isValidForAdvancedFind: column.IsValidForAdvancedFind?.Value, isValidForCreate: column.IsValidForCreate?.Value, isValidForUpdate: column.IsValidForUpdate?.Value, isCustomAttribute: column.IsCustomAttribute?.Value, isManaged: column.IsManaged?.Value, metadataId: column.MetadataId }; return { content: [ { type: "text", text: `AutoNumber column information for '${params.columnLogicalName}' in table '${params.entityLogicalName}':\n\n${JSON.stringify(columnInfo, null, 2)}` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error retrieving AutoNumber column: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
- src/index.ts:243-243 (registration)Top-level call to register the getAutoNumberColumnTool during MCP server initialization.getAutoNumberColumnTool(server, dataverseClient);