Skip to main content
Glama
olamide-olaniyan

SociaVault MCP Server

get_twitter_tweets

Retrieve tweets from any Twitter/X user by providing their username to access their posting history and content.

Instructions

Get tweets from a Twitter/X user

Input Schema

NameRequiredDescriptionDefault
handleYesTwitter username

Input Schema (JSON Schema)

{ "properties": { "handle": { "description": "Twitter username", "type": "string" } }, "required": [ "handle" ], "type": "object" }

Implementation Reference

  • The handler function for the 'get_twitter_tweets' tool. It extracts the 'handle' parameter, makes an API request to fetch tweets, processes them with extractTwitterTweets, and returns the result as JSON.
    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 ), }, ], }; }
  • The tool schema definition including name, description, and input schema for 'get_twitter_tweets'.
    name: "get_twitter_tweets", description: "Get tweets from a Twitter/X user", inputSchema: { type: "object", properties: { handle: { type: "string", description: "Twitter username" }, }, required: ["handle"], }, },
  • 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, }; }); }
  • src/index.ts:349-350 (registration)
    Registration of the ListToolsRequestSchema handler which returns the list of tools including 'get_twitter_tweets'.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));

Latest Blog Posts

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/olamide-olaniyan/sociavault-mcp'

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