send_linkedin_post
Create and publish LinkedIn posts using your connected account. Specify text content, visibility settings, and comment permissions to share professional updates.
Instructions
Create a post on LinkedIn. Account ID is taken from environment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comment_scope | No | Who can comment on the post | ALL |
| text | Yes | Post text content | |
| timeout | No | Timeout in seconds | |
| visibility | No | Post visibility | ANYONE |
Implementation Reference
- src/index.ts:981-996 (handler)Handler function that prepares request data including account_id and posts to the LinkedIn management post endpoint via makeRequest, returns JSON response or error.async ({ text, visibility, comment_scope, timeout }) => { const requestData = { text, visibility, comment_scope, timeout, account_id: ACCOUNT_ID }; log("Creating LinkedIn post with text:", text.substring(0, 50) + (text.length > 50 ? "..." : "")); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.LINKEDIN_POST, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn post creation error:", error); return { content: [{ type: "text", text: `LinkedIn post creation API error: ${formatError(error)}` }], isError: true }; } }
- src/index.ts:972-997 (registration)MCP server tool registration for 'send_linkedin_post' with description, Zod input schema, and inline handler function.server.tool( "send_linkedin_post", "Create LinkedIn post (requires ACCOUNT_ID)", { text: z.string().describe("Post text"), visibility: z.string().default("ANYONE").describe("Post visibility"), comment_scope: z.string().default("ALL").describe("Comment scope"), timeout: z.number().default(300).describe("Timeout in seconds") }, async ({ text, visibility, comment_scope, timeout }) => { const requestData = { text, visibility, comment_scope, timeout, account_id: ACCOUNT_ID }; log("Creating LinkedIn post with text:", text.substring(0, 50) + (text.length > 50 ? "..." : "")); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.LINKEDIN_POST, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn post creation error:", error); return { content: [{ type: "text", text: `LinkedIn post creation API error: ${formatError(error)}` }], isError: true }; } } );
- src/types.ts:121-126 (schema)TypeScript interface defining input arguments for send_linkedin_post tool, matching the Zod schema.export interface SendLinkedinPostArgs { text: string; visibility?: "ANYONE" | "CONNECTIONS_ONLY"; comment_scope?: "ALL" | "CONNECTIONS_ONLY" | "NONE"; timeout?: number; }
- src/types.ts:647-667 (helper)Type guard function to validate input arguments conform to SendLinkedinPostArgs interface.export function isValidSendLinkedinPostArgs( args: unknown ): args is SendLinkedinPostArgs { 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 (obj.visibility !== undefined && obj.visibility !== "ANYONE" && obj.visibility !== "CONNECTIONS_ONLY") return false; if (obj.comment_scope !== undefined && obj.comment_scope !== "ALL" && obj.comment_scope !== "CONNECTIONS_ONLY" && obj.comment_scope !== "NONE") return false; if (obj.timeout !== undefined && typeof obj.timeout !== "number") return false; return true; }