getRoles
Retrieve roles from Directus CMS via the Directus MCP Server using specified query parameters, authentication token, and API URL.
Instructions
Get roles from Directus
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Query parameters like filter, sort, limit, etc. (optional) | |
| token | No | Authentication token (default from config) | |
| url | No | Directus API URL (default from config) |
Input Schema (JSON Schema)
{
"properties": {
"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": [],
"type": "object"
}
Implementation Reference
- index.ts:898-918 (handler)Handler implementation for the getRoles tool. Fetches roles from the Directus /roles endpoint using axios, with optional token and query parameters. Returns JSON stringified response data.case "getRoles": { const token = toolArgs.token || CONFIG.DIRECTUS_ACCESS_TOKEN; const query = toolArgs.query as Record<string, any> | undefined; const response = await axios.get( `${url}/roles`, { headers: buildHeaders(token), params: query } ); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2) } ] }; }
- index.ts:461-478 (schema)Input schema definition for the getRoles tool, specifying optional url, token, and query parameters.inputSchema: { type: "object", properties: { url: { type: "string", description: "Directus API URL (default from config)" }, token: { type: "string", description: "Authentication token (default from config)" }, query: { type: "object", description: "Query parameters like filter, sort, limit, etc. (optional)" } }, required: [] }
- index.ts:458-479 (registration)Tool registration entry for getRoles in the tools array provided to the MCP server.{ name: "getRoles", description: "Get roles from Directus", inputSchema: { type: "object", properties: { url: { type: "string", description: "Directus API URL (default from config)" }, token: { type: "string", description: "Authentication token (default from config)" }, query: { type: "object", description: "Query parameters like filter, sort, limit, etc. (optional)" } }, required: [] } },