fetch_post
Retrieve LinkedIn post data including content, with options to fetch comments and reactions for analysis.
Instructions
Open a LinkedIn post and retrieve its data, with optional comments and reactions. (st.openPost action).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| postUrl | Yes | LinkedIn URL of the post. (e.g., 'https://www.linkedin.com/posts/username_activity-id') | |
| retrieveComments | No | Optional. When true, also retrieve comments for the post. Configure via commentsRetrievalConfig. | |
| retrieveReactions | No | Optional. When true, also retrieve reactions for the post. Configure via reactionsRetrievalConfig. | |
| commentsRetrievalConfig | No | Optional. Applies only when retrieveComments is true. Controls comments retrieval (limit, replies, sort). | |
| reactionsRetrievalConfig | No | Optional. Applies only when retrieveReactions is true. Controls reactions retrieval (limit). |
Implementation Reference
- src/tools/fetch-post.ts:7-90 (handler)The FetchPostTool class implements the 'fetch_post' tool. It extends OperationTool, sets the tool name to 'fetch_post', maps to the specific LinkedIn API operation, defines the Zod input schema for validation, and provides the MCP Tool definition including JSON inputSchema and description.export class FetchPostTool extends OperationTool<TFetchPostParams, unknown> { public override readonly name = 'fetch_post'; public override readonly operationName = OPERATION_NAME.fetchPost; protected override readonly schema = z.object({ postUrl: z.string(), retrieveComments: z.boolean().optional(), retrieveReactions: z.boolean().optional(), commentsRetrievalConfig: z .object({ limit: z.number().min(1).max(500).optional(), replies: z.boolean().optional(), sort: z.enum(['mostRelevant', 'mostRecent']).optional(), }) .optional(), reactionsRetrievalConfig: z .object({ limit: z.number().min(1).max(1000).optional(), }) .optional(), }); public override getTool(): Tool { return { name: this.name, description: 'Open a LinkedIn post and retrieve its data, with optional comments and reactions. (st.openPost action).', inputSchema: { type: 'object', properties: { postUrl: { type: 'string', description: "LinkedIn URL of the post. (e.g., 'https://www.linkedin.com/posts/username_activity-id')", }, retrieveComments: { type: 'boolean', description: 'Optional. When true, also retrieve comments for the post. Configure via commentsRetrievalConfig.', }, retrieveReactions: { type: 'boolean', description: 'Optional. When true, also retrieve reactions for the post. Configure via reactionsRetrievalConfig.', }, commentsRetrievalConfig: { type: 'object', description: 'Optional. Applies only when retrieveComments is true. Controls comments retrieval (limit, replies, sort).', properties: { limit: { type: 'number', description: 'Optional. Max number of comments to retrieve. Defaults to 10, with a maximum value of 500.', }, replies: { type: 'boolean', description: 'Optional. When true, include replies to comments (threaded).', }, sort: { type: 'string', enum: ['mostRelevant', 'mostRecent'], description: "Optional. Sort order for comments. One of 'mostRelevant' or 'mostRecent'.", }, }, }, reactionsRetrievalConfig: { type: 'object', description: 'Optional. Applies only when retrieveReactions is true. Controls reactions retrieval (limit).', properties: { limit: { type: 'number', description: 'Optional. Max number of reactions to retrieve. Defaults to 10, with a maximum value of 1000.', }, }, }, }, required: ['postUrl'], }, }; } }
- src/tools/fetch-post.ts:10-26 (schema)Zod schema for validating the input parameters of the fetch_post tool.protected override readonly schema = z.object({ postUrl: z.string(), retrieveComments: z.boolean().optional(), retrieveReactions: z.boolean().optional(), commentsRetrievalConfig: z .object({ limit: z.number().min(1).max(500).optional(), replies: z.boolean().optional(), sort: z.enum(['mostRelevant', 'mostRecent']).optional(), }) .optional(), reactionsRetrievalConfig: z .object({ limit: z.number().min(1).max(1000).optional(), }) .optional(), });
- src/linked-api-tools.ts:48-49 (registration)FetchPostTool is imported and instantiated as part of the LinkedApiTools collection, which aggregates all LinkedIn API tools.new FetchPersonTool(progressCallback), new FetchPostTool(progressCallback),
- src/utils/linked-api-tool.ts:36-58 (helper)Base OperationTool class that provides the core execution logic for operation-based tools like fetch_post. It locates the corresponding LinkedIn API operation by name and executes 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, }); } }
- src/linked-api-server.ts:22-24 (registration)LinkedApiMCPServer exposes the tools from LinkedApiTools as MCP Tools via getTools(), effectively registering fetch_post for the MCP server.public getTools(): Tool[] { return this.tools.tools.map((tool) => tool.getTool()); }