Skip to main content
Glama

get_user_timeline

Retrieve recent tweets from a user's timeline using the X API. Specify tweet count to fetch up to 100 posts for timeline analysis or content review.

Instructions

Get the user's recent tweets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of tweets to retrieve (max 100)

Implementation Reference

  • The handler function that initializes the Twitter client if needed, fetches the user's own ID, retrieves recent tweets from the user timeline using Twitter API v2, formats them into a list, and returns as a text content block. Falls back to user info if timeline fetch fails.
    private async getUserTimeline(args: any) { if (!this.twitterClient) { throw new Error("Twitter client not initialized"); } const count = Math.min(args.count || 10, 100); try { const me = await this.twitterClient.v2.me(); const tweets = await this.twitterClient.v2.userTimeline(me.data.id, { max_results: count, "tweet.fields": ["created_at", "public_metrics"], expansions: ["author_id"], }); const tweetList = tweets.data.data || []; const formattedTweets = tweetList .map((tweet) => `- ${tweet.text} (${tweet.id})`) .join("\n"); return { content: [ { type: "text", text: `Your recent tweets:\n${formattedTweets}`, }, ], }; } catch (error) { // If timeline fails, just return user info const me = await this.twitterClient.v2.me(); return { content: [ { type: "text", text: `User: @${me.data.username} (${me.data.name})\nTimeline access may be restricted.`, }, ], }; } }
  • Input schema definition for the get_user_timeline tool, specifying an optional 'count' property as a number with default 10.
    inputSchema: { type: "object", properties: { count: { type: "number", description: "Number of tweets to retrieve (max 100)", default: 10, }, }, },
  • src/index.ts:50-63 (registration)
    Tool registration entry in the getTools() method, providing name, description, and input schema for listTools response.
    { name: "get_user_timeline", description: "Get the user's recent tweets", inputSchema: { type: "object", properties: { count: { type: "number", description: "Number of tweets to retrieve (max 100)", default: 10, }, }, }, },
  • src/index.ts:111-112 (registration)
    Switch case in the CallToolRequestSchema handler that routes calls to the getUserTimeline method.
    case "get_user_timeline": return await this.getUserTimeline(args);

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/krishna-paulraj/x-mcp-server'

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