Skip to main content
Glama

instagram_like_comment

Like Instagram comments using comment IDs through authenticated API integration. This tool enables interaction with Instagram features via the MCP server protocol.

Instructions

Like an Instagram comment by comment ID. Requires authentication.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commentIdYesComment ID to like

Implementation Reference

  • The execute method implements the core logic for liking an Instagram comment. It validates input, checks authentication, initializes the client if needed, calls client.media.likeComment, and handles various errors like auth issues, not found, rate limits, and already liked cases.
    async execute(args: { commentId: string }): Promise<ToolResult> {
      const { commentId } = args;
    
      // Validate commentId
      if (typeof commentId !== "string") {
        throw new Error("commentId is required and must be a string");
      }
    
      const commentIdTrimmed = commentId.trim();
      if (commentIdTrimmed.length === 0) {
        throw new Error("commentId cannot be empty");
      }
    
      // Check if logged in
      if (!igpapiClient.isLoggedIn()) {
        throw new Error("Not logged in. Please use the instagram_login tool to authenticate first.");
      }
    
      // Ensure client is initialized
      if (!igpapiClient.isInitialized()) {
        await igpapiClient.initialize();
      }
    
      const client = igpapiClient.getClient();
    
      try {
        // Call the API to like the comment
        await client.media.likeComment(commentIdTrimmed);
    
        // Format success response
        const response = `Successfully liked comment with ID: ${commentIdTrimmed}`;
    
        return {
          content: [
            {
              type: "text",
              text: response,
            },
          ],
        };
      } catch (error: any) {
        // Handle specific error cases
        if (error?.message) {
          const errorMessage = error.message.toLowerCase();
    
          // Authentication errors
          if (
            errorMessage.includes("not logged in") ||
            errorMessage.includes("login") ||
            errorMessage.includes("authentication") ||
            errorMessage.includes("unauthorized") ||
            error?.response?.status === 401
          ) {
            throw new Error("Authentication required. Please use the instagram_login tool to authenticate first.");
          }
    
          // Session expired
          if (
            errorMessage.includes("session") ||
            errorMessage.includes("expired") ||
            errorMessage.includes("invalid")
          ) {
            throw new Error("Session has expired. Please use the instagram_login tool to re-authenticate.");
          }
    
          // Comment not found
          if (
            errorMessage.includes("not found") ||
            errorMessage.includes("invalid comment") ||
            errorMessage.includes("comment not found") ||
            error?.response?.status === 404
          ) {
            throw new Error(`Comment not found with ID "${commentIdTrimmed}". Please verify the comment ID is correct.`);
          }
    
          // Rate limiting
          if (
            errorMessage.includes("rate limit") ||
            errorMessage.includes("too many requests") ||
            error?.response?.status === 429
          ) {
            throw new Error("Rate limit exceeded. Please wait before trying again.");
          }
    
          // Already liked (Instagram API may return success, but handle if it throws)
          if (errorMessage.includes("already liked") || errorMessage.includes("duplicate")) {
            return {
              content: [
                {
                  type: "text",
                  text: `Comment with ID "${commentIdTrimmed}" is already liked.`,
                },
              ],
            };
          }
        }
    
        // Re-throw other errors to be handled by base error handling
        throw error;
      }
    }
  • The getDefinition method provides the tool's name, description, and input schema defining the required 'commentId' string parameter.
    getDefinition(): ToolDefinition {
      return {
        name: "instagram_like_comment",
        description: "Like an Instagram comment by comment ID. Requires authentication.",
        inputSchema: {
          type: "object",
          properties: {
            commentId: {
              type: "string",
              description: "Comment ID to like",
            },
          },
          required: ["commentId"],
        },
      };
    }
  • Central tools registry array where LikeCommentTool is instantiated (line 34) and all tools are collected for registration via getAllToolDefinitions().
    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
    ];
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 of behavioral disclosure. It states the action ('Like') and an authentication requirement, but it lacks details on potential side effects (e.g., whether liking is reversible, rate limits, error conditions, or what happens on success). For a mutation tool with zero annotation coverage, this is insufficient.

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 extremely concise—two short sentences that directly state the purpose and a key requirement. Every word earns its place, with no redundant or unnecessary information, making it front-loaded and efficient.

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 (a mutation action with authentication needs) and the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns, error handling, or behavioral nuances, leaving significant gaps for an AI agent to understand how to use it 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?

The schema description coverage is 100%, with the parameter 'commentId' fully documented in the schema as 'Comment ID to like'. The description does not add any additional meaning or context beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate.

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 ('Like an Instagram comment') and identifies the target resource ('by comment ID'), which distinguishes it from sibling tools like 'instagram_like_post' that target posts instead of comments. The verb+resource combination is precise and unambiguous.

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 mentions 'Requires authentication' as a prerequisite, which provides some context, but it does not explicitly guide when to use this tool versus alternatives. For example, it does not clarify when to like a comment versus liking a post or commenting on a post, nor does it specify any exclusions or typical use cases.

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