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",

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