get-record
Retrieve a specific record from PowerPlatform/Dataverse by providing the entity name (plural) and record ID. Simplify data access and management in PowerPlatform MCP.
Instructions
Get a specific record by entity name (plural) and ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityNamePlural | Yes | The plural name of the entity (e.g., 'accounts', 'contacts') | |
| recordId | Yes | The GUID of the record |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"entityNamePlural": {
"description": "The plural name of the entity (e.g., 'accounts', 'contacts')",
"type": "string"
},
"recordId": {
"description": "The GUID of the record",
"type": "string"
}
},
"required": [
"entityNamePlural",
"recordId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:548-576 (handler)The inline asynchronous handler function for the 'get-record' tool. It retrieves the PowerPlatformService instance via getPowerPlatformService(), calls its getRecord method, formats the result as a pretty-printed JSON string, constructs a text content response, and handles errors by returning an error message.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 tool, defining two required string parameters: entityNamePlural (plural entity set name like 'accounts') and recordId (GUID of the record).{ 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:541-577 (registration)MCP server tool registration call: server.tool('get-record', description, schema, handler).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/PowerPlatformService.ts:249-251 (helper)Core implementation in PowerPlatformService.getRecord(): makes an authenticated HTTP GET request to the Web API endpoint `/api/data/v9.2/${entityNamePlural}(${recordId})` via this.makeRequest().async getRecord(entityNamePlural: string, recordId: string): Promise<any> { return this.makeRequest(`api/data/v9.2/${entityNamePlural}(${recordId})`); }