Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_system_health

Monitor system performance and health metrics for Dynamics CRM, providing consolidated telemetry views to identify issues and optimize workflows.

Instructions

Painel de saúde geral do sistema - visão consolidada de performance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeRangeNoPeríodo de tempo para análise24h

Implementation Reference

  • The handler for dynamics_system_health, which collects metrics on failed jobs, slow plugins, active workflows, and recent errors, calculates a health score, and generates a status summary.
    server.tool(
      "dynamics_system_health",
      "Painel de saúde geral do sistema - visão consolidada de performance",
      GetSystemPerformanceSchema.shape,
      async (_params: z.infer<typeof GetSystemPerformanceSchema>) => {
        // Gather multiple data points in parallel
        const [failedJobs, slowPlugins, activeWorkflows, recentErrors] = await Promise.all([
          client.list("asyncoperations", {
            select: ["name", "statuscode", "createdon"],
            filter: "statuscode eq 31",
            orderby: "createdon desc",
            top: 10,
          }),
          client.list("plugintracelogs", {
            select: ["typename", "performanceexecutionduration", "exceptiondetails"],
            filter: "performanceexecutionduration ge 2000",
            orderby: "performanceexecutionduration desc",
            top: 10,
          }),
          client.list("workflows", {
            select: ["name", "category", "statecode"],
            filter: "statecode eq 1",
          }),
          client.list("plugintracelogs", {
            select: ["typename", "messagename", "exceptiondetails", "createdon"],
            filter: "exceptiondetails ne null",
            orderby: "createdon desc",
            top: 10,
          }),
        ]);
    
        const failedJobsList = failedJobs.value as Array<Record<string, unknown>>;
        const slowPluginsList = slowPlugins.value as Array<Record<string, unknown>>;
        const activeWfList = activeWorkflows.value as Array<Record<string, unknown>>;
        const errorsList = recentErrors.value as Array<Record<string, unknown>>;
    
        // Calculate health score
        let healthScore = 100;
        if (failedJobsList.length > 5) healthScore -= 20;
        else if (failedJobsList.length > 0) healthScore -= failedJobsList.length * 3;
        if (slowPluginsList.length > 5) healthScore -= 20;
        else if (slowPluginsList.length > 0) healthScore -= slowPluginsList.length * 3;
        if (errorsList.length > 5) healthScore -= 15;
        healthScore = Math.max(0, healthScore);
    
        const healthStatus = healthScore >= 80 ? "SAUDAVEL" : healthScore >= 50 ? "ATENCAO" : "CRITICO";
    
        return {
          content: [
            {
              type: "text" as const,
              text: `## Saúde do Sistema Dynamics CRM\n\n**Score: ${healthScore}/100 - ${healthStatus}**\n\n---\n\n### Jobs com Falha: ${failedJobsList.length}\n${failedJobsList.slice(0, 5).map((j) => `- ${j.name} (${j.createdon})`).join("\n") || "Nenhum"}\n\n### Plugins Lentos (>2s): ${slowPluginsList.length}\n${slowPluginsList.slice(0, 5).map((p) => `- ${p.typename}: ${p.performanceexecutionduration}ms`).join("\n") || "Nenhum"}\n\n### Workflows Ativos: ${activeWfList.length}\n\n### Erros Recentes de Plugin: ${errorsList.length}\n${errorsList.slice(0, 5).map((e) => `- ${e.typename} (${e.messagename}): ${String(e.exceptiondetails).substring(0, 100)}...`).join("\n") || "Nenhum"}\n\n---\n**Recomendações:**\n${healthScore < 80 ? [
                failedJobsList.length > 0 ? "- Investigar jobs com falha e corrigir as causas" : "",
                slowPluginsList.length > 0 ? "- Otimizar plugins lentos ou convertê-los para assíncrono" : "",
                errorsList.length > 0 ? "- Corrigir erros nos plugins identificados" : "",
              ].filter(Boolean).join("\n") : "Sistema operando normalmente."}`,
            },
          ],
        };
      }
    );
  • The schema used for input validation of the dynamics_system_health tool.
    export const GetSystemPerformanceSchema = z.object({
      timeRange: z.enum(["1h", "6h", "24h", "7d", "30d"]).default("24h")
        .describe("Período de tempo para análise"),
    });

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