Skip to main content
Glama

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
NameRequiredDescriptionDefault
comment_scopeNoWho can comment on the postALL
textYesPost text content
timeoutNoTimeout in seconds
visibilityNoPost visibilityANYONE

Implementation Reference

  • 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 }; } } );
  • 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; }
  • 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; }

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