@maheidem/linkedin-mcp
Version:
Comprehensive LinkedIn API MCP server with automatic Claude configuration
160 lines (135 loc) ⢠5.83 kB
JavaScript
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);