create_text_post
Post a text-only update to your LinkedIn feed to share thoughts or updates with your network.
Instructions
Share a simple text update on the user's feed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text content of the post. |
Implementation Reference
- src/tools/content/index.ts:47-63 (handler)The handler function that executes the 'create_text_post' tool logic. It validates the 'text' argument, calls getMyUrn() to get the user's LinkedIn URN, then calls client.createTextPost() to publish the post.
export async function handleContentTool(name: string, args: any, client: LinkedInClient) { switch (name) { case "create_text_post": { if (!args || !args.text) { throw new McpError(ErrorCode.InvalidParams, "text is required"); } const urn = await client.getMyUrn(); const result = await client.createTextPost(urn, args.text); return { content: [ { type: "text", text: `Post created successfully: ${JSON.stringify(result, null, 2)}`, }, ], }; } - src/tools/content/index.ts:4-18 (schema)The tool definition including name, description, and inputSchema for 'create_text_post'. Defines 'text' as a required string parameter.
export const contentTools = [ { name: "create_text_post", description: "Share a simple text update on the user's feed.", inputSchema: { type: "object", properties: { text: { type: "string", description: "The text content of the post.", }, }, required: ["text"], }, }, - src/linkedin-client.ts:48-67 (helper)The LinkedIn client method that actually calls the LinkedIn API to create a text post. Builds the UGC post payload with author, lifecycleState, shareCommentary, and visibility, then POSTs to /ugcPosts.
async createTextPost(authorUrn: string, text: string) { const payload = { author: authorUrn, lifecycleState: "PUBLISHED", specificContent: { "com.linkedin.ugc.ShareContent": { shareCommentary: { text: text, }, shareMediaCategory: "NONE", }, }, visibility: { "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC", }, }; const response = await this.client.post("/ugcPosts", payload); return response.data; } - src/index.ts:46-57 (registration)Registration of the 'create_text_post' tool via MCP server's ListToolsRequestSchema handler, where contentTools (including create_text_post) are spread into the tools array.
// Register tools server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ ...profileTools, ...contentTools, ...networkTools, ...organizationTools, ], }; }); - src/index.ts:58-71 (registration)Routing of the 'create_text_post' tool call to handleContentTool when a CallToolRequest is received with a matching tool name.
// Handle tool execution server.setRequestHandler(CallToolRequestSchema, async (request) => { try { const name = request.params.name; const args = request.params.arguments; if (profileTools.some((t) => t.name === name)) { return await handleProfileTool(name, args, linkedinClient); } if (contentTools.some((t) => t.name === name)) { return await handleContentTool(name, args, linkedinClient); }