Skip to main content
Glama

auth_login

Authenticate to an API, extract a JWT from the response, and store it locally for reuse in subsequent requests.

Instructions

Authenticate against an API, extract a JWT, and store it locally for reuse

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to make the authentication request to
headersNoOptional headers to include in the auth request
bodyNoThe request body for authentication
requestTypeNoRequest type for the auth call
fieldFilesNoArray of field names that should be treated as files for form-data auth requests
jwtPathYesDot-notation path to the JWT in the response (e.g., token.access_token)
folderYesFolder where the token file will be stored
user_titleNoOptional label for the stored token (default: 'default')

Implementation Reference

  • The main handler logic for the auth_login tool. Performs a POST request to the auth URL, extracts the JWT token from the response using the dot-notation jwtPath, validates it, stores it in the specified folder's tokens.json under the user_title, and returns a success message.
    case "auth_login": {
      const url = String(args?.url || '');
      const headers = args?.headers as Record<string, string> || {};
      const body = args?.body;
      const requestType = args?.requestType as 'json' | 'form-data' || 'json';
      const fieldFiles = args?.fieldFiles as string[] || [];
      const jwtPath = String(args?.jwtPath || '');
      const folder = String(args?.folder || '');
      const userTitle = String(args?.user_title || 'default');
    
      if (!url) {
        throw new Error("URL is required for auth_login");
      }
    
      if (!jwtPath) {
        throw new Error("jwtPath is required to extract the token");
      }
    
      if (!folder) {
        throw new Error("folder is required to store the token");
      }
    
      const result = await makeHttpRequest('POST', { url, headers, body, requestType, fieldFiles });
    
      const token = extractValueByPath(result.data, jwtPath);
    
      if (!token || typeof token !== 'string') {
        throw new Error(`Could not find a token at path '${jwtPath}' in the response`);
      }
    
      saveToken(folder, userTitle, token);
    
      return {
        content: [{
          type: "text",
          text: `Stored token for user '${userTitle}' at ${resolveTokenFilePath(folder)}`
        }]
      };
    }
  • src/index.ts:235-282 (registration)
    Registration of the auth_login tool in the listTools handler, including its description and full input schema definition.
    {
      name: "auth_login",
      description: "Authenticate against an API, extract a JWT, and store it locally for reuse",
      inputSchema: {
        type: "object",
        properties: {
          url: {
            type: "string",
            description: "The URL to make the authentication request to"
          },
          headers: {
            type: "object",
            description: "Optional headers to include in the auth request",
            additionalProperties: {
              type: "string"
            }
          },
          body: {
            description: "The request body for authentication"
          },
          requestType: {
            type: "string",
            enum: ["json", "form-data"],
            description: "Request type for the auth call"
          },
          fieldFiles: {
            type: "array",
            items: {
              type: "string"
            },
            description: "Array of field names that should be treated as files for form-data auth requests"
          },
          jwtPath: {
            type: "string",
            description: "Dot-notation path to the JWT in the response (e.g., token.access_token)"
          },
          folder: {
            type: "string",
            description: "Folder where the token file will be stored"
          },
          user_title: {
            type: "string",
            description: "Optional label for the stored token (default: 'default')"
          }
        },
        required: ["url", "jwtPath", "folder"]
      }
    },
  • Helper function called by the auth_login handler to persist the extracted JWT token to tokens.json in the specified folder, creating or updating the user entry.
    function saveToken(folder: string, userTitle: string, token: string) {
      const tokenFile = resolveTokenFilePath(folder);
      mkdirSync(folder, { recursive: true });
    
      const tokens = loadStoredTokens(folder);
      const existingIndex = tokens.findIndex((entry) => entry.user_title_name === userTitle);
    
      if (existingIndex >= 0) {
        tokens[existingIndex].token = token;
      } else {
        tokens.push({ user_title_name: userTitle, token });
      }
    
      writeFileSync(tokenFile, JSON.stringify(tokens, null, 2), 'utf-8');
    }
  • Helper function used by the auth_login handler to extract the JWT token from the API response using dot-notation path (e.g., 'data.token.access_token').
    function extractValueByPath(obj: any, path: string): any {
      return path.split('.').reduce((current, key) => {
        if (current && typeof current === 'object' && key in current) {
          return current[key as keyof typeof current];
        }
        return undefined;
      }, obj);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions authentication, JWT extraction, and local storage, but lacks details on behavioral traits such as error handling, security implications (e.g., token expiration), rate limits, or side effects (e.g., overwriting existing tokens). For a critical auth tool, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality without unnecessary words. It directly states the tool's actions (authenticate, extract, store) and purpose (for reuse), making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, no output schema, and no annotations), the description is insufficient. It does not cover critical aspects like return values (e.g., success/failure indicators), error scenarios, or security best practices, leaving gaps for an AI agent to operate safely and effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly. The description does not add any additional meaning or context beyond what the schema provides (e.g., explaining why 'jwtPath' or 'folder' are needed). Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Authenticate against an API, extract a JWT, and store it locally for reuse.' It specifies the verb (authenticate) and resource (API/JWT), but does not explicitly differentiate it from sibling tools like 'post' or 'get', which might also involve API interactions. This makes it clear but not fully sibling-distinctive.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing credentials), exclusions (e.g., not for non-JWT auth), or compare it to sibling tools like 'post' for general API calls. This lack of context leaves usage ambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/vilasone455/api-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server