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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'recent tweets' which implies a time-based scope, but doesn't specify what 'recent' means, whether authentication is required, rate limits, or the format of returned data. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. However, it could be more front-loaded with additional context to improve utility, slightly reducing the score.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'recent' means, authentication requirements, rate limits, or the structure of returned tweets. For a tool that retrieves user data, this leaves critical gaps in understanding how to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the single parameter 'count'. The description doesn't add any parameter-specific information beyond what's in the schema, but since the schema does the heavy lifting, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('user's recent tweets'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'search_tweets' which might also retrieve tweets, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'search_tweets' or 'post_tweet'. The description only states what it does, not when it's appropriate, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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