Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

findMutualConnections

Identify shared connections and interactions between two Twitter users by analyzing their mutual followers, retweets, and mentions. Use this tool to uncover common engagement patterns and relationships.

Instructions

Find mutual connections and interactions between two users

Input Schema

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

Implementation Reference

  • Implements the core logic for finding mutual connections between two users by searching for mutual mentions and interactions using the social data client, calculating connection strength and returning formatted analytics.
    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')); } };
  • Defines the tool description and input schema (using JSON schema) for validating arguments: user1, user2 (required), and optional maxResults.
    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)
    Registers the tool handler in the main MCP server request handler switch statement, dispatching calls to handleFindMutualConnections.
    case 'findMutualConnections': { const args = request.params.arguments as any; response = await handleFindMutualConnections(client, args); break;
  • src/index.ts:77-83 (registration)
    Imports the handleFindMutualConnections function (as part of socialdata handlers) for use in the MCP server.
    handleFindMutualConnections, handleAnalyzeFollowerDemographics, handleMapInfluenceNetwork, handleGetHashtagTrends, handleAnalyzeSentiment, handleTrackVirality } from './handlers/socialdata/index.js';

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