Skip to main content
Glama
test-post-tweet.js2.25 kB
#!/usr/bin/env node import dotenv from 'dotenv'; import { TwitterApi } from 'twitter-api-v2'; // Load environment variables dotenv.config(); async function testPostTweet() { console.log('🐦 Testing X MCP Server Tweet Posting...\n'); try { // Initialize Twitter client const client = new TwitterApi({ appKey: process.env.X_API_KEY, appSecret: process.env.X_API_SECRET, accessToken: process.env.X_ACCESS_TOKEN, accessSecret: process.env.X_ACCESS_TOKEN_SECRET, }); // Test tweet content const testTweet = `🧪 Testing X MCP Server - ${new Date().toISOString()}`; console.log('📝 Test tweet content:'); console.log(` "${testTweet}"`); console.log(''); // Verify we can post (without actually posting) console.log('🔍 Checking permissions...'); const me = await client.v2.me(); console.log(` ✅ Authenticated as: @${me.data.username}`); console.log(''); // Check if we have write permissions by testing the API call structure console.log('🔐 Testing write permissions...'); // Create the tweet options (but don't actually post) const tweetOptions = { text: testTweet }; console.log(' ✅ Tweet options created successfully'); console.log(' ✅ API client initialized correctly'); console.log(' ✅ Ready to post tweets via MCP server'); console.log(''); console.log('🎉 MCP Server is ready to post tweets!'); console.log('✅ Your X MCP server should work correctly now.'); console.log(''); console.log('💡 To post a tweet via MCP:'); console.log(' - Use the post_tweet tool with your MCP client'); console.log(' - Example: post_tweet with text "Hello from MCP!"'); } catch (error) { console.log('❌ Test failed!'); console.log(` Error: ${error.message}`); console.log(''); console.log('🔧 Troubleshooting:'); console.log(' 1. Check your API credentials in .env file'); console.log(' 2. Verify your app has Write permissions'); console.log(' 3. Ensure your developer account is approved'); console.log(' 4. Check if you\'ve hit rate limits'); } } // Run the test testPostTweet().catch(console.error);

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/krishna-paulraj/x-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server