search_linkedin_users
Find LinkedIn users by applying filters such as name, job title, company, location, industry, education, and keywords to identify relevant professionals.
Instructions
Search for LinkedIn users with various filters like keywords, name, title, company, location etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company_keywords | No | Exact word in the company name | |
| count | Yes | Maximum number of results (max 1000) | |
| current_company | No | Company URN or name | |
| education | No | Education URN or name | |
| first_name | No | Exact first name | |
| industry | No | Industry URN or name | |
| keywords | No | Any keyword for searching in the user page. | |
| last_name | No | Exact last name | |
| location | No | Location name or URN | |
| past_company | No | Past company URN or name | |
| school_keywords | No | Exact word in the school name | |
| timeout | No | Timeout in seconds (20-1500) | |
| title | No | Exact word in the title |
Implementation Reference
- src/index.ts:173-219 (registration)Registration of the 'search_linkedin_users' tool using McpServer.tool(), including inline Zod schema and the full handler function that prepares request data and calls the AnySite API via makeRequest.// Register search_linkedin_users tool server.tool( "search_linkedin_users", "Search for LinkedIn users with various filters", { keywords: z.string().optional().describe("Search keywords"), first_name: z.string().optional().describe("First name"), last_name: z.string().optional().describe("Last name"), title: z.string().optional().describe("Job title"), company_keywords: z.string().optional().describe("Company keywords"), count: z.number().default(10).describe("Max results"), timeout: z.number().default(300).describe("Timeout in seconds") }, async ({ keywords, first_name, last_name, title, company_keywords, count, timeout }) => { const requestData: any = { timeout, count }; if (keywords) requestData.keywords = keywords; if (first_name) requestData.first_name = first_name; if (last_name) requestData.last_name = last_name; if (title) requestData.title = title; if (company_keywords) requestData.company_keywords = company_keywords; log("Starting LinkedIn users search with:", JSON.stringify(requestData)); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.SEARCH_USERS, requestData); log(`Search complete, found ${response.length} results`); return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } catch (error) { log("LinkedIn search error:", error); return { content: [ { type: "text", text: `LinkedIn search API error: ${formatError(error)}` } ], isError: true }; } } );
- src/index.ts:186-217 (handler)Handler function that constructs the API request payload from input parameters, calls makeRequest to the /api/linkedin/search/users endpoint, and returns the JSON response or error.async ({ keywords, first_name, last_name, title, company_keywords, count, timeout }) => { const requestData: any = { timeout, count }; if (keywords) requestData.keywords = keywords; if (first_name) requestData.first_name = first_name; if (last_name) requestData.last_name = last_name; if (title) requestData.title = title; if (company_keywords) requestData.company_keywords = company_keywords; log("Starting LinkedIn users search with:", JSON.stringify(requestData)); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.SEARCH_USERS, requestData); log(`Search complete, found ${response.length} results`); return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } catch (error) { log("LinkedIn search error:", error); return { content: [ { type: "text", text: `LinkedIn search API error: ${formatError(error)}` } ], isError: true }; }
- src/index.ts:177-184 (schema)Zod input schema defining optional search parameters like keywords, names, title, company_keywords, with defaults for count and timeout.{ keywords: z.string().optional().describe("Search keywords"), first_name: z.string().optional().describe("First name"), last_name: z.string().optional().describe("Last name"), title: z.string().optional().describe("Job title"), company_keywords: z.string().optional().describe("Company keywords"), count: z.number().default(10).describe("Max results"), timeout: z.number().default(300).describe("Timeout in seconds")
- src/index.ts:22-22 (helper)API endpoint constant used by the handler: '/api/linkedin/search/users'SEARCH_USERS: "/api/linkedin/search/users",
- src/index.ts:100-144 (helper)makeRequest helper function used by the handler to perform HTTPS POST requests to the AnySite API with authentication.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(); });