Social Media MCP Server

// Script to post MCP server content to social media platforms import fs from 'fs/promises'; import twitterClient from './src/platforms/twitter/client.js'; import mastodonClient from './src/platforms/mastodon/client.js'; import linkedinClient from './src/platforms/linkedin/client.js'; import historyManager from './src/history/manager.js'; import { SocialPlatform, Content } from './src/types/index.js'; import { createComponentLogger } from './src/utils/logger.js'; const logger = createComponentLogger('MCPPostScript'); async function postMCPContent() { try { // Read the content file logger.info('Reading MCP post content...'); const contentRaw = await fs.readFile('./mcp-post-content.json', 'utf-8'); const content = JSON.parse(contentRaw); // Post to Twitter (thread) logger.info('Posting to Twitter...'); const twitterThread = content.twitter.thread; let previousTweetId = null; for (const tweet of twitterThread) { const tweetContent = { text: tweet, platform: SocialPlatform.TWITTER, replyToId: previousTweetId }; const result = await twitterClient.postTweet(tweetContent); logger.info('Tweet posted', { id: result.postId, success: result.success }); if (result.success) { previousTweetId = result.postId; } } // Post to Mastodon logger.info('Posting to Mastodon...'); const mastodonContent = { text: content.mastodon.post, platform: SocialPlatform.MASTODON }; const mastodonResult = await mastodonClient.postStatus(mastodonContent); logger.info('Mastodon post result', { success: mastodonResult.success, id: mastodonResult.postId, url: mastodonResult.url }); // Post to LinkedIn logger.info('Posting to LinkedIn...'); const linkedinContent = { text: content.linkedin.post, platform: SocialPlatform.LINKEDIN }; const linkedinResult = await linkedinClient.postShare(linkedinContent); logger.info('LinkedIn post result', { success: linkedinResult.success, id: linkedinResult.postId, url: linkedinResult.url }); // Add to history logger.info('Adding to history...'); const platforms = [SocialPlatform.TWITTER, SocialPlatform.MASTODON, SocialPlatform.LINKEDIN]; const contentForHistory = { [SocialPlatform.TWITTER]: { text: twitterThread.join('\n\n'), platform: SocialPlatform.TWITTER }, [SocialPlatform.MASTODON]: mastodonContent, [SocialPlatform.LINKEDIN]: linkedinContent }; const keywords = ['MCP', 'Model Context Protocol', 'AI', 'server', 'tutorial']; const historyId = historyManager.addToHistory( 'Model Context Protocol (MCP) servers tutorial', 'Create a post about MCP servers with step-by-step instructions', platforms, contentForHistory, keywords ); logger.info('Added to history', { id: historyId }); logger.info('All posts completed successfully!'); return { twitter: { success: true, threadLength: twitterThread.length }, mastodon: { success: mastodonResult.success, id: mastodonResult.postId, url: mastodonResult.url }, linkedin: { success: linkedinResult.success, id: linkedinResult.postId, url: linkedinResult.url }, historyId }; } catch (error) { logger.error('Error posting MCP content', { error: error instanceof Error ? error.message : String(error) }); throw error; } } // Run the script postMCPContent().then(results => { console.log('Results:', JSON.stringify(results, null, 2)); }).catch(error => { console.error('Unhandled error:', error); process.exit(1); });
ID: 9zu5lcg37u