get_linkedin_profile
Retrieve LinkedIn profile information including headline, summary, experience, and education.
Instructions
Retrieve the user's LinkedIn profile information including headline, summary, experience, and education.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- cli.js:796-930 (handler)Handler for the get_linkedin_profile tool. Validates API key, calls the backend LinkedIn profile API, formats the profile data (headline, summary, experience, education) into readable text, and returns it.
} else if (name === 'get_linkedin_profile') { console.error(`${packageName}: Received call for get_linkedin_profile tool.`); const apiKey = process.env.LINKEDIN_MCP_API_KEY; if (!apiKey) { sendResponse({ jsonrpc: "2.0", error: { code: -32001, message: "Server Configuration Error: API Key not set." }, id }); return; } try { const headers = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", "Accept": "application/json" }; console.error(`${packageName}: Calling LinkedIn profile API: ${backendLinkedinProfileApiUrl}`); const apiResponse = await axios.post(backendLinkedinProfileApiUrl, {}, { headers, timeout: 60000 }); console.error(`${packageName}: LinkedIn profile API response status: ${apiResponse.status}`); console.error(`${packageName}: LinkedIn profile API response data:`, JSON.stringify(apiResponse.data, null, 2)); if (apiResponse.data && apiResponse.data.success) { const profile = apiResponse.data.profile || {}; // Format profile as text to avoid "unsupported content type: data" error let profileHeadline = profile.headline || 'No headline'; let profileSummary = profile.summary || 'No summary'; // Format experience entries let experienceText = 'Experience:'; if (profile.experience && Array.isArray(profile.experience) && profile.experience.length > 0) { profile.experience.forEach((exp, index) => { experienceText += `\n\n${index + 1}. ${exp.title || 'Role'} at ${exp.companyName || 'Company'}`; if (exp.dateRange || exp.duration) { experienceText += `\n Duration: ${exp.dateRange || exp.duration || 'Not specified'}`; } if (exp.description) { experienceText += `\n Description: ${exp.description}`; } }); } else { experienceText += '\n No experience data available'; } // Format education entries let educationText = '\n\nEducation:'; if (profile.education && Array.isArray(profile.education) && profile.education.length > 0) { profile.education.forEach((edu, index) => { educationText += `\n\n${index + 1}. ${edu.schoolName || edu.school || 'Institution'}`; if (edu.degree || edu.fieldOfStudy) { educationText += `\n ${edu.degree || ''} ${edu.fieldOfStudy || ''}`.trim(); } if (edu.dateRange || edu.dates) { educationText += `\n Years: ${edu.dateRange || edu.dates || 'Not specified'}`; } }); } else { educationText += '\n No education data available'; } // Combine all text const profileText = `Headline: ${profileHeadline}\n\nSummary: ${profileSummary}\n\n${experienceText}${educationText}`; sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `LinkedIn profile data retrieved. Last updated: ${apiResponse.data.data_last_updated || 'Unknown'}` }, { type: "text", text: profileText } ], isError: false }, id }); } else { const errorMessage = apiResponse.data?.error || "Backend API Error (no detail)"; console.error(`${packageName}: LinkedIn profile API Error: ${errorMessage}`); sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `Failed to get LinkedIn profile: ${errorMessage}. This may occur if you haven't set your LinkedIn URL yet. Try using the set_linkedin_url tool first.` } ], isError: true }, id }); } } catch (error) { let errorMessage = `Failed to call LinkedIn profile API: ${error.message}`; if (error.response) { // Extract complete error details from the response const responseData = error.response.data || {}; const extractedError = responseData.error || responseData.message || (typeof responseData === 'string' ? responseData : null); // Include any suggestion provided const suggestion = responseData.suggestion ? `\n\nSuggestion: ${responseData.suggestion}` : ''; // Use the backend's full error message if (extractedError) { errorMessage = `${extractedError}${suggestion}`; } else { // Fallback with a generic message but including the status errorMessage = `Backend API Error (Status ${error.response.status}): Unknown error${suggestion}`; } console.error(`${packageName}: LinkedIn profile API Error Response:`, error.response.data); } else if (error.request) { errorMessage = "No response received from LinkedIn profile API. The server may be unavailable or experiencing issues."; } console.error(`${packageName}: ${errorMessage}`); sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `Failed to get LinkedIn profile: ${errorMessage}` } ], isError: true }, id }); } - cli.js:1352-1359 (registration)Registration of the get_linkedin_profile tool in the tools/list response, defining its name, description, and empty input schema.
{ name: "get_linkedin_profile", description: "Retrieve the user's LinkedIn profile information including headline, summary, experience, and education.", inputSchema: { type: "object", properties: {} } }, - cli.js:17-20 (helper)Backend API endpoint URL constant used by the get_linkedin_profile handler to make the actual HTTP request.
const backendLinkedinProfileApiUrl = 'https://ligosocial.com/api/mcp/linkedin/profile'; const backendLinkedinSetUrlApiUrl = 'https://ligosocial.com/api/mcp/linkedin/set-url'; const backendLinkedinRefreshProfileApiUrl = 'https://ligosocial.com/api/mcp/linkedin/refresh-profile'; const backendLinkedinRefreshPostsApiUrl = 'https://ligosocial.com/api/mcp/linkedin/refresh-posts';