Skip to main content
Glama

getItems

Retrieve items from a specific collection in Directus using the MCP Server by providing API details, collection name, and optional query parameters for filtering, sorting, or limiting results.

Instructions

Get items from a collection in Directus

Input Schema

NameRequiredDescriptionDefault
collectionYesCollection name
queryNoQuery parameters like filter, sort, limit, etc. (optional)
tokenNoAuthentication token (default from config)
urlNoDirectus API URL (default from config)

Input Schema (JSON Schema)

{ "properties": { "collection": { "description": "Collection name", "type": "string" }, "query": { "description": "Query parameters like filter, sort, limit, etc. (optional)", "type": "object" }, "token": { "description": "Authentication token (default from config)", "type": "string" }, "url": { "description": "Directus API URL (default from config)", "type": "string" } }, "required": [ "collection" ], "type": "object" }

Implementation Reference

  • The handler logic for the 'getItems' tool. It retrieves authentication token, collection name, and optional query parameters from inputs, performs a GET request to the Directus API endpoint `/items/{collection}` using axios, and returns the response data as JSON.
    case "getItems": { const token = toolArgs.token || CONFIG.DIRECTUS_ACCESS_TOKEN; const collection = toolArgs.collection as string; const query = toolArgs.query as Record<string, any> | undefined; const response = await axios.get( `${url}/items/${collection}`, { headers: buildHeaders(token), params: query } ); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2) } ] }; }
  • Input schema for the 'getItems' tool, defining properties for url, token, collection (required), and optional query object.
    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" }, query: { type: "object", description: "Query parameters like filter, sort, limit, etc. (optional)" } }, required: ["collection"] }
  • index.ts:88-112 (registration)
    Registration of the 'getItems' tool in the listTools response, including name, description, and input schema.
    { name: "getItems", description: "Get items from a collection in Directus", 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" }, query: { type: "object", description: "Query parameters like filter, sort, limit, etc. (optional)" } }, 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