Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_get_workflow_performance

Analyze workflow and automated process performance and status in Dynamics CRM to monitor execution, identify issues, and optimize business automation.

Instructions

Analisa performance e status de workflows e processos automáticos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topNo
statusFilterNoall

Implementation Reference

  • The handler for "dynamics_get_workflow_performance" queries 'asyncoperations' in Dynamics to provide performance and status summary of workflows.
    server.tool(
      "dynamics_get_workflow_performance",
      "Analisa performance e status de workflows e processos automáticos",
      GetWorkflowPerformanceSchema.shape,
      async (params: z.infer<typeof GetWorkflowPerformanceSchema>) => {
        const filters: string[] = [];
        if (params.statusFilter !== "all") {
          const statusCode = WORKFLOW_STATUS[params.statusFilter];
          if (statusCode !== undefined) {
            filters.push(`statuscode eq ${statusCode}`);
          }
        }
    
        const result = await client.list("asyncoperations", {
          select: [
            "asyncoperationid", "name", "operationtype", "statuscode",
            "startedon", "completedon", "executiontimespan", "retrycount",
            "friendlymessage", "message", "primaryentitytype",
            "postponeuntil", "recurrencepattern",
          ],
          filter: filters.length > 0 ? filters.join(" and ") : undefined,
          orderby: "createdon desc",
          top: params.top,
        });
    
        const jobs = result.value as Array<Record<string, unknown>>;
        const statusSummary: Record<string, number> = {};
        for (const job of jobs) {
          const statusName = SYSTEM_JOB_STATUS[job.statuscode as number] || `Unknown (${job.statuscode})`;
          statusSummary[statusName] = (statusSummary[statusName] || 0) + 1;
        }
    
        const failedJobs = jobs.filter((j) => j.statuscode === 31);
    
        return {
          content: [
            {
              type: "text" as const,
              text: `## Performance de Workflows/Processos\n\n**Resumo de Status:**\n${Object.entries(statusSummary).map(([status, count]) => `- ${status}: ${count}`).join("\n")}\n\n**Jobs com Falha:** ${failedJobs.length}\n${failedJobs.slice(0, 5).map((j) => `- **${j.name}**: ${j.friendlymessage || j.message || "Sem mensagem"}`).join("\n")}\n\n**Detalhes:**\n${JSON.stringify(jobs.slice(0, 10), null, 2)}`,
            },
          ],
        };
      }
    );
  • Input validation schema for the workflow performance tool.
    export const GetWorkflowPerformanceSchema = z.object({
      top: z.number().default(20),
      statusFilter: z.enum(["all", "succeeded", "failed", "waiting", "suspended", "cancelled"]).default("all"),
    });
  • Registration function that takes the server instance and registers the tools including dynamics_get_workflow_performance.
    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