Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

userInfluenceMetrics

Calculate Twitter user influence scores and engagement metrics to analyze reach and audience interaction for any username.

Instructions

Calculate user influence scores and engagement metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesUsername to analyze influence metrics for
analyzeEngagementNoInclude engagement analysis (default: true)
analyzeReachNoInclude reach and influence scoring (default: true)

Implementation Reference

  • Core handler function that executes the userInfluenceMetrics tool. Fetches user profile and recent tweets using SocialData client, computes engagement metrics (avg likes/retweets/replies, engagement rate) and reach metrics (follower base, influence score), formats and returns the response.
    export const handleUserInfluenceMetrics: SocialDataHandler<UserInfluenceMetricsArgs> = async (
        _client: any,
        { username, analyzeEngagement = true, analyzeReach = true }: UserInfluenceMetricsArgs
    ) => {
        try {
            const socialClient = getSocialDataClient();
            
            if (!socialClient) {
                return createMissingApiKeyResponse('User Influence Metrics');
            }
            
            // Get user profile and recent tweets
            const [profile, tweets] = await Promise.all([
                socialClient.getUserProfile({ username, includeMetrics: true }),
                socialClient.getUserTweets({ username, maxResults: 20 })
            ]);
    
            const user = profile.data;
            const recentTweets = tweets.data || [];
            
            // Calculate influence metrics
            const metrics: any = {
                user: {
                    username: user.username,
                    followers: user.public_metrics?.followers_count || 0,
                    following: user.public_metrics?.following_count || 0,
                    verified: user.verified || false
                }
            };
    
            if (analyzeEngagement && recentTweets.length > 0) {
                const totalLikes = recentTweets.reduce((sum: number, tweet: any) => 
                    sum + (tweet.public_metrics?.like_count || 0), 0);
                const totalRetweets = recentTweets.reduce((sum: number, tweet: any) => 
                    sum + (tweet.public_metrics?.retweet_count || 0), 0);
                const totalReplies = recentTweets.reduce((sum: number, tweet: any) => 
                    sum + (tweet.public_metrics?.reply_count || 0), 0);
    
                metrics.engagement = {
                    avg_likes_per_tweet: Math.round(totalLikes / recentTweets.length),
                    avg_retweets_per_tweet: Math.round(totalRetweets / recentTweets.length),
                    avg_replies_per_tweet: Math.round(totalReplies / recentTweets.length),
                    engagement_rate: user.public_metrics?.followers_count > 0 ? 
                        Math.round(((totalLikes + totalRetweets + totalReplies) / recentTweets.length / 
                        user.public_metrics.followers_count) * 10000) / 100 : 0
                };
            }
    
            if (analyzeReach) {
                metrics.reach = {
                    follower_base: user.public_metrics?.followers_count || 0,
                    potential_reach: user.public_metrics?.followers_count || 0,
                    estimated_influence_score: Math.min(100, 
                        Math.log10((user.public_metrics?.followers_count || 1) + 1) * 20)
                };
            }
    
            return createSocialDataResponse(
                formatAnalytics(metrics, `Influence Metrics for @${username}`)
            );
        } catch (error) {
            throw new Error(formatSocialDataError(error as Error, 'user influence metrics'));
        }
    };
  • Tool schema definition including description and input validation schema for the userInfluenceMetrics tool, used for MCP tool registration.
    userInfluenceMetrics: {
        description: 'Calculate user influence scores and engagement metrics',
        inputSchema: {
            type: 'object',
            properties: {
                username: {
                    type: 'string',
                    description: 'Username to analyze influence metrics for'
                },
                analyzeEngagement: {
                    type: 'boolean',
                    description: 'Include engagement analysis (default: true)'
                },
                analyzeReach: {
                    type: 'boolean',
                    description: 'Include reach and influence scoring (default: true)'
                }
            },
            required: ['username']
        }
    },
  • TypeScript interface defining the input arguments for the userInfluenceMetrics handler.
    export interface UserInfluenceMetricsArgs {
        username: string;
        analyzeEngagement?: boolean;
        analyzeReach?: boolean;
    }
  • src/index.ts:451-454 (registration)
    Tool dispatch/registration in the main MCP server request handler switch statement, calling the specific handler function.
    case 'userInfluenceMetrics': {
        const args = request.params.arguments as any;
        response = await handleUserInfluenceMetrics(client, args);
        break;
  • src/index.ts:73-83 (registration)
    Import of the handleUserInfluenceMetrics handler function into the main index file for use in tool dispatching.
        handleUserInfluenceMetrics,
        handleGetFullThread,
        handleGetConversationTree,
        handleGetThreadMetrics,
        handleFindMutualConnections,
        handleAnalyzeFollowerDemographics,
        handleMapInfluenceNetwork,
        handleGetHashtagTrends,
        handleAnalyzeSentiment,
        handleTrackVirality
    } from './handlers/socialdata/index.js';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'calculate' but doesn't specify whether this is a read-only operation, requires authentication, has rate limits, or what the output format might be. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/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 purpose without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly.

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 the complexity of calculating influence metrics, no annotations, and no output schema, the description is incomplete. It doesn't explain what the output looks like, potential side effects, or error conditions. For a tool with no structured behavioral data, more context is needed to be fully helpful.

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 input schema already documents all parameters thoroughly. The description doesn't add any additional meaning beyond what's in the schema, such as explaining how 'analyzeEngagement' and 'analyzeReach' interact or providing usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose with specific verbs ('calculate') and resources ('user influence scores and engagement metrics'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'mapInfluenceNetwork' or 'userGrowthAnalytics', which might have overlapping functionality in analyzing user metrics.

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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'mapInfluenceNetwork' and 'userGrowthAnalytics' that might analyze similar user data, there's no indication of context, prerequisites, or exclusions to help an agent choose appropriately.

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/crazyrabbitLTC/mcp-twitter-server'

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