Skip to main content
Glama
michsob

PowerPlatform MCP

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
NameRequiredDescriptionDefault
entityNamePluralYesThe plural name of the entity (e.g., 'accounts', 'contacts')
recordIdYesThe 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}`,
              },
            ],
          };
        }
      }
    );
  • 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"),
    },
  • 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}`,
            },
          ],
        };
      }
    }
  • 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})`);
    }
  • 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}`);
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/michsob/powerplatform-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server