Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_get_plugin_performance

Analyze plugin execution performance in Dynamics CRM by tracking duration, errors, and frequency to identify bottlenecks and optimize workflows.

Instructions

Analisa performance de execução de plugins (duração, erros, frequência)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topNoNúmero de plugins a retornar
minDurationNoDuração mínima em ms para filtrar
entityLogicalNameNoFiltrar por entidade

Implementation Reference

  • Implementation of the dynamics_get_plugin_performance tool handler.
    server.tool(
      "dynamics_get_plugin_performance",
      "Analisa performance de execução de plugins (duração, erros, frequência)",
      GetPluginPerformanceSchema.shape,
      async (params: z.infer<typeof GetPluginPerformanceSchema>) => {
        const filters: string[] = [];
        if (params.minDuration) {
          filters.push(`performanceexecutionduration ge ${params.minDuration}`);
        }
        if (params.entityLogicalName) {
          filters.push(`contains(primaryentity,'${params.entityLogicalName}')`);
        }
    
        const result = await client.list("plugintracelogs", {
          select: [
            "typename", "messagename", "primaryentity",
            "performanceexecutionstarttime", "performanceexecutionduration",
            "operationtype", "exceptiondetails", "depth", "createdon",
            "correlationid", "issystemcreated",
          ],
          filter: filters.length > 0 ? filters.join(" and ") : undefined,
          orderby: "performanceexecutionduration desc",
          top: params.top,
        });
    
        // Calculate statistics
        const traces = result.value as Array<Record<string, unknown>>;
        const stats = {
          totalExecutions: traces.length,
          withErrors: traces.filter((t) => t.exceptiondetails).length,
          avgDuration: traces.length > 0
            ? Math.round(traces.reduce((sum, t) => sum + ((t.performanceexecutionduration as number) || 0), 0) / traces.length)
            : 0,
          maxDuration: traces.length > 0
            ? Math.max(...traces.map((t) => (t.performanceexecutionduration as number) || 0))
            : 0,
          slowestPlugins: traces.slice(0, 5).map((t) => ({
            name: t.typename,
            message: t.messagename,
            entity: t.primaryentity,
            duration: t.performanceexecutionduration,
            hasError: !!t.exceptiondetails,
          })),
        };
    
        return {
          content: [
            {
              type: "text" as const,
              text: `## Performance de Plugins\n\n**Resumo:**\n- Total de execuções analisadas: ${stats.totalExecutions}\n- Execuções com erro: ${stats.withErrors}\n- Duração média: ${stats.avgDuration}ms\n- Duração máxima: ${stats.maxDuration}ms\n\n**Top 5 Plugins mais lentos:**\n${stats.slowestPlugins.map((p, i) => `${i + 1}. **${p.name}** (${p.message} em ${p.entity}) - ${p.duration}ms ${p.hasError ? "⚠ COM ERRO" : ""}`).join("\n")}\n\n**Detalhes:**\n${JSON.stringify(traces.slice(0, 10), null, 2)}`,
            },
          ],
        };
      }
    );
  • Zod schema definition for input validation of the dynamics_get_plugin_performance tool.
    export const GetPluginPerformanceSchema = z.object({
      top: z.number().default(20).describe("Número de plugins a retornar"),
      minDuration: z.number().optional().describe("Duração mínima em ms para filtrar"),
      entityLogicalName: z.string().optional().describe("Filtrar por entidade"),
    });
  • Registration of the dynamics_get_plugin_performance tool within registerTelemetryTools.
    export function registerTelemetryTools(
      server: { tool: Function },
      client: DataverseClient
    ) {

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