Skip to main content
Glama

instagram_complete_2fa

Complete Instagram login by entering the 2FA verification code received via SMS or authenticator app after initial login requires verification.

Instructions

Complete Instagram login by providing the 2FA verification code. Use this after 'instagram_login' indicates 2FA is required.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verification_codeYesThe 2FA verification code received via SMS or from your authenticator app

Implementation Reference

  • The `execute` method in `Complete2FATool` class performs the core logic: validates the 2FA code, checks for pending login, calls `igpapiClient.completeTwoFactorLogin`, confirms with user info, and returns success message or handles errors.
    async execute(args: { verification_code: string }): Promise<ToolResult> {
      const { verification_code } = args;
    
      // Validate input
      if (!verification_code || verification_code.trim().length === 0) {
        throw new Error("Verification code is required");
      }
    
      // Check if there's a pending 2FA login
      if (!igpapiClient.hasPendingTwoFactor()) {
        throw new Error(
          "No pending 2FA login found. Please call 'instagram_login' first to initiate the login process."
        );
      }
    
      const twoFactorInfo = igpapiClient.getTwoFactorInfo();
      if (!twoFactorInfo) {
        throw new Error("2FA information not available. Please try logging in again.");
      }
    
      try {
        // Complete 2FA login
        await igpapiClient.completeTwoFactorLogin(verification_code.trim());
    
        // Get user info to confirm login
        const user = await igpapiClient.getCurrentUser();
    
        const methodName = twoFactorInfo.verificationMethod === "1" ? "SMS" : "TOTP";
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully completed 2FA login to Instagram!\n\nAccount: ${user.username}\nFull Name: ${user.full_name || "N/A"}\nUser ID: ${user.pk}\n2FA Method: ${methodName}\n\nSession has been saved and will persist across server restarts.`,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        
        // Check for common 2FA errors
        if (errorMessage.includes("code") || errorMessage.includes("verification")) {
          throw new Error(
            `Invalid verification code. Please check the code and try again. If the code expired, please call 'instagram_login' again to receive a new code.`
          );
        }
    
        throw error;
      }
    }
  • The `getDefinition` method defines the tool's name, description, and input schema requiring 'verification_code' string.
    getDefinition(): ToolDefinition {
      return {
        name: "instagram_complete_2fa",
        description: "Complete Instagram login by providing the 2FA verification code. Use this after 'instagram_login' indicates 2FA is required.",
        inputSchema: {
          type: "object",
          properties: {
            verification_code: {
              type: "string",
              description: "The 2FA verification code received via SMS or from your authenticator app",
            },
          },
          required: ["verification_code"],
        },
      };
    }
  • Instantiation of Complete2FATool and inclusion in the `tools` array used by `getAllToolDefinitions()` and `executeTool()`.
    const tools: BaseTool[] = [
      new LoginTool(),
      new Complete2FATool(),
      new SearchAccountsTool(),
      new LogoutTool(),
      new GetUserProfileTool(),
      new GetCurrentUserProfileTool(),
      new GetUserPostsTool(),
      new LikePostTool(),
      new LikeCommentTool(),
      new CommentOnPostTool(),
      new GetPostCommentsTool(),
      new GetPostDetailsTool(),
      new GetUserStoriesTool(),
      new GetTimelineFeedTool(),
      new FollowUserTool(),
      // Add more tools here as you create them
    ];
  • src/server.ts:59-69 (registration)
    MCP server handler for listing tools, which includes 'instagram_complete_2fa' via `getAllToolDefinitions()`.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      const toolDefinitions = getAllToolDefinitions();
      
      return {
        tools: toolDefinitions.map((def) => ({
          name: def.name,
          description: def.description,
          inputSchema: def.inputSchema,
        })),
      };
    });
  • src/server.ts:71-80 (registration)
    MCP server handler for calling tools by name, executing 'instagram_complete_2fa' via `executeTool()`.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      const result = await executeTool(name, args || {});
    
      return {
        content: result.content,
        isError: result.isError,
      };
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly indicates this is part of a login flow and has a dependency on another tool, which is valuable context. However, it doesn't describe what happens after successful 2FA completion (e.g., session establishment, error handling for invalid codes, or rate limiting considerations), leaving some behavioral aspects unspecified.

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 perfectly concise with two sentences that each serve a distinct purpose: the first states what the tool does, and the second provides essential usage guidance. There's no wasted language, and the information is front-loaded with the core purpose immediately clear.

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

Completeness4/5

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

For a single-parameter tool with full schema coverage but no annotations or output schema, the description provides good contextual completeness. It establishes the tool's role in the authentication workflow and its dependency on another tool. The main gap is the lack of information about what happens after successful 2FA completion, but given the tool's focused purpose, the description is reasonably complete.

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?

With 100% schema description coverage, the input schema already fully documents the single parameter. The description doesn't add any additional parameter semantics beyond what's in the schema, so it meets the baseline expectation but doesn't provide extra value. The description focuses on tool usage rather than parameter details.

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?

The description clearly states the specific action ('complete Instagram login by providing the 2FA verification code') and resource ('Instagram login'), and explicitly distinguishes it from its sibling 'instagram_login' by indicating it should be used after that tool shows 2FA is required. This provides precise differentiation from other authentication-related tools.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('after "instagram_login" indicates 2FA is required'), creating a clear dependency relationship. It also implicitly suggests when not to use it (when 2FA hasn't been triggered), though it doesn't name alternative tools for other authentication scenarios, which is appropriate given the specific 2FA context.

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/anand-kamble/mcp-instagram'

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