create_post
Create LinkedIn posts with text and optional media attachments for personal profiles or company pages using the Linked API MCP server.
Instructions
Creates a new LinkedIn post with optional media attachments (st.createPost action).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Post content, must be up to 3000 characters. | |
| companyUrl | No | LinkedIn company page URL. If specified, the post will be created on the company page (requires admin access). | |
| attachments | No | Media attachments for the post. You can add up to 9 images, or 1 video, or 1 document. Cannot mix different attachment types. |
Implementation Reference
- src/tools/create-post.ts:7-71 (handler)The CreatePostTool class that implements the 'create_post' tool. It extends OperationTool, sets the tool name to 'create_post', defines the Zod input schema for validation, provides the MCP tool definition via getTool(), and uses the 'createPost' operation from LinkedAPI.export class CreatePostTool extends OperationTool<TCreatePostParams, unknown> { public override readonly name = 'create_post'; public override readonly operationName = OPERATION_NAME.createPost; protected override readonly schema = z.object({ text: z.string().min(1).max(3000), companyUrl: z.string().optional(), attachments: z .array( z.object({ url: z.string(), type: z.enum(['image', 'video', 'document']), name: z.string().optional(), }), ) .max(9) .optional(), }); public override getTool(): Tool { return { name: this.name, description: 'Creates a new LinkedIn post with optional media attachments (st.createPost action).', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Post content, must be up to 3000 characters.', }, companyUrl: { type: 'string', description: 'LinkedIn company page URL. If specified, the post will be created on the company page (requires admin access).', }, attachments: { type: 'array', description: 'Media attachments for the post. You can add up to 9 images, or 1 video, or 1 document. Cannot mix different attachment types.', items: { type: 'object', properties: { url: { type: 'string', description: 'Publicly accessible URL of the media file.', }, type: { type: 'string', enum: ['image', 'video', 'document'], description: 'Type of media attachment.', }, name: { type: 'string', description: 'Display name for the document (required for documents).', }, }, required: ['url', 'type'], }, }, }, required: ['text'], }, }; } }
- src/tools/create-post.ts:10-23 (schema)Zod schema definition for validating the input parameters of the create_post tool: text (required), companyUrl (optional), attachments (optional array).protected override readonly schema = z.object({ text: z.string().min(1).max(3000), companyUrl: z.string().optional(), attachments: z .array( z.object({ url: z.string(), type: z.enum(['image', 'video', 'document']), name: z.string().optional(), }), ) .max(9) .optional(), });
- src/linked-api-tools.ts:52-52 (registration)The CreatePostTool is instantiated with a progress callback and added to the array of tools in the LinkedApiTools constructor.new CreatePostTool(progressCallback),
- src/linked-api-tools.ts:3-3 (registration)Import of CreatePostTool from './tools/create-post.js'.import { CreatePostTool } from './tools/create-post.js';
- src/utils/linked-api-tool.ts:36-58 (helper)The execute method in OperationTool base class, which performs the actual tool execution by finding the operation by operationName and calling it with progress tracking.export abstract class OperationTool<TParams, TResult> extends LinkedApiTool<TParams, TResult> { public abstract readonly operationName: TOperationName; public override execute({ linkedapi, args, workflowTimeout, progressToken, }: { linkedapi: LinkedApi; args: TParams; workflowTimeout: number; progressToken?: string | number; }): Promise<TMappedResponse<TResult>> { const operation = linkedapi.operations.find( (operation) => operation.operationName === this.operationName, )! as Operation<TParams, TResult>; return executeWithProgress(this.progressCallback, operation, workflowTimeout, { params: args, progressToken, }); } }