Skip to main content
Glama
Jing-yilin

LinkedIn MCP Server

by Jing-yilin

get_post_comments

Retrieve and organize comments from LinkedIn posts using HarvestAPI, with options to sort by relevance or date, paginate results, and save cleaned JSON data.

Instructions

Get comments on a LinkedIn post. Returns cleaned data in TOON format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
postYesLinkedIn post URL (required)
sortByNoSort by: relevance or date
pageNoPage number
paginationTokenNoPagination token
save_dirNoDirectory to save cleaned JSON data
max_itemsNoMaximum comments (default: 10)

Implementation Reference

  • The handler function for the get_post_comments tool. It constructs API parameters from input args, calls the HarvestAPI endpoint '/post-comments', cleans the response data using DataCleaners.cleanComment, limits the number of items, and returns a formatted TOON-encoded response with optional saving to file and pagination info.
    private async getPostComments(args: Record<string, any>): Promise<CallToolResult> { const params: Record<string, any> = { post: args.post }; if (args.sortBy) params.sortBy = args.sortBy; if (args.page) params.page = args.page; if (args.paginationToken) params.paginationToken = args.paginationToken; const data = await this.makeRequest('/post-comments', params); const maxItems = args.max_items || 10; const cleaned = (data.elements || []).slice(0, maxItems).map(DataCleaners.cleanComment); return this.formatResponse(cleaned, { saveDir: args.save_dir, toolName: 'get_post_comments', pagination: data.pagination, }); }
  • The input schema for the get_post_comments tool, defining the expected parameters: required 'post' URL, optional sortBy, page, paginationToken, save_dir, and max_items.
    inputSchema: { type: 'object', properties: { post: { type: 'string', description: 'LinkedIn post URL (required)' }, sortBy: { type: 'string', description: 'Sort by: relevance or date', enum: ['relevance', 'date'] }, page: { type: 'integer', description: 'Page number', default: 1 }, paginationToken: { type: 'string', description: 'Pagination token' }, save_dir: { type: 'string', description: 'Directory to save cleaned JSON data' }, max_items: { type: 'integer', description: 'Maximum comments (default: 10)', default: 10 }, }, required: ['post'], },
  • src/index.ts:454-469 (registration)
    Registration of the get_post_comments tool in the tools list returned by ListToolsRequestSchema handler.
    { name: 'get_post_comments', description: 'Get comments on a LinkedIn post. Returns cleaned data in TOON format.', inputSchema: { type: 'object', properties: { post: { type: 'string', description: 'LinkedIn post URL (required)' }, sortBy: { type: 'string', description: 'Sort by: relevance or date', enum: ['relevance', 'date'] }, page: { type: 'integer', description: 'Page number', default: 1 }, paginationToken: { type: 'string', description: 'Pagination token' }, save_dir: { type: 'string', description: 'Directory to save cleaned JSON data' }, max_items: { type: 'integer', description: 'Maximum comments (default: 10)', default: 10 }, }, required: ['post'], }, } as Tool,
  • src/index.ts:546-546 (registration)
    Dispatch case in the CallToolRequestSchema switch statement that maps the tool name to the getPostComments handler method.
    case 'get_post_comments': return await this.getPostComments(args as Record<string, any>);
  • Helper function in DataCleaners used by get_post_comments to clean individual comment data, extracting id, content, author, timestamp, and likes.
    cleanComment(raw: any): any { if (!raw) return null; return { id: raw.id, content: raw.content, authorName: raw.author?.name, postedAgo: raw.postedAt?.postedAgoText, likes: raw.engagement?.likes, }; },

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/Jing-yilin/linkedin-mcp-server'

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