Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_generate_fetchxml

Generate FetchXML queries for Dynamics CRM by specifying entities, columns, filters, and joins to retrieve structured data efficiently.

Instructions

Gera FetchXML com base em parâmetros estruturados

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityLogicalNameYesEntidade principal
columnsYesColunas a retornar
filtersNoFiltros
ordersNo
linkedEntitiesNo
topNo

Implementation Reference

  • The handler implementation for the `dynamics_generate_fetchxml` tool, which constructs a FetchXML string based on the provided schema parameters.
    server.tool(
      "dynamics_generate_fetchxml",
      "Gera FetchXML com base em parâmetros estruturados",
      GenerateFetchXmlSchema.shape,
      async (params: z.infer<typeof GenerateFetchXmlSchema>) => {
        let fetchXml = `<fetch version="1.0" output-format="xml-platform" mapping="logical"`;
        if (params.top) fetchXml += ` top="${params.top}"`;
        fetchXml += `>\n  <entity name="${params.entityLogicalName}">\n`;
    
        for (const col of params.columns) {
          fetchXml += `    <attribute name="${col}" />\n`;
        }
    
        if (params.orders) {
          for (const order of params.orders) {
            fetchXml += `    <order attribute="${order.attribute}" descending="${order.descending}" />\n`;
          }
        }
    
        if (params.filters && params.filters.length > 0) {
          fetchXml += `    <filter type="and">\n`;
          for (const f of params.filters) {
            if (f.value) {
              fetchXml += `      <condition attribute="${f.attribute}" operator="${f.operator}" value="${f.value}" />\n`;
            } else {
              fetchXml += `      <condition attribute="${f.attribute}" operator="${f.operator}" />\n`;
            }
          }
          fetchXml += `    </filter>\n`;
        }
    
        if (params.linkedEntities) {
          for (const le of params.linkedEntities) {
            fetchXml += `    <link-entity name="${le.name}" from="${le.from}" to="${le.to}" alias="${le.alias}" link-type="${le.linkType}">\n`;
            for (const col of le.columns) {
              fetchXml += `      <attribute name="${col}" />\n`;
            }
            fetchXml += `    </link-entity>\n`;
          }
        }
    
        fetchXml += `  </entity>\n</fetch>`;
    
        return {
          content: [
            {
              type: "text" as const,
              text: `FetchXML gerado:\n\n\`\`\`xml\n${fetchXml}\n\`\`\``,
            },
          ],
        };
      }
    );
  • The input validation schema (`GenerateFetchXmlSchema`) for the `dynamics_generate_fetchxml` tool.
    export const GenerateFetchXmlSchema = z.object({
      entityLogicalName: z.string().describe("Entidade principal"),
      columns: z.array(z.string()).describe("Colunas a retornar"),
      filters: z.array(z.object({
        attribute: z.string(),
        operator: z.string(),
        value: z.string().optional(),
      })).optional().describe("Filtros"),
      orders: z.array(z.object({
        attribute: z.string(),
        descending: z.boolean().default(false),
      })).optional(),
      linkedEntities: z.array(z.object({
        name: z.string(),
        from: z.string(),
        to: z.string(),
        alias: z.string(),
        columns: z.array(z.string()),
        linkType: z.enum(["inner", "outer"]).default("outer"),
      })).optional(),
      top: z.number().optional(),
    });
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 FetchXML but doesn't describe what happens with that output, whether it's returned as text, saved somewhere, or used in another process. It doesn't mention permissions needed, rate limits, or whether this is a read-only operation (likely, but not stated).

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

Conciseness5/5

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

The description is extremely concise - a single sentence in Portuguese that directly states the tool's function. There's zero wasted language or unnecessary elaboration. It's front-loaded with the core purpose immediately clear.

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 tool with 6 parameters (including complex nested objects), no annotations, no output schema, and only 50% schema description coverage, the description is inadequate. It doesn't explain what FetchXML is, how the generated XML would be used, what the output format is, or provide any context about this being a Dynamics CRM/CE query language generator versus a general XML tool.

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 50%, with only 3 of 6 parameters having descriptions. The description adds minimal value beyond the schema - it mentions 'parâmetros estruturados' (structured parameters) which hints at the complex object structure but doesn't explain what each parameter does or how they combine to create FetchXML. The baseline is 3 since schema coverage is exactly 50%.

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

Purpose3/5

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

The description 'Gera FetchXML com base em parâmetros estruturados' (Generates FetchXML based on structured parameters) states the action (generates) and output (FetchXML), but is vague about what FetchXML is and its purpose. It doesn't specify that this is for querying Dynamics data or distinguish it from sibling tools like dynamics_get_views or dynamics_list_tables that might retrieve data directly.

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. The description doesn't mention that this generates query XML rather than executing queries, or when you'd use this instead of direct data retrieval tools like dynamics_get_views. There's no context about prerequisites or typical use cases.

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