get-entity-metadata
Retrieve metadata for PowerPlatform entities to understand structure, fields, and relationships for integration and development.
Instructions
Get metadata about a PowerPlatform entity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityName | Yes | The logical name of the entity |
Implementation Reference
- src/index.ts:356-385 (handler)The MCP tool handler function for 'get-entity-metadata'. It initializes the PowerPlatformService if needed, calls getEntityMetadata on it, stringifies the result as JSON, and returns it in the required MCP content format. Handles errors gracefully.async ({ entityName }) => { try { // Get or initialize PowerPlatformService const service = getPowerPlatformService(); const metadata = await service.getEntityMetadata(entityName); // Format the metadata as a string for text display const metadataStr = JSON.stringify(metadata, null, 2); return { content: [ { type: "text", text: `Entity metadata for '${entityName}':\n\n${metadataStr}`, }, ], }; } catch (error: any) { console.error("Error getting entity metadata:", error); return { content: [ { type: "text", text: `Failed to get entity metadata: ${error.message}`, }, ], }; } } );
- src/index.ts:353-355 (schema)Zod schema for input validation of the tool, requiring 'entityName' as a string with description.{ entityName: z.string().describe("The logical name of the entity"), },
- src/index.ts:350-352 (registration)Registration of the 'get-entity-metadata' tool on the MCP server with name and description.server.tool( "get-entity-metadata", "Get metadata about a PowerPlatform entity",
- src/PowerPlatformService.ts:100-109 (helper)Core helper method in PowerPlatformService that performs the authenticated API request to Dataverse Web API to fetch entity metadata by logical name, removes Privileges property, and returns the data.async getEntityMetadata(entityName: string): Promise<any> { const response = await this.makeRequest(`api/data/v9.2/EntityDefinitions(LogicalName='${entityName}')`); // Remove Privileges property if it exists if (response && typeof response === 'object' && 'Privileges' in response) { delete response.Privileges; } return response; }