Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

analyzeFollowerDemographics

Analyze Twitter follower demographics and engagement patterns to understand audience composition and interaction trends for strategic insights.

Instructions

Analyze follower demographics and engagement patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesUsername to analyze followers for
sampleSizeNoSample size for analysis (default: 50)
analyzeDemographicsNoInclude demographic breakdown (default: true)

Implementation Reference

  • The main handler function that implements the core logic for analyzing follower demographics by sampling user interactions (mentions) with the target account, computing statistics like verified percentage, average followers, distribution categories, and top interactors.
    export const handleAnalyzeFollowerDemographics: SocialDataHandler<FollowerAnalyticsArgs> = async (
        _client: any,
        { username, sampleSize = 50, analyzeDemographics = true }: FollowerAnalyticsArgs
    ) => {
        try {
            const socialClient = getSocialDataClient();
            
            if (!socialClient) {
                return createMissingApiKeyResponse('Follower Demographics Analysis');
            }
            
            // Get recent interactions to sample follower activity
            const mentionsQuery = `@${username}`;
            const mentionsResult = await socialClient.searchTweets({
                query: mentionsQuery,
                maxResults: sampleSize
            });
    
            // Get retweets of user's content
            const retweetsQuery = `from:${username}`;
            const userTweetsResult = await socialClient.searchTweets({
                query: retweetsQuery,
                maxResults: 25
            });
    
            const interactingUsers = new Map();
            
            // Analyze users who mention this account
            mentionsResult.data?.forEach((tweet: any) => {
                const user = tweet.user;
                if (user && user.screen_name !== username) {
                    interactingUsers.set(user.screen_name, {
                        screen_name: user.screen_name,
                        name: user.name,
                        followers_count: user.followers_count,
                        verified: user.verified,
                        interaction_type: 'mention'
                    });
                }
            });
    
            const sampleUsers = Array.from(interactingUsers.values());
            
            let analytics: any = {
                target_user: username,
                sample_size: sampleUsers.length,
                analysis_date: new Date().toISOString()
            };
    
            if (analyzeDemographics && sampleUsers.length > 0) {
                const verifiedCount = sampleUsers.filter(u => u.verified).length;
                const followerCounts = sampleUsers.map(u => u.followers_count || 0);
                const avgFollowers = followerCounts.reduce((a, b) => a + b, 0) / followerCounts.length;
                
                analytics.demographics = {
                    verified_percentage: Math.round((verifiedCount / sampleUsers.length) * 100),
                    average_follower_count: Math.round(avgFollowers),
                    follower_distribution: {
                        micro_influencers: followerCounts.filter(c => c >= 1000 && c < 100000).length,
                        regular_users: followerCounts.filter(c => c < 1000).length,
                        large_accounts: followerCounts.filter(c => c >= 100000).length
                    },
                    engagement_quality: sampleUsers.length > 20 ? 'High' : 
                                       sampleUsers.length > 10 ? 'Medium' : 'Low'
                };
    
                analytics.top_interacting_users = sampleUsers
                    .sort((a, b) => (b.followers_count || 0) - (a.followers_count || 0))
                    .slice(0, 10)
                    .map(u => ({
                        username: u.screen_name,
                        name: u.name,
                        followers: u.followers_count,
                        verified: u.verified
                    }));
            }
    
            return createSocialDataResponse(
                formatAnalytics(analytics, `Follower Demographics Analysis for @${username}`)
            );
        } catch (error) {
            throw new Error(formatSocialDataError(error as Error, 'follower analytics'));
        }
    };
  • Zod schema definition and input validation structure for the analyzeFollowerDemographics tool, defining required username and optional sampleSize and analyzeDemographics parameters.
    analyzeFollowerDemographics: {
        description: 'Analyze follower demographics and engagement patterns',
        inputSchema: {
            type: 'object',
            properties: {
                username: {
                    type: 'string',
                    description: 'Username to analyze followers for'
                },
                sampleSize: {
                    type: 'number',
                    description: 'Sample size for analysis (default: 50)',
                    minimum: 10,
                    maximum: 100
                },
                analyzeDemographics: {
                    type: 'boolean',
                    description: 'Include demographic breakdown (default: true)'
                }
            },
            required: ['username']
        }
    },
  • src/index.ts:478-481 (registration)
    Tool dispatch registration in the main MCP server request handler switch statement, routing 'analyzeFollowerDemographics' tool calls to the specific handler function.
    case 'analyzeFollowerDemographics': {
        const args = request.params.arguments as any;
        response = await handleAnalyzeFollowerDemographics(client, args);
        break;
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 analysis but doesn't specify what the analysis entails (e.g., types of demographics, engagement metrics), whether it's read-only or has side effects, rate limits, or authentication requirements. For a tool with no annotations, this leaves significant behavioral gaps.

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 with no wasted words, clearly front-loading the core purpose. It's appropriately sized for the tool's complexity, making it easy to scan and understand 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 tool's moderate complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks details on behavioral traits (e.g., read-only vs. side effects), output format, or how it differs from sibling analytics tools. Without annotations or an output schema, the description should provide more context 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 schema already documents all three parameters (username, sampleSize, analyzeDemographics) with descriptions and constraints. The description adds no additional parameter semantics beyond what the schema provides, such as explaining how the sample is selected or what demographic data is included. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Analyze follower demographics and engagement patterns' clearly states the tool's purpose with a specific verb ('analyze') and resource ('follower demographics and engagement patterns'), but it doesn't differentiate from sibling tools like 'getFollowers', 'userGrowthAnalytics', or 'userInfluenceMetrics' that might provide related analytics. The purpose is understandable but lacks sibling distinction.

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 such as 'getFollowers' (which retrieves follower lists), 'userGrowthAnalytics' (which might analyze growth trends), and 'userInfluenceMetrics' (which could assess influence), there's no indication of when this specific analysis tool is preferred or what prerequisites exist for its use.

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