Skip to main content
Glama

get_linkedin_post_reposts

Retrieve LinkedIn post reposts by providing the post URN to track content sharing and engagement metrics across the platform.

Instructions

Get LinkedIn reposts for a post by URN

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesMax reposts to return
timeoutNoTimeout in seconds
urnYesPost URN, only activity urn type is allowed (example: activity:7234173400267538433)

Implementation Reference

  • Registration and inline handler for the 'get_linkedin_post_reposts' tool. Defines schema with Zod, executes API request to retrieve reposts for a given post URN, handles errors, and formats response as text content.
      "get_linkedin_post_reposts",
      "Get LinkedIn post reposts",
      {
        urn: z.string().describe("Post URN"),
        count: z.number().default(10).describe("Max reposts"),
        timeout: z.number().default(300).describe("Timeout in seconds")
      },
      async ({ urn, count, timeout }) => {
        const requestData = { timeout, urn, count };
        log(`Starting LinkedIn post reposts lookup for: ${urn}`);
        try {
          const response = await makeRequest(API_CONFIG.ENDPOINTS.LINKEDIN_POST_REPOSTS, requestData);
          return {
            content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
          };
        } catch (error) {
          log("LinkedIn post reposts lookup error:", error);
          return {
            content: [{ type: "text", text: `LinkedIn post reposts API error: ${formatError(error)}` }],
            isError: true
          };
        }
      }
    );
  • TypeScript interface defining input parameters for get_linkedin_post_reposts tool.
    export interface GetLinkedinPostRepostsArgs {
      urn: string;
      count?: number;
      timeout?: number;
    }
  • Runtime type guard/validator for GetLinkedinPostRepostsArgs input.
    export function isValidGetLinkedinPostRepostsArgs(
      args: unknown
    ): args is GetLinkedinPostRepostsArgs {
      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.count !== undefined && typeof obj.count !== "number") return false;
      if (obj.timeout !== undefined && typeof obj.timeout !== "number") return false;
      return true;
    }
  • API endpoint path used by the get_linkedin_post_reposts handler.
    LINKEDIN_POST_REPOSTS: "/api/linkedin/post/reposts",
  • Shared HTTP request utility function used by all tools including get_linkedin_post_reposts to make authenticated POST requests to the AnySite API.
    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();
      });
    };

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