Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_generate_plugin_code

Generate C# code for Dynamics CRM plugins by specifying entity, message, stage, and business logic to automate custom workflow extensions.

Instructions

Gera código C# para um plugin do Dynamics CRM com base nos parâmetros fornecidos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesNome da classe do plugin (ex: AccountPreCreate)
entityLogicalNameYesNome lógico da entidade (ex: account)
messageYesMensagem/evento do plugin
stageYesEstágio de execução
executionModeNoModo de execuçãoSynchronous
filteringAttributesNoAtributos de filtragem separados por vírgula
descriptionNoDescrição do plugin
businessLogicNoLógica de negócio a ser implementada no plugin

Implementation Reference

  • The handler implementation for dynamics_generate_plugin_code, which generates C# code based on provided plugin configuration parameters.
    server.tool(
      "dynamics_generate_plugin_code",
      "Gera código C# para um plugin do Dynamics CRM com base nos parâmetros fornecidos",
      CreatePluginSchema.shape,
      async (params: z.infer<typeof CreatePluginSchema>) => {
        const stageValue = STAGE_MAP[params.stage] || 40;
        const template = PLUGIN_TEMPLATES.standard;
    
        const code = template
          .replace(/{{CLASS_NAME}}/g, params.name)
          .replace(/{{ENTITY_LOGICAL_NAME}}/g, params.entityLogicalName)
          .replace(/{{MESSAGE}}/g, params.message)
          .replace(/{{STAGE}}/g, String(stageValue))
          .replace(/{{EXECUTION_MODE}}/g, params.executionMode === "Synchronous" ? "0" : "1")
          .replace(/{{FILTERING_ATTRIBUTES}}/g, params.filteringAttributes || "")
          .replace(/{{DESCRIPTION}}/g, params.description || `Plugin ${params.name} for ${params.message} on ${params.entityLogicalName}`)
          .replace(/{{BUSINESS_LOGIC}}/g, params.businessLogic || "// TODO: Implement business logic here");
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Plugin C# gerado com sucesso:\n\n\`\`\`csharp\n${code}\n\`\`\`\n\n**Configuração:**\n- Entidade: ${params.entityLogicalName}\n- Mensagem: ${params.message}\n- Estágio: ${params.stage} (${stageValue})\n- Modo: ${params.executionMode}\n${params.filteringAttributes ? `- Filtro: ${params.filteringAttributes}` : ""}`,
            },
          ],
        };
      }
    );
  • The schema defining the expected input parameters for the dynamics_generate_plugin_code tool.
    export const CreatePluginSchema = z.object({
      name: z.string().describe("Nome da classe do plugin (ex: AccountPreCreate)"),
      entityLogicalName: z.string().describe("Nome lógico da entidade (ex: account)"),
      message: z.enum(["Create", "Update", "Delete", "Retrieve", "RetrieveMultiple", "Associate", "Disassociate", "SetState", "SetStateDynamicEntity"])
        .describe("Mensagem/evento do plugin"),
      stage: z.enum(["PreValidation", "PreOperation", "PostOperation"])
        .describe("Estágio de execução"),
      executionMode: z.enum(["Synchronous", "Asynchronous"]).default("Synchronous")
        .describe("Modo de execução"),
      filteringAttributes: z.string().optional()
        .describe("Atributos de filtragem separados por vírgula"),
      description: z.string().optional()
        .describe("Descrição do plugin"),
      businessLogic: z.string().optional()
        .describe("Lógica de negócio a ser implementada no plugin"),
    });
  • The registration entry point for plugin-related tools, including dynamics_generate_plugin_code.
    export function registerPluginTools(
      server: { tool: Function },
      client: DataverseClient
    ) {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool generates code but doesn't reveal important behavioral aspects: whether this creates files or returns code as text, what format the output takes, whether it validates inputs, what happens with invalid parameters, or any authentication/permission requirements. For a code generation tool with 8 parameters, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point. There's no wasted language, and it's appropriately sized for a tool with this complexity. However, it could be slightly more structured by front-loading the most critical information about output format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a code generation tool with 8 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what format the generated code takes (file, string, structured object), how to use the output, or any constraints on the businessLogic parameter. The description should provide more context about the tool's behavior and output given the absence of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'com base nos parâmetros fornecidos' (based on the parameters provided) but adds no specific parameter semantics beyond what's already in the schema. With 100% schema description coverage, the baseline is 3. The description doesn't explain how parameters interact (e.g., how businessLogic integrates into the generated code) or provide examples of typical parameter combinations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Gera código C# para um plugin do Dynamics CRM' (Generates C# code for a Dynamics CRM plugin). It specifies the verb ('gera' - generates), resource (C# code), and target (Dynamics CRM plugin). However, it doesn't distinguish this from its sibling 'dynamics_generate_plugin_project' which might generate project files rather than just plugin code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when this tool is appropriate versus other code generation tools like 'dynamics_generate_web_resource_code' or 'dynamics_generate_plugin_project', or any context about what should be done with the generated code.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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