Skip to main content
Glama

auth_login

Authenticate with Magento Admin credentials to establish a secure session for managing store operations.

Instructions

Authenticate with Magento Admin credentials and establish a session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNoAction parameters as a JSON object

Implementation Reference

  • The 'auth.login' action definition containing the handler logic. It validates input via AuthLoginSchema, supports three auth methods (OAuth 1.0, integration bearer token, username/password), and creates a session via the SessionStore.
    name: 'auth.login',
    description: 'Authenticate with Magento Admin credentials and establish a session.',
    riskTier: RiskTier.Safe,
    requiresAuth: false,
    handler: async (params: Record<string, unknown>, context: ActionContext) => {
      const validated = AuthLoginSchema.parse(params);
    
      const base_url = validated.base_url || process.env.MAGENTO_BASE_URL;
      if (!base_url) {
        return { error: { code: 'VALIDATION_ERROR', message: 'base_url is required — pass it in params or set MAGENTO_BASE_URL env var' } };
      }
    
      // Check for OAuth 1.0 integration credentials first (bypasses 2FA)
      const oauthConsumerKey = (params['oauth_consumer_key'] as string) || process.env.MAGENTO_OAUTH_CONSUMER_KEY;
      const oauthConsumerSecret = (params['oauth_consumer_secret'] as string) || process.env.MAGENTO_OAUTH_CONSUMER_SECRET;
      const oauthToken = (params['oauth_token'] as string) || process.env.MAGENTO_OAUTH_TOKEN;
      const oauthTokenSecret = (params['oauth_token_secret'] as string) || process.env.MAGENTO_OAUTH_TOKEN_SECRET;
    
      if (oauthConsumerKey && oauthConsumerSecret && oauthToken && oauthTokenSecret) {
        const oauthCreds: OAuthCredentials = {
          consumerKey: oauthConsumerKey,
          consumerSecret: oauthConsumerSecret,
          token: oauthToken,
          tokenSecret: oauthTokenSecret,
        };
        const username = validated.username || process.env.MAGENTO_ADMIN_USERNAME || 'integration';
        sessionStore.createOAuth(context.sessionId, base_url, oauthCreds, username);
        return {
          message: 'Login successful (OAuth 1.0 integration)',
          username: username,
          base_url: base_url,
          auth_method: 'oauth',
        };
      }
    
      // Check for integration bearer token (bypasses 2FA)
      const integrationToken = (params['integration_token'] as string) || process.env.MAGENTO_INTEGRATION_TOKEN;
      if (integrationToken) {
        const username = validated.username || process.env.MAGENTO_ADMIN_USERNAME || 'integration';
        sessionStore.create(context.sessionId, base_url, integrationToken, username);
        return {
          message: 'Login successful (integration token)',
          username: username,
          base_url: base_url,
          auth_method: 'integration_token',
        };
      }
    
      // Fall back to username/password login
      const username = validated.username || process.env.MAGENTO_ADMIN_USERNAME;
      if (!username) {
        return { error: { code: 'VALIDATION_ERROR', message: 'username is required — pass it in params or set MAGENTO_ADMIN_USERNAME env var' } };
      }
    
      const password = validated.password || process.env.MAGENTO_ADMIN_PASSWORD;
      if (!password) {
        return { error: { code: 'VALIDATION_ERROR', message: 'password is required — pass it in params or set MAGENTO_ADMIN_PASSWORD env var' } };
      }
    
      const client = new MagentoRestClient(base_url);
      const token = await client.getAdminToken(username, password);
    
      sessionStore.create(context.sessionId, base_url, token, username);
    
      return {
        message: 'Login successful',
        username: username,
        base_url: base_url,
        auth_method: 'admin_token',
      };
    },
  • Zod validation schema for auth_login input parameters: base_url (optional URL), username (optional string), password (optional string).
    export const AuthLoginSchema = z.object({
      base_url: z.string().url('base_url must be a valid URL').optional(),
      username: z.string().min(1).optional(),
      password: z.string().min(1).optional(),
    });
  • src/index.ts:76-82 (registration)
    Registration of the tool: dots are converted to underscores (auth.login -> auth_login) when registering with the MCP SDK server via mcpServer.tool().
    for (const action of allActions) {
      // Convert dots to underscores for MCP tool names (e.g. "auth.login" -> "auth_login")
      const toolName = action.name.replace(/\./g, '_');
    
      mcpServer.tool(
        toolName,
        action.description,
  • src/index.ts:51-53 (registration)
    Actions are collected from createAuthActions(sessionStore) into the allActions array, which is then iterated to register each tool.
    const allActions: ActionDefinition[] = [
      ...createAuthActions(sessionStore),
      ...createScopeActions(sessionStore),
  • Factory function createAuthActions that returns the action definition array including auth.login.
    export function createAuthActions(sessionStore: SessionStore): ActionDefinition[] {
      return [
        {
          name: 'auth.login',
          description: 'Authenticate with Magento Admin credentials and establish a session.',
          riskTier: RiskTier.Safe,
          requiresAuth: false,
          handler: async (params: Record<string, unknown>, context: ActionContext) => {
            const validated = AuthLoginSchema.parse(params);
    
            const base_url = validated.base_url || process.env.MAGENTO_BASE_URL;
            if (!base_url) {
              return { error: { code: 'VALIDATION_ERROR', message: 'base_url is required — pass it in params or set MAGENTO_BASE_URL env var' } };
            }
    
            // Check for OAuth 1.0 integration credentials first (bypasses 2FA)
            const oauthConsumerKey = (params['oauth_consumer_key'] as string) || process.env.MAGENTO_OAUTH_CONSUMER_KEY;
            const oauthConsumerSecret = (params['oauth_consumer_secret'] as string) || process.env.MAGENTO_OAUTH_CONSUMER_SECRET;
            const oauthToken = (params['oauth_token'] as string) || process.env.MAGENTO_OAUTH_TOKEN;
            const oauthTokenSecret = (params['oauth_token_secret'] as string) || process.env.MAGENTO_OAUTH_TOKEN_SECRET;
    
            if (oauthConsumerKey && oauthConsumerSecret && oauthToken && oauthTokenSecret) {
              const oauthCreds: OAuthCredentials = {
                consumerKey: oauthConsumerKey,
                consumerSecret: oauthConsumerSecret,
                token: oauthToken,
                tokenSecret: oauthTokenSecret,
              };
              const username = validated.username || process.env.MAGENTO_ADMIN_USERNAME || 'integration';
              sessionStore.createOAuth(context.sessionId, base_url, oauthCreds, username);
Behavior2/5

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

No annotations provided, so description carries full burden. Only mentions 'authenticate' and 'establish a session' without details on permissions, existing session handling, or rate limits. Minimal disclosure.

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

Conciseness4/5

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

Single sentence with no unnecessary words. Could be improved by adding more context without becoming verbose.

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?

No output schema, no annotations, and parameters are undefined. Description lacks crucial details like credential format, error responses, or prerequisites, making it incomplete for a login tool.

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

Parameters2/5

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

Input schema has one generic 'params' object with no defined properties. Description adds no meaning beyond the schema, leaving required credentials or fields unspecified.

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

Purpose5/5

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

Description clearly states the verb 'Authenticate' with resource 'Magento Admin credentials' and outcome 'establish a session'. Distinguishes from siblings like auth_logout and auth_whoami.

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

Usage Guidelines4/5

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

Explicitly says when to use (to authenticate), but does not provide when-not-to or alternatives. Still clear context for use.

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/thomastx05/magento-mcp'

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