get-entity-attribute
Retrieve specific attribute/field values from PowerPlatform entities using entity and attribute logical names for precise data access.
Instructions
Get a specific attribute/field of a PowerPlatform entity
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| attributeName | Yes | The logical name of the attribute | |
| entityName | Yes | The logical name of the entity |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"attributeName": {
"description": "The logical name of the attribute",
"type": "string"
},
"entityName": {
"description": "The logical name of the entity",
"type": "string"
}
},
"required": [
"entityName",
"attributeName"
],
"type": "object"
}
Implementation Reference
- src/index.ts:426-462 (registration)Registration of the 'get-entity-attribute' tool, including input schema (entityName, attributeName) and handler function that fetches via PowerPlatformService and returns formatted text response.server.tool( "get-entity-attribute", "Get a specific attribute/field of a PowerPlatform entity", { entityName: z.string().describe("The logical name of the entity"), attributeName: z.string().describe("The logical name of the attribute") }, async ({ entityName, attributeName }) => { try { // Get or initialize PowerPlatformService const service = getPowerPlatformService(); const attribute = await service.getEntityAttribute(entityName, attributeName); // Format the attribute as a string for text display const attributeStr = JSON.stringify(attribute, null, 2); return { content: [ { type: "text", text: `Attribute '${attributeName}' for entity '${entityName}':\n\n${attributeStr}`, }, ], }; } catch (error: any) { console.error("Error getting entity attribute:", error); return { content: [ { type: "text", text: `Failed to get entity attribute: ${error.message}`, }, ], }; } } );
- src/PowerPlatformService.ts:165-167 (handler)Core implementation of getEntityAttribute in PowerPlatformService: makes authenticated GET request to Dataverse Web API endpoint for specific entity attribute metadata.async getEntityAttribute(entityName: string, attributeName: string): Promise<any> { return this.makeRequest(`api/data/v9.2/EntityDefinitions(LogicalName='${entityName}')/Attributes(LogicalName='${attributeName}')`); }
- src/PowerPlatformService.ts:74-94 (helper)Helper method makeRequest used by getEntityAttribute to perform authenticated API calls with token acquisition and axios GET.private async makeRequest<T>(endpoint: string): Promise<T> { try { const token = await this.getAccessToken(); const response = await axios({ method: 'GET', url: `${this.config.organizationUrl}/${endpoint}`, headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json', 'OData-MaxVersion': '4.0', 'OData-Version': '4.0' } }); return response.data as T; } catch (error) { console.error('PowerPlatform API request failed:', error); throw new Error(`PowerPlatform API request failed: ${error}`); } }