search_companies
Search for companies on LinkedIn using keywords, location, size, and other filters. Returns cleaned company data in structured TOON format for analysis and integration.
Instructions
Search LinkedIn companies. Returns cleaned data in TOON format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search | Yes | Keywords to search | |
| location | No | Filter by location | |
| geoId | No | Filter by LinkedIn Geo ID | |
| companySize | No | Filter by size: 1-10, 11-50, 51-200, 201-500, 501-1000, 1001-5000, 5001-10000, 10001+ | |
| page | No | Page number | |
| save_dir | No | Directory to save cleaned JSON data | |
| max_items | No | Maximum results (default: 10) |
Implementation Reference
- src/index.ts:778-795 (handler)The main handler function that implements the search_companies tool. It builds search parameters from input args, calls the HarvestAPI endpoint '/company-search', cleans the response data using DataCleaners.cleanCompany, limits the number of results, and returns a formatted CallToolResult with TOON-encoded content, optional file save, and pagination info.private async searchCompanies(args: Record<string, any>): Promise<CallToolResult> { const params: Record<string, any> = { search: args.search }; if (args.location) params.location = args.location; if (args.geoId) params.geoId = args.geoId; if (args.companySize) params.companySize = args.companySize; if (args.page) params.page = args.page; const data = await this.makeRequest('/company-search', params); const maxItems = args.max_items || 10; const cleaned = (data.elements || []).slice(0, maxItems).map(DataCleaners.cleanCompany); return this.formatResponse(cleaned, { saveDir: args.save_dir, toolName: 'search_companies', pagination: data.pagination, }); }
- src/index.ts:343-359 (registration)The tool registration entry in the ListToolsRequestSchema handler's tools array. Defines the tool name, description, and detailed input schema including required 'search' parameter and optional filters like location, geoId, companySize, pagination, and save options.{ name: 'search_companies', description: 'Search LinkedIn companies. Returns cleaned data in TOON format.', inputSchema: { type: 'object', properties: { search: { type: 'string', description: 'Keywords to search' }, location: { type: 'string', description: 'Filter by location' }, geoId: { type: 'string', description: 'Filter by LinkedIn Geo ID' }, companySize: { type: 'string', description: 'Filter by size: 1-10, 11-50, 51-200, 201-500, 501-1000, 1001-5000, 5001-10000, 10001+' }, page: { type: 'integer', description: 'Page number', default: 1 }, save_dir: { type: 'string', description: 'Directory to save cleaned JSON data' }, max_items: { type: 'integer', description: 'Maximum results (default: 10)', default: 10 }, }, required: ['search'], }, } as Tool,
- src/index.ts:346-358 (schema)The input schema definition for the search_companies tool, specifying properties for search query, filters (location, geoId, companySize), pagination (page, max_items), and optional save_dir, with 'search' as the only required field.inputSchema: { type: 'object', properties: { search: { type: 'string', description: 'Keywords to search' }, location: { type: 'string', description: 'Filter by location' }, geoId: { type: 'string', description: 'Filter by LinkedIn Geo ID' }, companySize: { type: 'string', description: 'Filter by size: 1-10, 11-50, 51-200, 201-500, 501-1000, 1001-5000, 5001-10000, 10001+' }, page: { type: 'integer', description: 'Page number', default: 1 }, save_dir: { type: 'string', description: 'Directory to save cleaned JSON data' }, max_items: { type: 'integer', description: 'Maximum results (default: 10)', default: 10 }, }, required: ['search'], },
- src/index.ts:83-98 (helper)Helper function within DataCleaners object that cleans raw company data from the API response, extracting and simplifying key fields such as id, name, linkedinUrl, website, logo, description, employeeCount, followers, and headquarter location.cleanCompany(raw: any): any { if (!raw) return null; const hq = (raw.locations || []).find((l: any) => l.headquarter) || raw.locations?.[0]; return { id: raw.id, universalName: raw.universalName, linkedinUrl: raw.linkedinUrl, name: raw.name, website: raw.website, logo: raw.logo, description: raw.description, employeeCount: raw.employeeCount, followers: raw.followerCount, headquarter: hq?.parsed?.text || hq?.city, }; },
- src/index.ts:540-540 (registration)The switch case in the CallToolRequestSchema handler that dispatches calls to the search_companies tool by invoking the searchCompanies method.case 'search_companies': return await this.searchCompanies(args as Record<string, any>);