Skip to main content
Glama

getRelations

Retrieve relations for a specific collection in Directus CMS using the MCP server. Input the API URL, authentication token, and optional collection name to fetch related data.

Instructions

Get relations for a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNoCollection name (optional)
tokenNoAuthentication token (default from config)
urlNoDirectus API URL (default from config)

Implementation Reference

  • Handler for the 'getRelations' tool. Retrieves relations from Directus API endpoint '/relations' or '/relations/{collection}' using axios GET request and returns the JSON response as text content.
    case "getRelations": {
      const token = toolArgs.token || CONFIG.DIRECTUS_ACCESS_TOKEN;
      const collection = toolArgs.collection as string | undefined;
      
      let endpoint = `${url}/relations`;
      if (collection) {
        endpoint += `/${collection}`;
      }
      
      const response = await axios.get(
        endpoint,
        { headers: buildHeaders(token) }
      );
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(response.data, null, 2)
          }
        ]
      };
    }
  • index.ts:332-353 (registration)
    Registration of the 'getRelations' tool in the listTools response, including name, description, and input schema definition.
    {
      name: "getRelations",
      description: "Get relations for a collection",
      inputSchema: {
        type: "object",
        properties: {
          url: { 
            type: "string", 
            description: "Directus API URL (default from config)"
          },
          token: { 
            type: "string", 
            description: "Authentication token (default from config)"
          },
          collection: {
            type: "string",
            description: "Collection name (optional)"
          }
        },
        required: []
      }
    },
  • Input schema definition for the 'getRelations' tool, specifying optional parameters for URL, token, and collection.
    inputSchema: {
      type: "object",
      properties: {
        url: { 
          type: "string", 
          description: "Directus API URL (default from config)"
        },
        token: { 
          type: "string", 
          description: "Authentication token (default from config)"
        },
        collection: {
          type: "string",
          description: "Collection name (optional)"
        }
      },
      required: []
    }
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 only states the basic operation. It doesn't disclose whether this is a read-only operation (implied by 'get'), what authentication is needed (though the token parameter hints at it), rate limits, pagination behavior, or what format the relations are returned in. Significant behavioral details are missing.

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 waste. It's appropriately sized for a simple tool and front-loads the core purpose 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?

Given the tool's complexity (retrieving metadata-like relations), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'relations' are in the Directus context (e.g., database relationships, API links), what the output looks like, or error conditions. More context is needed for effective use.

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%, so the schema already documents all three parameters (collection, token, url). The description doesn't add any meaning beyond what the schema provides—it doesn't explain what 'relations' are or how the collection parameter affects the output. Baseline 3 is appropriate when the schema does the heavy lifting.

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 'Get relations for a collection' states the basic action (get) and target (relations), but is vague about what 'relations' means in this context and doesn't distinguish this tool from similar siblings like getFields or getCollections. It provides minimal but functional purpose information.

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 like getFields (which might return related field metadata) or getCollections (which might list collections themselves). The description implies it's for retrieving relationship data but offers no context about appropriate use cases or prerequisites.

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

Related 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/pixelsock/directus-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server