Skip to main content
Glama
Jing-yilin

LinkedIn MCP Server

by Jing-yilin

search_posts

Search LinkedIn posts using keywords, filters, and sorting options to find relevant content and save cleaned data in TOON format.

Instructions

Search LinkedIn posts. Returns cleaned data in TOON format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchNoKeywords to search
profileNoFilter by author profile URL
profileIdNoFilter by author profile ID
companyNoFilter by company name
companyIdNoFilter by company ID
authorsCompanyNoSearch posts from employees of a company
authorsCompanyIdNoFilter by company ID of post authors
groupNoFilter by group name
postedLimitNoFilter by time: 24h, week, month
sortByNoSort by: relevance or date
pageNoPage number
paginationTokenNoPagination token
save_dirNoDirectory to save cleaned JSON data
max_itemsNoMaximum results (default: 10)

Implementation Reference

  • The handler function that implements the core logic of the 'search_posts' tool. It builds request parameters from input args, calls the '/post-search' API endpoint, cleans the post data using DataCleaners.cleanPost, applies max_items limit, and returns formatted response with pagination.
    private async searchPosts(args: Record<string, any>): Promise<CallToolResult> { const params: Record<string, any> = {}; if (args.search) params.search = args.search; if (args.profile) params.profile = args.profile; if (args.profileId) params.profileId = args.profileId; if (args.company) params.company = args.company; if (args.companyId) params.companyId = args.companyId; if (args.authorsCompany) params.authorsCompany = args.authorsCompany; if (args.authorsCompanyId) params.authorsCompanyId = args.authorsCompanyId; if (args.group) params.group = args.group; if (args.postedLimit) params.postedLimit = args.postedLimit; 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-search', params); const maxItems = args.max_items || 10; const cleaned = (data.elements || []).slice(0, maxItems).map(DataCleaners.cleanPost); return this.formatResponse(cleaned, { saveDir: args.save_dir, toolName: 'search_posts', pagination: data.pagination, }); }
  • src/index.ts:430-453 (registration)
    Registration of the 'search_posts' tool in the ListToolsRequestSchema handler, defining name, description, and input schema.
    { name: 'search_posts', description: 'Search LinkedIn posts. Returns cleaned data in TOON format.', inputSchema: { type: 'object', properties: { search: { type: 'string', description: 'Keywords to search' }, profile: { type: 'string', description: 'Filter by author profile URL' }, profileId: { type: 'string', description: 'Filter by author profile ID' }, company: { type: 'string', description: 'Filter by company name' }, companyId: { type: 'string', description: 'Filter by company ID' }, authorsCompany: { type: 'string', description: 'Search posts from employees of a company' }, authorsCompanyId: { type: 'string', description: 'Filter by company ID of post authors' }, group: { type: 'string', description: 'Filter by group name' }, postedLimit: { type: 'string', description: 'Filter by time: 24h, week, month', enum: ['24h', 'week', 'month'] }, 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 results (default: 10)', default: 10 }, }, required: [], }, } as Tool,
  • Input schema definition for the 'search_posts' tool, specifying parameters for search query, filters, pagination, and optional save options.
    inputSchema: { type: 'object', properties: { search: { type: 'string', description: 'Keywords to search' }, profile: { type: 'string', description: 'Filter by author profile URL' }, profileId: { type: 'string', description: 'Filter by author profile ID' }, company: { type: 'string', description: 'Filter by company name' }, companyId: { type: 'string', description: 'Filter by company ID' }, authorsCompany: { type: 'string', description: 'Search posts from employees of a company' }, authorsCompanyId: { type: 'string', description: 'Filter by company ID of post authors' }, group: { type: 'string', description: 'Filter by group name' }, postedLimit: { type: 'string', description: 'Filter by time: 24h, week, month', enum: ['24h', 'week', 'month'] }, 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 results (default: 10)', default: 10 }, }, required: [], },
  • Helper function in DataCleaners that processes and cleans raw post data from the API response, extracting key fields like content, author, engagement metrics, used in searchPosts handler.
    cleanPost(raw: any): any { if (!raw) return null; return { id: raw.id, linkedinUrl: raw.linkedinUrl, content: raw.content, authorName: raw.author?.name, authorType: raw.author?.type, postedAgo: raw.postedAt?.postedAgoText || raw.postedAt?.postedAgoShort, likes: raw.engagement?.likes, comments: raw.engagement?.comments, shares: raw.engagement?.shares, hasVideo: !!raw.postVideo, hasImages: (raw.postImages?.length || 0) > 0, }; },
  • src/index.ts:545-545 (registration)
    Switch case in CallToolRequestSchema handler that routes calls to the 'search_posts' tool to its handler method.
    case 'search_posts': return await this.searchPosts(args as Record<string, any>);

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