Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

mapInfluenceNetwork

Analyze Twitter user influence by mapping connections and patterns around a central account to understand network relationships.

Instructions

Map user influence network and connection patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
centerUserYesCentral user to map network around
depthNoNetwork depth to analyze (default: 2)
connectionTypesNoTypes of connections to analyze

Implementation Reference

  • Main handler function implementing the mapInfluenceNetwork tool. Builds an influence network by analyzing tweet mentions to/from the center user, calculating metrics like incoming/outgoing connections, influence scores, and network insights.
    export const handleMapInfluenceNetwork: SocialDataHandler<NetworkMappingArgs> = async (
        _client: any,
        { centerUser, depth = 2, connectionTypes = ['followers', 'following', 'mutual'] }: NetworkMappingArgs
    ) => {
        try {
            const socialClient = getSocialDataClient();
            
            if (!socialClient) {
                return createMissingApiKeyResponse('Influence Network Mapping');
            }
            
            // Get users who frequently interact with the center user
            const mentionsQuery = `@${centerUser}`;
            const mentionsResult = await socialClient.searchTweets({
                query: mentionsQuery,
                maxResults: 100
            });
    
            // Get users the center user mentions
            const centerMentionsQuery = `from:${centerUser} @`;
            const centerMentionsResult = await socialClient.searchTweets({
                query: centerMentionsQuery,
                maxResults: 50
            });
    
            // Build network map
            const networkNodes = new Map();
            
            // Add center user
            networkNodes.set(centerUser, {
                username: centerUser,
                type: 'center',
                connections: [],
                influence_score: 100
            });
    
            // Process mentions TO the center user (incoming connections)
            const incomingConnections = new Map();
            mentionsResult.data?.forEach((tweet: any) => {
                const user = tweet.user;
                if (user && user.screen_name !== centerUser) {
                    const existing = incomingConnections.get(user.screen_name) || 0;
                    incomingConnections.set(user.screen_name, existing + 1);
                    
                    if (!networkNodes.has(user.screen_name)) {
                        networkNodes.set(user.screen_name, {
                            username: user.screen_name,
                            name: user.name,
                            type: 'incoming',
                            mention_frequency: existing + 1,
                            followers_count: user.followers_count,
                            verified: user.verified,
                            influence_score: Math.min(90, (user.followers_count || 0) / 1000)
                        });
                    }
                }
            });
    
            // Process mentions FROM the center user (outgoing connections)
            const outgoingConnections = new Set();
            centerMentionsResult.data?.forEach((tweet: any) => {
                const mentions = tweet.text?.match(/@(\w+)/g) || [];
                mentions.forEach((mention: string) => {
                    const username = mention.substring(1);
                    if (username !== centerUser) {
                        outgoingConnections.add(username);
                        
                        if (!networkNodes.has(username)) {
                            networkNodes.set(username, {
                                username,
                                type: 'outgoing',
                                influence_score: 50
                            });
                        }
                    }
                });
            });
    
            // Calculate network metrics
            const networkMap = {
                center_user: centerUser,
                network_depth: depth,
                total_nodes: networkNodes.size,
                connection_types: connectionTypes,
                network_metrics: {
                    incoming_connections: incomingConnections.size,
                    outgoing_connections: outgoingConnections.size,
                    total_unique_connections: new Set([...incomingConnections.keys(), ...outgoingConnections]).size,
                    network_density: Math.round((incomingConnections.size + outgoingConnections.size) / 2),
                    influence_centrality: Math.min(100, (incomingConnections.size * 2) + outgoingConnections.size)
                },
                top_connected_users: Array.from(networkNodes.values())
                    .filter(node => node.type !== 'center')
                    .sort((a, b) => (b.influence_score || 0) - (a.influence_score || 0))
                    .slice(0, 15)
                    .map(node => ({
                        username: node.username,
                        name: node.name,
                        connection_type: node.type,
                        influence_score: Math.round(node.influence_score || 0),
                        followers: node.followers_count,
                        verified: node.verified
                    })),
                network_insights: {
                    most_active_mentioner: Array.from(incomingConnections.entries())
                        .sort(([,a], [,b]) => b - a)[0]?.[0] || 'None',
                    network_reach_estimate: Math.round(
                        Array.from(networkNodes.values())
                            .reduce((sum, node) => sum + (node.followers_count || 0), 0) / 1000
                    ) + 'K',
                    connection_strength: incomingConnections.size > 20 ? 'Strong' : 
                                       incomingConnections.size > 5 ? 'Moderate' : 'Developing'
                }
            };
    
            return createSocialDataResponse(
                formatAnalytics(networkMap, `Influence Network Map for @${centerUser}`)
            );
        } catch (error) {
            throw new Error(formatSocialDataError(error as Error, 'influence network mapping'));
        }
    };
  • Input schema definition and description for the mapInfluenceNetwork tool, specifying parameters like centerUser, depth, and connectionTypes.
    mapInfluenceNetwork: {
        description: 'Map user influence network and connection patterns',
        inputSchema: {
            type: 'object',
            properties: {
                centerUser: {
                    type: 'string',
                    description: 'Central user to map network around'
                },
                depth: {
                    type: 'number',
                    description: 'Network depth to analyze (default: 2)',
                    minimum: 1,
                    maximum: 3
                },
                connectionTypes: {
                    type: 'array',
                    items: {
                        type: 'string',
                        enum: ['followers', 'following', 'mutual']
                    },
                    description: 'Types of connections to analyze'
                }
            },
            required: ['centerUser']
        }
    },
  • src/tools.ts:736-738 (registration)
    Registers the mapInfluenceNetwork tool by spreading SOCIALDATA_TOOLS into the main TOOLS object used by the MCP server for listTools.
        // SocialData.tools enhanced research and analytics
        ...SOCIALDATA_TOOLS
    }; 
  • src/index.ts:483-486 (registration)
    Dispatches calls to the mapInfluenceNetwork tool handler in the main CallToolRequestSchema handler switch statement.
    case 'mapInfluenceNetwork': {
        const args = request.params.arguments as any;
        response = await handleMapInfluenceNetwork(client, args);
        break;
  • Re-exports the handleMapInfluenceNetwork handler from network.handlers.ts, making it available for import in src/index.ts.
    export * from './network.handlers.js';
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions mapping and analyzing but doesn't specify whether this is a read-only operation, what permissions are required, how results are returned, or any rate limits. This is inadequate for a tool that likely involves data analysis.

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 front-loads the core purpose without unnecessary words. Every part earns its place, making it highly concise and well-structured.

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 mapping influence networks, no annotations, and no output schema, the description is incomplete. It doesn't explain what the output looks like, how to interpret results, or any behavioral traits, leaving significant gaps for an AI agent.

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 parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as explaining how 'depth' affects analysis or what 'connectionTypes' imply. 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.

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 a specific verb ('Map') and resource ('user influence network and connection patterns'), making it distinct from most sibling tools that focus on tweets, users, or lists. However, it doesn't explicitly differentiate from 'findMutualConnections' or 'userInfluenceMetrics', which could be related.

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 like 'findMutualConnections' or 'userInfluenceMetrics', nor does it mention prerequisites or exclusions. Usage is implied by the purpose but lacks explicit 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/crazyrabbitLTC/mcp-twitter-server'

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