Skip to main content
Glama

login

Authenticate into the Directus CMS API to generate an access token using the MCP Server, enabling interaction with collections, items, files, and system data.

Instructions

Login to Directus and get an access token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailNoUser email (default from config)
passwordNoUser password (default from config)
urlNoDirectus API URL (default from config)

Implementation Reference

  • Handler for the 'login' tool within the switch statement in CallToolRequestSchema. It extracts email/password from args or config, calls getAuthToken, and returns the access token as text content.
    case "login": { const email = toolArgs.email || CONFIG.DIRECTUS_EMAIL; const password = toolArgs.password || CONFIG.DIRECTUS_PASSWORD; const token = await getAuthToken(url, email, password); return { content: [ { type: "text", text: JSON.stringify({ access_token: token }, null, 2) } ] }; }
  • Schema definition for the 'login' tool, including name, description, and inputSchema, registered in the ListToolsRequestSchema response.
    name: "login", description: "Login to Directus and get an access token", inputSchema: { type: "object", properties: { url: { type: "string", description: "Directus API URL (default from config)" }, email: { type: "string", description: "User email (default from config)" }, password: { type: "string", description: "User password (default from config)" } }, required: [] }
  • index.ts:266-287 (registration)
    Registration of the 'login' tool in the tools list returned by listTools handler.
    { name: "login", description: "Login to Directus and get an access token", inputSchema: { type: "object", properties: { url: { type: "string", description: "Directus API URL (default from config)" }, email: { type: "string", description: "User email (default from config)" }, password: { type: "string", description: "User password (default from config)" } }, required: [] } },
  • Helper function getAuthToken that performs the HTTP POST to /auth/login endpoint using axios to obtain the access token.
    async function getAuthToken(url: string, email: string, password: string): Promise<string> { try { const response = await axios.post(`${url}/auth/login`, { email, password }); return response.data.data.access_token; } catch (error: any) { throw new Error(`Authentication failed: ${error.message}`); } }

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