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

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

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name (optional)", "type": "string" }, "token": { "description": "Authentication token (default from config)", "type": "string" }, "url": { "description": "Directus API URL (default from config)", "type": "string" } }, "required": [], "type": "object" }

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: [] }

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