get-record
Retrieve a specific PowerPlatform/Dataverse record by providing the entity name and record ID for data access and management.
Instructions
Get a specific record by entity name (plural) and ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityNamePlural | Yes | The plural name of the entity (e.g., 'accounts', 'contacts') | |
| recordId | Yes | The GUID of the record |
Implementation Reference
- src/index.ts:541-577 (registration)MCP server.tool registration for 'get-record' tool, including input schema, description, and the handler function that initializes the service and calls getRecord on it, formatting the response.server.tool( "get-record", "Get a specific record by entity name (plural) and ID", { entityNamePlural: z.string().describe("The plural name of the entity (e.g., 'accounts', 'contacts')"), recordId: z.string().describe("The GUID of the record"), }, async ({ entityNamePlural, recordId }) => { try { // Get or initialize PowerPlatformService const service = getPowerPlatformService(); const record = await service.getRecord(entityNamePlural, recordId); // Format the record as a string for text display const recordStr = JSON.stringify(record, null, 2); return { content: [ { type: "text", text: `Record from '${entityNamePlural}' with ID '${recordId}':\n\n${recordStr}`, }, ], }; } catch (error: any) { console.error("Error getting record:", error); return { content: [ { type: "text", text: `Failed to get record: ${error.message}`, }, ], }; } } );
- src/index.ts:544-547 (schema)Zod input schema for the 'get-record' tool: entityNamePlural (string) and recordId (string).{ entityNamePlural: z.string().describe("The plural name of the entity (e.g., 'accounts', 'contacts')"), recordId: z.string().describe("The GUID of the record"), },
- src/index.ts:548-576 (handler)Inline handler function for 'get-record' tool that calls PowerPlatformService.getRecord and returns formatted text response.async ({ entityNamePlural, recordId }) => { try { // Get or initialize PowerPlatformService const service = getPowerPlatformService(); const record = await service.getRecord(entityNamePlural, recordId); // Format the record as a string for text display const recordStr = JSON.stringify(record, null, 2); return { content: [ { type: "text", text: `Record from '${entityNamePlural}' with ID '${recordId}':\n\n${recordStr}`, }, ], }; } catch (error: any) { console.error("Error getting record:", error); return { content: [ { type: "text", text: `Failed to get record: ${error.message}`, }, ], }; } }
- src/PowerPlatformService.ts:249-251 (helper)Core helper method in PowerPlatformService that makes the authenticated API request to retrieve the specific record by plural entity name and ID.async getRecord(entityNamePlural: string, recordId: string): Promise<any> { return this.makeRequest(`api/data/v9.2/${entityNamePlural}(${recordId})`); }
- src/PowerPlatformService.ts:74-94 (helper)Private makeRequest helper method that handles authentication and makes the HTTP GET request to the Power Platform API.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}`); } }