analyze_linkedin_chat
Ask questions and analyze your LinkedIn profile, content, or network through multi-turn conversations.
Instructions
Ask questions about the user's LinkedIn profile, content, or network, with support for multi-turn conversations.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The question or request about LinkedIn data to be analyzed. | |
| conversation_history | No | Optional. Previous messages in the conversation for context. Each message must have 'role' (user/assistant) and 'content' (text). |
Implementation Reference
- cli.js:443-530 (handler)The main handler for the analyze_linkedin_chat tool. It receives the MCP call, validates the API key, 'query' (required string) and 'conversation_history' (optional array) arguments, calls the backend API at backendAnalyzeChatApiUrl, and returns the AI-generated reply text to the user.
} else if (name === 'analyze_linkedin_chat') { console.error(`${packageName}: Received call for analyze_linkedin_chat tool.`); const apiKey = process.env.LINKEDIN_MCP_API_KEY; const query = args?.query; const conversationHistory = args?.conversation_history || []; if (!apiKey) { sendResponse({ jsonrpc: "2.0", error: { code: -32001, message: "Server Configuration Error: API Key not set." }, id }); return; } if (typeof query !== 'string' || query.trim() === '') { sendResponse({ jsonrpc: "2.0", error: { code: -32602, message: "Invalid arguments: 'query' (string) required." }, id }); return; } if (!Array.isArray(conversationHistory)) { sendResponse({ jsonrpc: "2.0", error: { code: -32602, message: "Invalid arguments: 'conversation_history' must be an array." }, id }); return; } try { const headers = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", "Accept": "application/json" }; const payload = { "query": query, "conversation_history": conversationHistory }; console.error(`${packageName}: Calling analyze chat API: ${backendAnalyzeChatApiUrl} with payload:`, JSON.stringify(payload, null, 2)); const apiResponse = await axios.post(backendAnalyzeChatApiUrl, payload, { headers, timeout: 60000 }); console.error(`${packageName}: Analyze chat API response status: ${apiResponse.status}`); console.error(`${packageName}: Analyze chat API response data:`, JSON.stringify(apiResponse.data, null, 2)); if (apiResponse.data && apiResponse.data.reply) { sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: apiResponse.data.reply } ], isError: false }, id }); } else { const errorMessage = apiResponse.data?.error || "Backend API Error (no detail)"; console.error(`${packageName}: Analyze chat API Error: ${errorMessage}`); sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `Failed to analyze LinkedIn chat: ${errorMessage}` } ], isError: true }, id }); } } catch (error) { let errorMessage = `Failed to call analyze chat API: ${error.message}`; if (error.response) { // Extract the error message directly from the backend response const backendError = error.response.data?.error || error.response.data?.message; errorMessage = backendError || `Backend API Error (Status ${error.response.status})`; console.error(`${packageName}: Analyze chat API Error Response:`, error.response.data); } else if (error.request) { errorMessage = "No response received from analyze chat API."; } console.error(`${packageName}: ${errorMessage}`); sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `Failed to analyze LinkedIn chat: ${errorMessage}` } ], isError: true }, id }); } - cli.js:1289-1319 (schema)The input schema registered for analyze_linkedin_chat. Defines 'query' (required string) and 'conversation_history' (optional array of {role, content} objects) properties.
{ name: "analyze_linkedin_chat", description: "Ask questions about the user's LinkedIn profile, content, or network, with support for multi-turn conversations.", inputSchema: { type: "object", properties: { query: { type: "string", description: "The question or request about LinkedIn data to be analyzed." }, conversation_history: { type: "array", description: "Optional. Previous messages in the conversation for context. Each message must have 'role' (user/assistant) and 'content' (text).", items: { type: "object", properties: { role: { type: "string", description: "The sender of the message: 'user' or 'assistant'." }, content: { type: "string", description: "The text content of the message." } }, required: ["role", "content"] } } }, required: ["query"] } - cli.js:1289-1320 (registration)The registration of the analyze_linkedin_chat tool in the tools/list response, declaring its name, description, and inputSchema to the MCP client.
{ name: "analyze_linkedin_chat", description: "Ask questions about the user's LinkedIn profile, content, or network, with support for multi-turn conversations.", inputSchema: { type: "object", properties: { query: { type: "string", description: "The question or request about LinkedIn data to be analyzed." }, conversation_history: { type: "array", description: "Optional. Previous messages in the conversation for context. Each message must have 'role' (user/assistant) and 'content' (text).", items: { type: "object", properties: { role: { type: "string", description: "The sender of the message: 'user' or 'assistant'." }, content: { type: "string", description: "The text content of the message." } }, required: ["role", "content"] } } }, required: ["query"] } }, - cli.js:14-15 (helper)The backend API URL constant for analyze-linkedin-chat, pointing to 'https://ligosocial.com/api/mcp/analyze-linkedin-chat'.
const backendAnalyzeChatApiUrl = 'https://ligosocial.com/api/mcp/analyze-linkedin-chat'; const backendGeneratePostApiUrl = 'https://ligosocial.com/api/mcp/generate-linkedin-post';