Skip to main content
Glama

get_linkedin_post_comments

Retrieve LinkedIn post comments by providing the post URN, with options to sort by relevance or recency and control the number of comments returned.

Instructions

Get LinkedIn comments for a post by URN

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesMax comments to return
sortNoSort type (relevance or recent)relevance
timeoutNoTimeout in seconds
urnYesPost URN, only activity urn type is allowed (example: activity:7234173400267538433)

Implementation Reference

  • Full tool registration and inline handler implementation. Defines input schema with Zod, handles arguments, makes authenticated HTTPS POST request to AnySite API endpoint /api/linkedin/post/comments, returns JSON response or formatted error.
    server.tool(
      "get_linkedin_post_comments",
      "Get LinkedIn post comments",
      {
        urn: z.string().describe("Post URN"),
        count: z.number().default(10).describe("Max comments"),
        timeout: z.number().default(300).describe("Timeout in seconds"),
        sort: z.string().default("relevance").describe("Sort order")
      },
      async ({ urn, count, timeout, sort }) => {
        const requestData = { timeout, urn, sort, count };
        log(`Starting LinkedIn post comments lookup for: ${urn}`);
        try {
          const response = await makeRequest(API_CONFIG.ENDPOINTS.LINKEDIN_POST_COMMENTS, requestData);
          return {
            content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
          };
        } catch (error) {
          log("LinkedIn post comments lookup error:", error);
          return {
            content: [{ type: "text", text: `LinkedIn post comments API error: ${formatError(error)}` }],
            isError: true
          };
        }
      }
    );
  • TypeScript interface defining expected input arguments for the tool, matching the inline Zod schema.
    export interface GetLinkedinPostCommentsArgs {
      urn: string;
      sort?: "relevance" | "recent";
      count?: number;
      timeout?: number;
    }
  • Type guard validation function for tool input arguments, checks urn contains 'activity:', valid sort options, numeric count/timeout.
    export function isValidGetLinkedinPostCommentsArgs(
      args: unknown
    ): args is GetLinkedinPostCommentsArgs {
      if (typeof args !== "object" || args === null) return false;
      const obj = args as Record<string, unknown>;
      if (typeof obj.urn !== "string" || !obj.urn.includes("activity:")) return false;
      if (obj.sort !== undefined && obj.sort !== "relevance" && obj.sort !== "recent") return false;
      if (obj.count !== undefined && typeof obj.count !== "number") return false;
      if (obj.timeout !== undefined && typeof obj.timeout !== "number") return false;
      return true;
    }
  • Shared helper function that performs all API calls to AnySite.io. Handles HTTPS POST requests with authentication (access-token, optional account-id), JSON parsing, and error handling.
    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 configuration object defining base URL and all endpoints. The tool uses API_CONFIG.ENDPOINTS.LINKEDIN_POST_COMMENTS.
    const API_CONFIG = {
      BASE_URL: "https://api.anysite.io",
      ENDPOINTS: {
        SEARCH_USERS: "/api/linkedin/search/users",
        USER_PROFILE: "/api/linkedin/user",
        LINKEDIN_EMAIL: "/api/linkedin/email/user",
        LINKEDIN_USER_POSTS: "/api/linkedin/user/posts",
        LINKEDIN_USER_REACTIONS: "/api/linkedin/user/reactions",
        LINKEDIN_USER_COMMENTS: "/api/linkedin/user/comments",
        LINKEDIN_SEARCH_POSTS: "/api/linkedin/search/posts",
        REDDIT_SEARCH_POSTS: "/api/reddit/search/posts",
        REDDIT_POSTS: "/api/reddit/posts",
        REDDIT_POST_COMMENTS: "/api/reddit/posts/comments",
        CHAT_MESSAGES: "/api/linkedin/management/chat/messages",
        CHAT_MESSAGE: "/api/linkedin/management/chat/message",
        USER_CONNECTION: "/api/linkedin/management/user/connection",
        POST_COMMENT: "/api/linkedin/management/post/comment",
        USER_CONNECTIONS: "/api/linkedin/management/user/connections",
        LINKEDIN_POST_REPOSTS: "/api/linkedin/post/reposts",
        LINKEDIN_POST_COMMENTS: "/api/linkedin/post/comments",
        LINKEDIN_POST_REACTIONS: "/api/linkedin/post/reactions",
        LINKEDIN_GOOGLE_COMPANY: "/api/linkedin/google/company",
        LINKEDIN_COMPANY: "/api/linkedin/company",
        LINKEDIN_COMPANY_EMPLOYEES: "/api/linkedin/company/employees",
        LINKEDIN_COMPANY_POSTS: "/api/linkedin/company/posts",
        LINKEDIN_POST: "/api/linkedin/management/post",
        LINKEDIN_SN_SEARCH_USERS: "/api/linkedin/sn_search/users",
        CONVERSATIONS: "/api/linkedin/management/conversations",
        GOOGLE_SEARCH: "/api/google/search",
        INSTAGRAM_USER: "/api/instagram/user",
        INSTAGRAM_USER_POSTS: "/api/instagram/user/posts",
        INSTAGRAM_POST_COMMENTS: "/api/instagram/post/comments",
        // New LinkedIn endpoints
        LINKEDIN_USER_ENDORSERS: "/api/linkedin/user/endorsers",
        LINKEDIN_USER_CERTIFICATES: "/api/linkedin/user/certificates",
        LINKEDIN_USER_EMAIL_DB: "/api/linkedin/user/email",
        LINKEDIN_MANAGEMENT_ME: "/api/linkedin/management/me",
        // New Instagram endpoints
        INSTAGRAM_POST: "/api/instagram/post",
        INSTAGRAM_POST_LIKES: "/api/instagram/post/likes",
        INSTAGRAM_USER_FRIENDSHIPS: "/api/instagram/user/friendships",
        INSTAGRAM_SEARCH_POSTS: "/api/instagram/search/posts",
        INSTAGRAM_USER_REELS: "/api/instagram/user/reels",
        // Twitter/X endpoints
        TWITTER_USER: "/api/twitter/user",
        TWITTER_SEARCH_USERS: "/api/twitter/search/users",
        TWITTER_USER_POSTS: "/api/twitter/user/posts",
        TWITTER_SEARCH_POSTS: "/api/twitter/search/posts",
        TWITTER_POST: "/api/twitter/post",
        // Web Parser endpoints
        WEBPARSER_PARSE: "/api/webparser/parse",
        WEBPARSER_SITEMAP: "/api/webparser/sitemap"
      }
    };
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool gets comments but lacks behavioral details such as rate limits, authentication requirements, pagination behavior, error handling, or what happens if the URN is invalid. This is a significant gap for a tool that likely interacts with an external API.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

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 no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like API limits or errors, and lacks details on return values (e.g., comment structure, pagination). For a tool with 4 parameters and likely external dependencies, more context is needed 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?

Schema description coverage is 100%, so the schema fully documents all parameters (urn, count, sort, timeout). The description adds no additional parameter semantics beyond the schema, such as explaining URN format constraints or sort behavior 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.

Purpose4/5

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

The description clearly states the action ('Get') and resource ('LinkedIn comments for a post'), specifying it operates on posts identified by URN. It distinguishes from siblings like get_linkedin_post_reactions by focusing on comments rather than reactions, but doesn't explicitly contrast with get_linkedin_user_comments which might retrieve comments made by a user rather than on a post.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention when to prefer this over get_linkedin_user_comments or how it relates to send_linkedin_post_comment. The description only states what it does, not the context for its application.

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