Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_delete_web_resource

Delete web resources from Microsoft Dynamics CRM to manage and clean up development assets. Specify the web resource ID to remove it from the CRM environment.

Instructions

Remove um web resource do Dynamics CRM

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
webResourceIdYesID do web resource a remover

Implementation Reference

  • Handler implementation for the dynamics_delete_web_resource tool, which removes a web resource using the provided webResourceId.
    server.tool(
      "dynamics_delete_web_resource",
      "Remove um web resource do Dynamics CRM",
      DeleteWebResourceSchema.shape,
      async (params: z.infer<typeof DeleteWebResourceSchema>) => {
        await client.remove("webresourceset", params.webResourceId);
        return {
          content: [
            {
              type: "text" as const,
              text: `Web resource ${params.webResourceId} removido com sucesso!`,
            },
          ],
        };
      }
    );
  • Schema definition for the input parameters of the dynamics_delete_web_resource tool.
    export const DeleteWebResourceSchema = z.object({
      webResourceId: z.string().describe("ID do web resource a remover"),
    });
  • Registration function where dynamics_delete_web_resource is defined along with other web resource tools.
    export function registerWebResourceTools(
      server: { tool: Function },
      client: DataverseClient
    ) {
      // 1. Create Web Resource
      server.tool(
        "dynamics_create_web_resource",
        "Cria um novo web resource no Dynamics CRM",
        CreateWebResourceSchema.shape,
        async (params: z.infer<typeof CreateWebResourceSchema>) => {
          let content = params.content;
    
          if (!content && params.generateTemplate) {
            const templateKey = params.type.toLowerCase() as keyof typeof WEB_RESOURCE_TEMPLATES;
            const template = WEB_RESOURCE_TEMPLATES[templateKey];
            if (template) {
              content = typeof template === "string" ? template : template.form || "";
              content = content
                .replace(/{{NAME}}/g, params.name)
                .replace(/{{DISPLAY_NAME}}/g, params.displayName);
            }
          }
    
          const encodedContent = content ? Buffer.from(content).toString("base64") : "";
    
          const data: Record<string, unknown> = {
            name: params.name,
            displayname: params.displayName,
            webresourcetype: TYPE_MAP[params.type],
            content: encodedContent,
            description: params.description || "",
          };
    
          let endpoint = "webresourceset";
          if (params.solutionUniqueName) {
            endpoint += `?SolutionUniqueName='${params.solutionUniqueName}'`;
          }
    
          const result = await client.create(endpoint, data);
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Web resource criado com sucesso!\nID: ${result.entityId}\nNome: ${params.name}\nTipo: ${params.type}${params.solutionUniqueName ? `\nSolução: ${params.solutionUniqueName}` : ""}`,
              },
            ],
          };
        }
      );
    
      // 2. Update Web Resource
      server.tool(
        "dynamics_update_web_resource",
        "Atualiza o conteúdo de um web resource existente",
        UpdateWebResourceSchema.shape,
        async (params: z.infer<typeof UpdateWebResourceSchema>) => {
          const encodedContent = Buffer.from(params.content).toString("base64");
          const data: Record<string, unknown> = { content: encodedContent };
          if (params.description) data.description = params.description;
    
          await client.update("webresourceset", params.webResourceId, data);
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Web resource ${params.webResourceId} atualizado com sucesso!`,
              },
            ],
          };
        }
      );
    
      // 3. List Web Resources
      server.tool(
        "dynamics_list_web_resources",
        "Lista web resources com filtros opcionais",
        ListWebResourcesSchema.shape,
        async (params: z.infer<typeof ListWebResourcesSchema>) => {
          const filters: string[] = ["ismanaged eq false"];
          if (params.nameFilter) {
            filters.push(`contains(name,'${params.nameFilter}')`);
          }
          if (params.type) {
            filters.push(`webresourcetype eq ${TYPE_MAP[params.type]}`);
          }
    
          const result = await client.list("webresourceset", {
            select: ["webresourceid", "name", "displayname", "webresourcetype", "description", "createdon", "modifiedon"],
            filter: filters.join(" and "),
            orderby: "name asc",
            top: params.top,
          });
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Web resources encontrados: ${result.value.length}\n\n${JSON.stringify(result.value, null, 2)}`,
              },
            ],
          };
        }
      );
    
      // 4. Publish Web Resources
      server.tool(
        "dynamics_publish_web_resources",
        "Publica web resources para torná-los disponíveis no sistema",
        PublishWebResourceSchema.shape,
        async (params: z.infer<typeof PublishWebResourceSchema>) => {
          const parameterXml = `<importexportxml><webresources>${params.webResourceIds.map((id) => `<webresource>{${id}}</webresource>`).join("")}</webresources></importexportxml>`;
    
          await client.executeAction("PublishXml", {
            ParameterXml: parameterXml,
          });
    
          return {
            content: [
              {
                type: "text" as const,
                text: `${params.webResourceIds.length} web resource(s) publicado(s) com sucesso!`,
              },
            ],
          };
        }
      );
    
      // 5. Get Web Resource Content
      server.tool(
        "dynamics_get_web_resource_content",
        "Recupera o conteúdo de um web resource (decodificado de Base64)",
        z.object({ webResourceId: z.string().describe("ID do web resource") }).shape,
        async (params: { webResourceId: string }) => {
          const result = await client.get<Record<string, unknown>>(
            `webresourceset(${params.webResourceId})?$select=name,displayname,content,webresourcetype,description`
          );
    
          let decodedContent = "";
          if (result.content) {
            decodedContent = Buffer.from(result.content as string, "base64").toString("utf-8");
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: `**${result.name}** (${result.displayname})\n\nConteúdo:\n\`\`\`\n${decodedContent}\n\`\`\``,
              },
            ],
          };
        }
      );
    
      // 6. Generate Web Resource Code
      server.tool(
        "dynamics_generate_web_resource_code",
        "Gera código template para web resources (JS/HTML/CSS) com helpers do Dynamics",
        GenerateWebResourceCodeSchema.shape,
        async (params: z.infer<typeof GenerateWebResourceCodeSchema>) => {
          let code = "";
    
          if (params.type === "JavaScript") {
            code = params.includeFormHelpers
              ? WEB_RESOURCE_TEMPLATES.javascript.form
              : WEB_RESOURCE_TEMPLATES.javascript.library;
          } else if (params.type === "HTML") {
            code = WEB_RESOURCE_TEMPLATES.html;
          } else if (params.type === "CSS") {
            code = WEB_RESOURCE_TEMPLATES.css;
          }
    
          code = code
            .replace(/{{NAME}}/g, params.name)
            .replace(/{{ENTITY_LOGICAL_NAME}}/g, params.entityLogicalName || "entity")
            .replace(/{{DESCRIPTION}}/g, params.description || "");
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Código gerado para **${params.name}** (${params.type}):\n\n\`\`\`${params.type.toLowerCase()}\n${code}\n\`\`\``,
              },
            ],
          };
        }
      );
    
      // 7. Delete Web Resource
      server.tool(
        "dynamics_delete_web_resource",
        "Remove um web resource do Dynamics CRM",
        DeleteWebResourceSchema.shape,
        async (params: z.infer<typeof DeleteWebResourceSchema>) => {
          await client.remove("webresourceset", params.webResourceId);
          return {
            content: [
              {
                type: "text" as const,
                text: `Web resource ${params.webResourceId} removido com sucesso!`,
              },
            ],
          };
        }
      );
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It confirms a destructive 'Remove' action but lacks details on permissions required, whether the deletion is permanent/reversible, side effects, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

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 with no wasted words, making it easy to parse. However, the Portuguese phrasing ('um web resource do Dynamics CRM') might slightly hinder clarity in English-dominant contexts, though it remains structurally sound.

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 destructive tool with no annotations and no output schema, the description is insufficient. It lacks critical context like success/error responses, confirmation prompts, or integration with sibling tools (e.g., 'dynamics_list_web_resources' for IDs), leaving gaps in operational understanding.

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?

Schema description coverage is 100%, with the single parameter 'webResourceId' clearly documented in the schema. The description adds no additional parameter context beyond implying the ID is for removal, so it meets the baseline of 3 where the schema does the heavy lifting.

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 action ('Remove') and target resource ('web resource do Dynamics CRM'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'dynamics_delete_column' or 'dynamics_delete_solution' beyond the resource type, and the Portuguese phrasing might cause minor ambiguity for English-only agents.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing web resource), exclusions, or relationships to siblings like 'dynamics_create_web_resource' or 'dynamics_list_web_resources', leaving the agent to infer context from the tool name alone.

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