get_linkedin_chat_messages
Retrieve LinkedIn chat messages for a specific user from the management API to monitor conversations and manage communications.
Instructions
Get top chat messages from LinkedIn management API. Account ID is taken from environment.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company | No | Company URN where the account is admin (format: company:123456) | |
| count | No | Max messages to return | |
| timeout | No | Timeout in seconds | |
| user | Yes | User URN for filtering messages (must include prefix, e.g. fsd_profile:ACoAA...) |
Implementation Reference
- src/index.ts:836-858 (handler)The core handler function for the 'get_linkedin_chat_messages' tool. Normalizes the user URN, validates it, constructs the API request payload including account_id, calls the AnySite API endpoint for chat messages, and returns the JSON response or an error message.
async ({ user, company, count, timeout }) => { const normalizedUser = normalizeUserURN(user); if (!isValidUserURN(normalizedUser)) { return { content: [{ type: "text", text: "Invalid URN format. Must start with 'fsd_profile:'" }], isError: true }; } const requestData: any = { timeout, user: normalizedUser, count, account_id: ACCOUNT_ID }; if (company) requestData.company = company; log("Starting LinkedIn chat messages lookup for user:", normalizedUser); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.CHAT_MESSAGES, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn chat messages lookup error:", error); return { content: [{ type: "text", text: `LinkedIn chat messages API error: ${formatError(error)}` }], isError: true }; } - src/index.ts:831-835 (schema)Zod input schema defining parameters for the tool: user URN (required), optional company URN, count (default 20), timeout (default 300).
user: z.string().describe("User URN (must include prefix)"), company: z.string().optional().describe("Company URN"), count: z.number().default(20).describe("Max messages"), timeout: z.number().default(300).describe("Timeout in seconds") }, - src/index.ts:827-860 (registration)MCP server tool registration call that defines the tool name, description, input schema, and points to the handler function.
server.tool( "get_linkedin_chat_messages", "Get LinkedIn chat messages (requires ACCOUNT_ID)", { user: z.string().describe("User URN (must include prefix)"), company: z.string().optional().describe("Company URN"), count: z.number().default(20).describe("Max messages"), timeout: z.number().default(300).describe("Timeout in seconds") }, async ({ user, company, count, timeout }) => { const normalizedUser = normalizeUserURN(user); if (!isValidUserURN(normalizedUser)) { return { content: [{ type: "text", text: "Invalid URN format. Must start with 'fsd_profile:'" }], isError: true }; } const requestData: any = { timeout, user: normalizedUser, count, account_id: ACCOUNT_ID }; if (company) requestData.company = company; log("Starting LinkedIn chat messages lookup for user:", normalizedUser); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.CHAT_MESSAGES, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn chat messages lookup error:", error); return { content: [{ type: "text", text: `LinkedIn chat messages API error: ${formatError(error)}` }], isError: true }; } } ); - src/index.ts:88-92 (helper)Helper function used in the handler to normalize user URN by prepending 'fsd_profile:' if missing.
const normalizeUserURN = (urn: string): string => { if (!urn.includes("fsd_profile:")) { return `fsd_profile:${urn}`; } return urn; - src/index.ts:32-32 (helper)API endpoint configuration used by the handler for fetching LinkedIn chat messages.
CHAT_MESSAGES: "/api/linkedin/management/chat/messages",