Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_get_entity_analytics

Analyze entity metrics like total records and usage to monitor performance and track data volume in Microsoft Dynamics CRM.

Instructions

Analisa métricas de uma entidade (total de registros, usage, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityLogicalNameYesNome lógico da entidade

Implementation Reference

  • Implementation of the 'dynamics_get_entity_analytics' tool, which fetches entity metadata, record count, recent plugin traces, and active workflows.
    server.tool(
      "dynamics_get_entity_analytics",
      "Analisa métricas de uma entidade (total de registros, usage, etc.)",
      GetEntityAnalyticsSchema.shape,
      async (params: z.infer<typeof GetEntityAnalyticsSchema>) => {
        // Get entity metadata
        const metadata = await client.get<Record<string, unknown>>(
          `EntityDefinitions(LogicalName='${params.entityLogicalName}')?$select=LogicalName,SchemaName,DisplayName,EntitySetName,IsCustomEntity,IsAuditEnabled,ChangeTrackingEnabled`
        );
    
        // Get record count
        const countResult = await client.get<number>(
          `${(metadata as Record<string, unknown>).EntitySetName}/$count`
        );
    
        // Get recent plugin trace logs for this entity
        const pluginTraces = await client.list("plugintracelogs", {
          select: ["typename", "messagename", "performanceexecutionduration", "exceptiondetails"],
          filter: `contains(primaryentity,'${params.entityLogicalName}')`,
          orderby: "createdon desc",
          top: 10,
        });
    
        // Get workflows related to this entity
        const workflows = await client.list("workflows", {
          select: ["name", "category", "statecode", "mode"],
          filter: `primaryentity eq '${params.entityLogicalName}' and statecode eq 1`,
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: `## Análise da Entidade: ${params.entityLogicalName}\n\n**Metadados:**\n- Schema: ${(metadata as Record<string, unknown>).SchemaName}\n- Custom: ${(metadata as Record<string, unknown>).IsCustomEntity}\n- Audit: ${JSON.stringify((metadata as Record<string, unknown>).IsAuditEnabled)}\n- Change Tracking: ${(metadata as Record<string, unknown>).ChangeTrackingEnabled}\n\n**Registros:** ${countResult}\n\n**Plugins Recentes (${pluginTraces.value.length}):**\n${JSON.stringify(pluginTraces.value, null, 2)}\n\n**Workflows Ativos (${workflows.value.length}):**\n${JSON.stringify(workflows.value, null, 2)}`,
            },
          ],
        };
      }
    );
  • Schema definition for 'dynamics_get_entity_analytics' requiring entityLogicalName.
    export const GetEntityAnalyticsSchema = z.object({
      entityLogicalName: z.string().describe("Nome lógico da entidade"),
    });

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/rafteles2016/mcpDynamics'

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