Skip to main content
Glama

send_linkedin_post_comment

Post comments on LinkedIn posts and replies to engage with content using your LinkedIn account. Add your perspective to discussions and interact with professional content.

Instructions

Create a comment on a LinkedIn post or on another comment. Account ID is taken from environment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesComment text
timeoutNoTimeout in seconds
urnYesURN of the activity or comment to comment on (e.g., 'activity:123' or 'comment:(activity:123,456)')

Implementation Reference

  • Primary implementation: server.tool registration including Zod input schema, description, and async handler function. Validates post URN format, constructs request with account_id, calls API endpoint to send comment, returns response or error.
      "send_linkedin_post_comment",
      "Comment on LinkedIn post (requires ACCOUNT_ID)",
      {
        post: z.string().describe("Post URN (activity: or comment:)"),
        text: z.string().describe("Comment text"),
        timeout: z.number().default(300).describe("Timeout in seconds")
      },
      async ({ post, text, timeout }) => {
        const isActivityOrComment = post.includes("activity:") || post.includes("comment:");
        if (!isActivityOrComment) {
          return {
            content: [{ type: "text", text: "URN must be for an activity or comment" }],
            isError: true
          };
        }
        let urnObj;
        if (post.startsWith("activity:")) {
          urnObj = { type: "activity", value: post.replace("activity:", "") };
        } else if (post.startsWith("comment:")) {
          urnObj = { type: "comment", value: post.replace("comment:", "") };
        } else {
          urnObj = post;
        }
        const requestData = { timeout, text, urn: urnObj, account_id: ACCOUNT_ID };
        log(`Creating LinkedIn comment on ${post}`);
        try {
          const response = await makeRequest(API_CONFIG.ENDPOINTS.POST_COMMENT, requestData);
          return {
            content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
          };
        } catch (error) {
          log("LinkedIn comment creation error:", error);
          return {
            content: [{ type: "text", text: `LinkedIn comment API error: ${formatError(error)}` }],
            isError: true
          };
        }
      }
    );
  • TypeScript type definition for the tool input arguments (note: 'urn' vs 'post' in handler).
    export interface SendLinkedinPostCommentArgs {
      text: string;
      urn: string;
      timeout?: number;
    }
  • Type guard function for validating SendLinkedinPostCommentArgs input (TypeScript runtime checks).
    export function isValidSendLinkedinPostCommentArgs(
      args: unknown
    ): args is SendLinkedinPostCommentArgs {
      if (typeof args !== "object" || args === null) return false;
      const obj = args as Record<string, unknown>;
      if (typeof obj.text !== "string" || !obj.text.trim()) return false;
      if (typeof obj.urn !== "string" || !obj.urn.trim()) return false;
      if (obj.timeout !== undefined && typeof obj.timeout !== "number") return false;
      return true;
    }
  • Shared HTTP request helper function used by the handler to POST to the AnySite API endpoints with authentication.
    const makeRequest = (endpoint: string, data: any, method: string = "POST"): Promise<any> => {
      return new Promise((resolve, reject) => {
        const url = new URL(endpoint, API_CONFIG.BASE_URL);
        const postData = JSON.stringify(data);
    
        const options = {
          hostname: url.hostname,
          port: url.port || 443,
          path: url.pathname,
          method: method,
          headers: {
            "Content-Type": "application/json",
            "Content-Length": Buffer.byteLength(postData),
            "access-token": API_KEY,
            ...(ACCOUNT_ID && { "x-account-id": ACCOUNT_ID })
          }
        };
    
        const req = https.request(options, (res) => {
          let responseData = "";
          res.on("data", (chunk) => {
            responseData += chunk;
          });
    
          res.on("end", () => {
            try {
              const parsed = JSON.parse(responseData);
              if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
                resolve(parsed);
              } else {
                reject(new Error(`API error ${res.statusCode}: ${JSON.stringify(parsed)}`));
              }
            } catch (e) {
              reject(new Error(`Failed to parse response: ${responseData}`));
            }
          });
        });
    
        req.on("error", (error) => {
          reject(error);
        });
    
        req.write(postData);
        req.end();
      });
    };
  • API endpoint constant used in the request: POST /api/linkedin/management/post/comment/
    POST_COMMENT: "/api/linkedin/management/post/comment",
Behavior2/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 mentions that 'Account ID is taken from the environment', which adds some context about authentication. However, it lacks details on permissions, rate limits, error handling, or what happens after creation (e.g., response format). 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.

Conciseness4/5

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

The description is concise and front-loaded with the core purpose. Both sentences earn their place: the first defines the action and target, and the second clarifies authentication. There is no wasted text, though it could be slightly more 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 complexity of a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., side effects, error cases), usage guidelines, and return values. The authentication note helps but does not compensate for the overall gaps.

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 parameters (text, timeout, urn). The description adds no additional meaning beyond what the schema provides, such as explaining URN formats or timeout implications. Baseline 3 is appropriate when the schema does the heavy lifting.

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 ('Create a comment') and the target resources ('on a LinkedIn post or on another comment'), distinguishing it from sibling tools like send_linkedin_post (which creates posts) or send_linkedin_chat_message (which sends messages). It also specifies that the Account ID is taken from the environment, adding operational context.

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 when to comment on a post versus a comment, nor does it differentiate from other LinkedIn interaction tools like send_linkedin_post or send_linkedin_chat_message. Usage is implied but not explicitly stated.

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/anysiteio/hdw-mcp-server'

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