Skip to main content
Glama
firstorderai

Authenticator App MCP Server

by firstorderai

get_2fa_code

Retrieve the current two-factor authentication (2FA) code for a specific username and website, enabling automated login processes while maintaining security.

Instructions

Retrieve the current 2FA code for a username when logging into a website.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username or email of the account you need to login, e.g. "john.doe@example.com"
websiteYesThe domain name of the website you need to login, e.g. "github.com"

Implementation Reference

  • Core handler function that fetches the 2FA code from the backend API via HTTP request using the access token.
    async get2FACode(website: string, username: string): Promise<Get2FACodeResponse> {
      const url = `${this.baseUrl}/code?website=${encodeURIComponent(website)}&username=${encodeURIComponent(username)}`;
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${this.accessToken}`,
        },
      });
    
      if (!response.ok) {
        const errorBody = await response.text();
        console.error(`HTTP error ${response.status} from ${url}: ${errorBody}`);
        throw new Error(`HTTP error ${response.status}: ${errorBody}`); // Include body in error
      }
      return (await response.json()) as Get2FACodeResponse;
    }
  • src/mcp.ts:26-50 (registration)
    Registers the get_2fa_code tool with the MCP server, including input schema and thin wrapper handler that delegates to Authenticator.get2FACode and formats the MCP response.
    this.tool(
      'get_2fa_code',
      'Retrieve the current 2FA code for a username when logging into a website.',
      {
        website: z
          .string()
          .describe('The domain name of the website you need to login, e.g. "github.com"'),
        username: z
          .string()
          .describe(
            'The username or email of the account you need to login, e.g. "john.doe@example.com"'
          ),
      },
      async ({ website, username }, extra) => {
        const res = await this.authenticator.get2FACode(website, username);
        return {
          content: [
            {
              type: 'text',
              text: `The 2FA code is ${res.code}, it will expire in ${res.valid_for} seconds.`,
            },
          ],
        };
      }
    );
  • Zod schema for the tool inputs: website (string) and username (string) with descriptions.
    {
      website: z
        .string()
        .describe('The domain name of the website you need to login, e.g. "github.com"'),
      username: z
        .string()
        .describe(
          'The username or email of the account you need to login, e.g. "john.doe@example.com"'
        ),
    },
  • TypeScript interfaces defining input parameters and output responses for the authenticator methods, including get2FACode.
    interface Get2FACodeParams {
      website: string;
      username: string;
    }
    
    interface GetPasswordParams {
      website: string;
      username: string;
    }
    
    interface GetAccountListParams {
      website: string;
    }
    
    export interface Get2FACodeResponse {
      code: string;
      valid_for: number;
    }
    
    export interface GetPasswordResponse {
      password: string;
    }
    
    export interface GetAccountListResponse {
      accounts: string[];
    }
Install Server

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/firstorderai/authenticator_mcp'

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