UNPKG

@maheidem/linkedin-mcp

Version:

Comprehensive LinkedIn API MCP server with automatic Claude configuration

160 lines (135 loc) • 5.83 kB
#!/usr/bin/env node const { spawn } = require('child_process'); async function callLinkedIn(toolName, args = {}) { const process = spawn('npx', ['-y', '--package=@maheidem/linkedin-mcp', 'linkedin-mcp-server'], { stdio: ['pipe', 'pipe', 'pipe'] }); const request = JSON.stringify({ jsonrpc: '2.0', id: Math.floor(Math.random() * 1000), method: 'tools/call', params: { name: toolName, arguments: args } }); process.stdin.write(request + '\n'); process.stdin.end(); let response = ''; process.stdout.on('data', (data) => { response += data.toString(); }); await new Promise((resolve) => { process.on('close', () => resolve()); }); const lines = response.split('\n'); const resultLine = lines.find(line => line.startsWith('{"result"')); if (resultLine) { const result = JSON.parse(resultLine); const data = JSON.parse(result.result.content[0].text); return data; } return null; } async function demoLinkedInMCP() { console.log('šŸŽÆ LinkedIn MCP Complete Demo\n'); console.log('This demonstrates all working LinkedIn MCP functions:\n'); // Demo 1: LinkedIn Headlines console.log('šŸ“ 1. LINKEDIN HEADLINE GENERATION'); console.log(' Input: Principal ML Engineer with Python, TensorFlow, AWS skills'); const headlines = await callLinkedIn('linkedin_generate_optimized_content', { contentType: 'headline', currentRole: 'Principal ML Engineer', skills: ['Python', 'TensorFlow', 'AWS', 'MLOps'], industry: 'Technology', tone: 'professional' }); if (headlines) { console.log(' āœ… Generated Headlines:'); headlines.generatedContent.options.forEach((headline, i) => { console.log(` ${i + 1}. ${headline}`); }); console.log(' šŸ’” Tips:', headlines.generatedContent.tips.join(', ')); } // Demo 2: LinkedIn Posts console.log('\nšŸš€ 2. LINKEDIN POST GENERATION'); console.log(' Input: ML Engineer discussing AI trends'); const posts = await callLinkedIn('linkedin_generate_optimized_content', { contentType: 'post', currentRole: 'ML Engineer', skills: ['AI', 'Machine Learning', 'Python'], industry: 'Technology' }); if (posts) { console.log(' āœ… Generated Posts:'); posts.generatedContent.posts.forEach((post, i) => { console.log(` ${i + 1}. ${post}`); }); } // Demo 3: Profile Summary console.log('\nšŸ“‹ 3. LINKEDIN SUMMARY GENERATION'); console.log(' Input: Senior engineer with leadership experience'); const summary = await callLinkedIn('linkedin_generate_optimized_content', { contentType: 'summary', currentRole: 'Senior ML Engineer', skills: ['Python', 'Leadership', 'MLOps'], achievements: ['Led team of 10', 'Increased model accuracy by 25%'], tone: 'professional' }); if (summary) { console.log(' āœ… Generated Summary:'); console.log(` "${summary.generatedContent.summary}"`); } // Demo 4: Profile Analysis console.log('\nšŸ” 4. LINKEDIN PROFILE ANALYSIS'); console.log(' Input: Sample profile data for analysis'); const analysis = await callLinkedIn('linkedin_analyze_profile_from_data', { name: 'Marcos Heidemann', currentHeadline: 'Principal ML Engineer', currentSummary: 'Building scalable ML systems with Python and TensorFlow', skills: ['Python', 'TensorFlow', 'AWS', 'MLOps', 'Leadership'], industry: 'Technology', experience: '10+ years' }); if (analysis) { console.log(' āœ… Profile Analysis Results:'); console.log(` Completeness: ${analysis.analysis.profileCompleteness}%`); console.log(` Optimization Opportunities: ${analysis.analysis.optimizationOpportunities.join(', ')}`); } // Demo 5: OAuth URL Generation console.log('\nšŸ” 5. OAUTH URL GENERATION'); console.log(' Generating fresh LinkedIn authentication URL...'); const auth = await callLinkedIn('linkedin_get_auth_url', { state: 'demo-test' }); if (auth) { console.log(' āœ… OAuth URL Generated Successfully'); console.log(` URL: ${auth.authorizationUrl.substring(0, 80)}...`); console.log(' šŸ“‹ Ready for authentication flow'); } // Summary console.log('\nšŸŽ‰ LINKEDIN MCP STATUS SUMMARY'); console.log(' āœ… Package installed and working via npx'); console.log(' āœ… Content generation (headlines, posts, summaries)'); console.log(' āœ… Profile analysis and optimization'); console.log(' āœ… OAuth URL generation'); console.log(' āœ… Claude MCP integration configured'); console.log(' āœ… All 13 LinkedIn tools available'); console.log('\nšŸ“‹ AUTHENTICATED FUNCTIONS (require valid access token):'); console.log(' šŸ” linkedin_create_post - Create LinkedIn posts'); console.log(' šŸ” linkedin_get_user_info - Get profile information'); console.log(' šŸ” linkedin_get_feed - Get LinkedIn feed'); console.log(' šŸ” linkedin_get_user_posts - Get your posts'); console.log(' šŸ” linkedin_create_optimized_post - AI-generated posts'); console.log(' šŸ” linkedin_post_profile_update - Announcement posts'); console.log(' šŸ” linkedin_get_post_details - Post analytics'); console.log(' šŸ” linkedin_get_post_comments - Post comments'); console.log(' šŸ” linkedin_get_user_activity - User activity'); console.log('\nšŸš€ LINKEDIN MCP IS FULLY OPERATIONAL!'); console.log('\nšŸ’” Next Steps:'); console.log(' 1. Use content generation tools immediately (no auth required)'); console.log(' 2. For posting/feed access, complete LinkedIn OAuth setup'); console.log(' 3. Available via: npx -y --package=@maheidem/linkedin-mcp linkedin-mcp-server'); console.log(' 4. Integrated with Claude Code MCP system'); } demoLinkedInMCP().catch(console.error);