get_linkedin_company_employees
Retrieve employee data from LinkedIn companies using search filters like keywords, first name, last name, and company identifiers to find specific professionals.
Instructions
Get employees of a LinkedIn company
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companies | Yes | Company URNs (example: ['company:14064608']) | |
| count | Yes | Maximum number of results | |
| first_name | No | Search for exact first name | |
| keywords | No | Any keyword for searching employees | |
| last_name | No | Search for exact last name | |
| timeout | No | Timeout in seconds |
Implementation Reference
- src/index.ts:614-632 (handler)The async handler function that prepares the request data and calls the AnySite API to fetch LinkedIn company employees, returning JSON response or error.async ({ companies, keywords, first_name, last_name, count, timeout }) => { const requestData: any = { timeout, companies, count }; if (keywords) requestData.keywords = keywords; if (first_name) requestData.first_name = first_name; if (last_name) requestData.last_name = last_name; log(`Starting LinkedIn company employees lookup for companies: ${companies.join(', ')}`); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.LINKEDIN_COMPANY_EMPLOYEES, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn company employees lookup error:", error); return { content: [{ type: "text", text: `LinkedIn company employees API error: ${formatError(error)}` }], isError: true }; } }
- src/index.ts:607-613 (schema)Zod input schema defining parameters for the get_linkedin_company_employees tool.companies: z.array(z.string()).describe("Company URNs or aliases"), keywords: z.string().optional().describe("Search keywords"), first_name: z.string().optional().describe("First name filter"), last_name: z.string().optional().describe("Last name filter"), count: z.number().default(10).describe("Max employees"), timeout: z.number().default(300).describe("Timeout in seconds") },
- src/index.ts:603-633 (registration)Registration of the tool using McpServer.tool() method, specifying name, description, input schema, and handler.server.tool( "get_linkedin_company_employees", "Get LinkedIn company employees", { companies: z.array(z.string()).describe("Company URNs or aliases"), keywords: z.string().optional().describe("Search keywords"), first_name: z.string().optional().describe("First name filter"), last_name: z.string().optional().describe("Last name filter"), count: z.number().default(10).describe("Max employees"), timeout: z.number().default(300).describe("Timeout in seconds") }, async ({ companies, keywords, first_name, last_name, count, timeout }) => { const requestData: any = { timeout, companies, count }; if (keywords) requestData.keywords = keywords; if (first_name) requestData.first_name = first_name; if (last_name) requestData.last_name = last_name; log(`Starting LinkedIn company employees lookup for companies: ${companies.join(', ')}`); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.LINKEDIN_COMPANY_EMPLOYEES, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn company employees lookup error:", error); return { content: [{ type: "text", text: `LinkedIn company employees API error: ${formatError(error)}` }], isError: true }; } } );
- src/types.ts:112-119 (schema)TypeScript interface defining the input arguments for the tool.export interface GetLinkedinCompanyEmployeesArgs { companies: string[]; keywords?: string; first_name?: string; last_name?: string; count?: number; timeout?: number; }
- src/index.ts:100-145 (helper)Helper function makeRequest used by the handler to perform HTTPS POST requests to the AnySite API endpoints.const makeRequest = (endpoint: string, data: any, method: string = "POST"): Promise<any> => { return new Promise((resolve, reject) => { const url = new URL(endpoint, API_CONFIG.BASE_URL); const postData = JSON.stringify(data); const options = { hostname: url.hostname, port: url.port || 443, path: url.pathname, method: method, headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData), "access-token": API_KEY, ...(ACCOUNT_ID && { "x-account-id": ACCOUNT_ID }) } }; const req = https.request(options, (res) => { let responseData = ""; res.on("data", (chunk) => { responseData += chunk; }); res.on("end", () => { try { const parsed = JSON.parse(responseData); if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) { resolve(parsed); } else { reject(new Error(`API error ${res.statusCode}: ${JSON.stringify(parsed)}`)); } } catch (e) { reject(new Error(`Failed to parse response: ${responseData}`)); } }); }); req.on("error", (error) => { reject(error); }); req.write(postData); req.end(); }); };
- src/index.ts:42-42 (helper)API endpoint path constant used in the handler for company employees request.LINKEDIN_COMPANY_EMPLOYEES: "/api/linkedin/company/employees",