Skip to main content
Glama

getFields

Retrieve field details for a specific collection in Directus via the Model Context Protocol, enabling streamlined interaction with CMS APIs for data management.

Instructions

Get fields for a collection

Input Schema

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

Implementation Reference

  • The handler function for the 'getFields' tool. It retrieves the fields schema for a given collection by making an authenticated GET request to the Directus API endpoint `/fields/{collection}` and returns the response as JSON text.
    case "getFields": { const token = toolArgs.token || CONFIG.DIRECTUS_ACCESS_TOKEN; const collection = toolArgs.collection as string; const response = await axios.get( `${url}/fields/${collection}`, { headers: buildHeaders(token) } ); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2) } ] }; }
  • index.ts:310-331 (registration)
    Registration of the 'getFields' tool in the ListTools handler response. Includes the tool name, description, and input schema defining required 'collection' parameter and optional 'url' and 'token'.
    { name: "getFields", description: "Get fields 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" } }, required: ["collection"] } },
  • The input schema for the 'getFields' tool, specifying an object with optional 'url' and 'token' properties, and required 'collection' string.
    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" } }, required: ["collection"] }

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