Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

findMutualConnections

Identify shared connections and interactions between two Twitter users to analyze their network relationships and common engagements.

Instructions

Find mutual connections and interactions between two users

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user1YesFirst username (without @)
user2YesSecond username (without @)
maxResultsNoMaximum results to return (default: 20)

Implementation Reference

  • The main handler function that implements the findMutualConnections tool logic. It searches for direct mentions between two users and users who mention both, computing connection strength and mutual interactions using Twitter search API.
    export const handleFindMutualConnections: SocialDataHandler<CommonFollowersArgs> = async (
        _client: any,
        { user1, user2, maxResults = 20 }: CommonFollowersArgs
    ) => {
        try {
            const socialClient = getSocialDataClient();
            
            if (!socialClient) {
                return createMissingApiKeyResponse('Mutual Connections Analysis');
            }
            
            // Get interactions between the users by searching for mentions
            const mutualMentionsQuery = `(from:${user1} @${user2}) OR (from:${user2} @${user1})`;
            const mentionsResult = await socialClient.searchTweets({
                query: mutualMentionsQuery,
                maxResults: 50
            });
    
            // Get users who mention both
            const bothMentionedQuery = `@${user1} @${user2}`;
            const bothMentionedResult = await socialClient.searchTweets({
                query: bothMentionedQuery,
                maxResults: maxResults
            });
    
            // Extract unique users from interactions
            const interactingUsers = new Set();
            [...(mentionsResult.data || []), ...(bothMentionedResult.data || [])].forEach((tweet: any) => {
                if (tweet.user?.screen_name && 
                    tweet.user.screen_name !== user1 && 
                    tweet.user.screen_name !== user2) {
                    interactingUsers.add(tweet.user.screen_name);
                }
            });
    
            const mutualConnections = {
                user1,
                user2,
                direct_interactions: {
                    count: mentionsResult.data?.length || 0,
                    recent_mentions: mentionsResult.data?.slice(0, 5).map((tweet: any) => ({
                        from: tweet.user?.screen_name,
                        text: tweet.text?.substring(0, 140),
                        date: tweet.tweet_created_at
                    })) || []
                },
                mutual_interactions: {
                    users_mentioning_both: Array.from(interactingUsers).slice(0, maxResults),
                    count: interactingUsers.size,
                    sample_tweets: bothMentionedResult.data?.slice(0, 3).map((tweet: any) => ({
                        author: tweet.user?.screen_name,
                        text: tweet.text?.substring(0, 140),
                        date: tweet.tweet_created_at
                    })) || []
                },
                connection_strength: {
                    direct_mentions: mentionsResult.data?.length || 0,
                    mutual_mention_network: interactingUsers.size,
                    estimated_relationship: interactingUsers.size > 5 ? 'Strong' : 
                                           interactingUsers.size > 1 ? 'Moderate' : 'Weak'
                }
            };
    
            return createSocialDataResponse(
                formatAnalytics(mutualConnections, `Mutual Connections: @${user1} ↔ @${user2}`)
            );
        } catch (error) {
            throw new Error(formatSocialDataError(error as Error, 'mutual connections analysis'));
        }
    };
  • Tool schema definition including description and input validation schema for findMutualConnections.
    findMutualConnections: {
        description: 'Find mutual connections and interactions between two users',
        inputSchema: {
            type: 'object',
            properties: {
                user1: {
                    type: 'string',
                    description: 'First username (without @)'
                },
                user2: {
                    type: 'string',
                    description: 'Second username (without @)'
                },
                maxResults: {
                    type: 'number',
                    description: 'Maximum results to return (default: 20)',
                    minimum: 5,
                    maximum: 50
                }
            },
            required: ['user1', 'user2']
        }
    },
  • src/index.ts:473-476 (registration)
    Registration in the main tool dispatcher switch statement, mapping the tool name to its handler function.
    case 'findMutualConnections': {
        const args = request.params.arguments as any;
        response = await handleFindMutualConnections(client, args);
        break;
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. While 'find' implies a read operation, it doesn't specify what 'mutual connections and interactions' actually returns (e.g., list of users, interaction metrics, timestamps), whether there are rate limits, authentication requirements, or data freshness considerations. For a social network analysis tool with zero annotation coverage, this is inadequate.

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 gets straight to the point with zero wasted words. It's appropriately sized for a tool with clear parameters documented elsewhere and follows good front-loading principles.

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?

For a tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'mutual connections and interactions' means operationally, what format the results take, or how this differs from related sibling tools. The combination of missing behavioral context and lack of output information creates 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 three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

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 verb 'find' and the resource 'mutual connections and interactions between two users', making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'getFollowers' or 'getFollowing', but the focus on mutual relationships is specific enough to avoid confusion with those individual relationship tools.

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 many sibling tools for analyzing user relationships (getFollowers, getFollowing, mapInfluenceNetwork, userInfluenceMetrics), there's no indication of when mutual connections analysis is preferred over individual relationship queries or broader network analysis.

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