get_twitter_tweets
Retrieve tweets from any Twitter/X user by providing their username. This tool accesses Twitter data through the SociaVault MCP Server for social media analysis and content extraction.
Instructions
Get tweets from a Twitter/X user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | Twitter username |
Implementation Reference
- src/index.ts:445-464 (handler)Executes the get_twitter_tweets tool by calling the Sociavault API endpoint /twitter/user-tweets with the handle, extracts tweets using helper, and returns JSON stringified response.if (name === "get_twitter_tweets") { const { handle } = args as { handle: string }; const response = await axios.get(`${BASE_URL}/twitter/user-tweets`, { headers: { "X-API-Key": API_KEY }, params: { handle }, }); const extracted = extractTwitterTweets(response.data, 10); return { content: [ { type: "text", text: JSON.stringify( { handle, tweets: extracted, total_returned: extracted.length }, null, 2 ), }, ], }; }
- src/index.ts:278-288 (registration)Registers the get_twitter_tweets tool in the tools list with name, description, and input schema requiring 'handle'.{ name: "get_twitter_tweets", description: "Get tweets from a Twitter/X user", inputSchema: { type: "object", properties: { handle: { type: "string", description: "Twitter username" }, }, required: ["handle"], }, },
- src/index.ts:122-136 (helper)Helper function to extract and format up to 10 tweets from the API response data.function extractTwitterTweets(data: any, limit = 10) { const tweets = data?.data?.tweets || data?.tweets || data?.data || []; const tweetsArray = Array.isArray(tweets) ? tweets : tweets.timeline || []; return tweetsArray.slice(0, limit).map((tweet: any) => { return { id: tweet.id_str || tweet.id, text: tweet.full_text || tweet.text, created_at: tweet.created_at, retweets: tweet.retweet_count || 0, likes: tweet.favorite_count || tweet.like_count || 0, replies: tweet.reply_count || 0, is_retweet: tweet.retweeted || false, }; }); }