// Simple script to post actionable MCP content to Mastodon and LinkedIn
import fs from 'fs/promises';
import { fileURLToPath } from 'url';
import path from 'path';
// Function to log to a file
async function log(message) {
await fs.appendFile('actionable-log.txt', message + '\n');
console.log(message);
}
async function main() {
try {
// Clear the log file
await fs.writeFile('actionable-log.txt', '');
await log('Starting actionable MCP content posting...');
// Dynamically import the modules
await log('Importing modules...');
const mastodonClient = (await import('./build/src/platforms/mastodon/client.js')).default;
const linkedinClient = (await import('./build/src/platforms/linkedin/client.js')).default;
const { SocialPlatform } = await import('./build/src/types/index.js');
await log('Modules imported successfully');
// Read the content file
await log('Reading actionable MCP content...');
const contentRaw = await fs.readFile('./actionable-mcp-content.json', 'utf-8');
const content = JSON.parse(contentRaw);
// Post to Mastodon
await log('Posting to Mastodon...');
const mastodonContent = {
text: content.mastodon.post,
platform: SocialPlatform.MASTODON
};
const mastodonResult = await mastodonClient.postStatus(mastodonContent);
await log(`Mastodon post result: ${JSON.stringify(mastodonResult, null, 2)}`);
// Post to LinkedIn
await log('Posting to LinkedIn...');
const linkedinContent = {
text: content.linkedin.post,
platform: SocialPlatform.LINKEDIN
};
const linkedinResult = await linkedinClient.postShare(linkedinContent);
await log(`LinkedIn post result: ${JSON.stringify(linkedinResult, null, 2)}`);
// Provide a summary
await log('\n===== POSTING SUMMARY =====');
await log(`Mastodon: ${mastodonResult.success ? 'SUCCESS' : 'FAILED'} ${mastodonResult.isMock ? '(MOCK)' : ''}`);
if (mastodonResult.success) {
await log(`URL: ${mastodonResult.url}`);
}
await log(`LinkedIn: ${linkedinResult.success ? 'SUCCESS' : 'FAILED'} ${linkedinResult.isMock ? '(MOCK)' : ''}`);
if (linkedinResult.success) {
await log(`URL: ${linkedinResult.url}`);
}
// Check if any posts were mocks and provide guidance
if (mastodonResult.isMock) {
await log('\nMastodon post used mock implementation. To fix:');
await log('1. Check Mastodon credentials in config/index.ts');
await log('2. Ensure you have a valid access token for your Mastodon instance');
await log('3. Rebuild and try again');
}
if (linkedinResult.isMock) {
await log('\nLinkedIn post used mock implementation. To fix:');
await log('1. Check LinkedIn credentials in config/index.ts');
await log('2. Ensure you have a valid access token for LinkedIn');
await log('3. Rebuild and try again');
}
await log('\nPosting completed!');
} catch (error) {
await log(`Error: ${error.message}`);
await log(error.stack);
}
}
// Run the main function
main().catch(console.error);