Skip to main content
Glama
rafteles2016

MCP Dynamics CRM Server

by rafteles2016

dynamics_create_relationship

Create relationships between tables in Microsoft Dynamics CRM by defining schema, entities, attributes, and cascade behaviors for data modeling.

Instructions

Cria um relacionamento entre duas tabelas

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNameYesNome do schema do relacionamento
referencingEntityYesEntidade referenciadora (many)
referencedEntityYesEntidade referenciada (one)
referencingAttributeYesAtributo de lookup
relationshipTypeNoOneToMany
cascadeAssignNoNoCascade
cascadeDeleteNoRemoveLink
solutionUniqueNameNo

Implementation Reference

  • The handler function for "dynamics_create_relationship" which defines the relationship metadata and sends a POST request to Dataverse.
    server.tool(
      "dynamics_create_relationship",
      "Cria um relacionamento entre duas tabelas",
      CreateRelationshipSchema.shape,
      async (params: z.infer<typeof CreateRelationshipSchema>) => {
        if (params.relationshipType === "OneToMany") {
          const relData = {
            SchemaName: params.schemaName,
            "@odata.type": "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata",
            ReferencedEntity: params.referencedEntity,
            ReferencingEntity: params.referencingEntity,
            Lookup: {
              SchemaName: params.referencingAttribute,
              DisplayName: {
                "@odata.type": "Microsoft.Dynamics.CRM.Label",
                LocalizedLabels: [{ "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel", Label: params.referencedEntity, LanguageCode: 1046 }],
              },
              RequiredLevel: { Value: "None" },
            },
            CascadeConfiguration: {
              Assign: params.cascadeAssign,
              Delete: params.cascadeDelete,
              Merge: "NoCascade",
              Reparent: "NoCascade",
              Share: "NoCascade",
              Unshare: "NoCascade",
            },
          };
    
          let endpoint = "RelationshipDefinitions";
          if (params.solutionUniqueName) {
            endpoint += `?SolutionUniqueName='${params.solutionUniqueName}'`;
          }
    
          const result = await client.post<{ MetadataId: string }>(endpoint, relData);
          return {
            content: [
              {
                type: "text" as const,
                text: `Relacionamento 1:N criado!\nMetadataId: ${result.MetadataId}\n${params.referencedEntity} -> ${params.referencingEntity}`,
              },
            ],
          };
        } else {
          const relData = {
            SchemaName: params.schemaName,
            "@odata.type": "Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata",
            Entity1LogicalName: params.referencedEntity,
            Entity2LogicalName: params.referencingEntity,
            IntersectEntityName: `${params.referencedEntity}_${params.referencingEntity}`,
          };
    
          let endpoint = "RelationshipDefinitions";
          if (params.solutionUniqueName) {
            endpoint += `?SolutionUniqueName='${params.solutionUniqueName}'`;
          }
    
          const result = await client.post<{ MetadataId: string }>(endpoint, relData);
          return {
            content: [
              {
                type: "text" as const,
                text: `Relacionamento N:N criado!\nMetadataId: ${result.MetadataId}\n${params.referencedEntity} <-> ${params.referencingEntity}`,
  • The Zod schema definition for "dynamics_create_relationship" inputs.
    export const CreateRelationshipSchema = z.object({
      schemaName: z.string().describe("Nome do schema do relacionamento"),
      referencingEntity: z.string().describe("Entidade referenciadora (many)"),
      referencedEntity: z.string().describe("Entidade referenciada (one)"),
      referencingAttribute: z.string().describe("Atributo de lookup"),
      relationshipType: z.enum(["OneToMany", "ManyToMany"]).default("OneToMany"),
      cascadeAssign: z.enum(["NoCascade", "Cascade", "Active", "UserOwned"]).default("NoCascade"),
      cascadeDelete: z.enum(["NoCascade", "Cascade", "RemoveLink", "Restrict"]).default("RemoveLink"),
      solutionUniqueName: z.string().optional(),
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Cria' indicates a write/mutation operation, but the description doesn't disclose important behavioral traits like required permissions, whether the operation is idempotent, what happens on failure, or what the expected response looks like. For a creation tool with zero annotation coverage, this is a significant gap.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with a clear primary function and gets straight to the point without unnecessary elaboration.

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 complex tool with 8 parameters (4 required), no annotations, and no output schema, the description is insufficient. It doesn't explain the relationship types (OneToMany/ManyToMany), cascade behaviors, or solution context. The description fails to provide the contextual completeness needed for an agent to understand this tool's full scope and implications.

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% (4 of 8 parameters have descriptions), so the description needs to compensate but doesn't. The description mentions creating relationships between two tables, which aligns with referencingEntity and referencedEntity parameters, but adds no additional semantic context beyond what's implied by parameter names. With moderate schema coverage, the description provides minimal added value.

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 ('Cria' - creates) and the resource ('um relacionamento entre duas tabelas' - a relationship between two tables), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like dynamics_create_column or dynamics_create_table, which also create different types of resources in the same system.

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 operation is appropriate, or how it differs from other relationship management tools (though none appear in the sibling list). The description is purely functional without contextual usage information.

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