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
| Name | Required | Description | Default |
|---|---|---|---|
| search | No | Keywords to search | |
| profile | No | Filter by author profile URL | |
| profileId | No | Filter by author profile ID | |
| company | No | Filter by company name | |
| companyId | No | Filter by company ID | |
| authorsCompany | No | Search posts from employees of a company | |
| authorsCompanyId | No | Filter by company ID of post authors | |
| group | No | Filter by group name | |
| postedLimit | No | Filter by time: 24h, week, month | |
| sortBy | No | Sort by: relevance or date | |
| page | No | Page number | |
| paginationToken | No | Pagination token | |
| save_dir | No | Directory to save cleaned JSON data | |
| max_items | No | Maximum results (default: 10) |
Implementation Reference
- src/index.ts:884-909 (handler)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,
- src/index.ts:433-452 (schema)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: [], },
- src/index.ts:132-147 (helper)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>);