Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_get_audit_history

Retrieve audit history records from Dynamics CRM to track system changes, user activities, and data modifications for compliance and troubleshooting.

Instructions

Consulta histórico de auditoria do sistema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityLogicalNameNo
userIdNo
topNo
operationNoall

Implementation Reference

  • The handler function for 'dynamics_get_audit_history' that queries the Dynamics API for audit records based on input filters.
    server.tool(
      "dynamics_get_audit_history",
      "Consulta histórico de auditoria do sistema",
      GetAuditHistorySchema.shape,
      async (params: z.infer<typeof GetAuditHistorySchema>) => {
        const filters: string[] = [];
        if (params.entityLogicalName) {
          filters.push(`objecttypecode eq '${params.entityLogicalName}'`);
        }
        if (params.userId) {
          filters.push(`_userid_value eq '${params.userId}'`);
        }
        if (params.operation !== "all") {
          const opMap: Record<string, number> = { Create: 1, Update: 2, Delete: 3 };
          filters.push(`operation eq ${opMap[params.operation]}`);
        }
    
        const result = await client.list("audits", {
          select: [
            "auditid", "objecttypecode", "operation", "action",
            "_userid_value", "createdon", "changedata",
          ],
          filter: filters.length > 0 ? filters.join(" and ") : undefined,
          orderby: "createdon desc",
          top: params.top,
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: `## Histórico de Auditoria\n\nRegistros: ${result.value.length}\n\n${JSON.stringify(result.value, null, 2)}`,
            },
          ],
        };
      }
    );
  • Zod schema definition for 'dynamics_get_audit_history' input validation.
    export const GetAuditHistorySchema = z.object({
      entityLogicalName: z.string().optional(),
      userId: z.string().optional(),
      top: z.number().default(50),
      operation: z.enum(["all", "Create", "Update", "Delete"]).default("all"),
    });

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