Skip to main content
Glama

fetch_post

Retrieve detailed data from a LinkedIn post using its URL. Integrates with Linked API MCP to enable AI assistants to analyze and utilize post information automatically.

Instructions

This action allows you to open a post to retrieve its data. (st.openPost action).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
postUrlYesLinkedIn URL of the post. (e.g., 'https://www.linkedin.com/posts/username_activity-id')

Implementation Reference

  • The FetchPostTool class provides the implementation of the 'fetch_post' tool. It extends OperationTool, sets the tool name, maps to the specific LinkedIn API operation, defines the Zod input schema for validation, and provides the MCP Tool object with JSON schema 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'], }, }; } }
  • Instantiates the FetchPostTool and adds it to the array of tools managed by LinkedApiTools class.
    new FetchPostTool(progressCallback),
  • The LinkedApiMCPServer class instantiates LinkedApiTools (which includes fetch_post) and exposes the tools via getTools() for MCP registration, and handles tool execution.
    private tools: LinkedApiTools; constructor(progressCallback: (notification: LinkedApiProgressNotification) => void) { this.tools = new LinkedApiTools(progressCallback); } public getTools(): Tool[] { return this.tools.tools.map((tool) => tool.getTool()); }
  • The OperationTool base class implements the execute method used by fetch_post tool, which locates the corresponding LinkedIn API operation by operationName 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, }); } }
  • Zod schema defining the input parameters and validation rules for 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(), });

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/Linked-API/linkedapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server