Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

advancedTweetSearch

Search Twitter tweets using advanced operators and filters to find specific content while bypassing API tier restrictions.

Instructions

Advanced tweet search with operators and filters, bypassing API tier restrictions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query with advanced operators (e.g., "AI OR ML -crypto lang:en")
maxResultsNoMaximum number of results to return (default: 10, max: 100)
startTimeNoStart time for search in ISO 8601 format (e.g., "2024-01-01T00:00:00Z")
endTimeNoEnd time for search in ISO 8601 format
includeRetweetsNoWhether to include retweets in results (default: true)
languageNoLanguage code to filter tweets (e.g., "en", "es", "fr")

Implementation Reference

  • The primary handler function that executes the advanced tweet search logic. It constructs a search query with optional filters for retweets and language, calls the socialDataClient to perform the search, and formats the tweet results.
    export const handleAdvancedTweetSearch: SocialDataHandler<AdvancedSearchArgs> = async (
        _client: any,
        { query, maxResults = 10, startTime, endTime, includeRetweets = true, language }: AdvancedSearchArgs
    ) => {
        try {
            const socialClient = getSocialDataClient();
            
            if (!socialClient) {
                return createMissingApiKeyResponse('Advanced Tweet Search');
            }
            
            // Build advanced query with operators
            let searchQuery = query;
            if (!includeRetweets) {
                searchQuery += ' -is:retweet';
            }
            if (language) {
                searchQuery += ` lang:${language}`;
            }
            
            const result = await socialClient.searchTweets({
                query: searchQuery,
                maxResults,
                startTime,
                endTime
            });
    
            if (!result.data || result.data.length === 0) {
                return createSocialDataResponse(`No tweets found for advanced search: ${query}`);
            }
    
            return createSocialDataResponse(
                formatTweetList(result.data, `Advanced Search Results for "${query}" (${result.data.length} tweets)`)
            );
        } catch (error) {
            throw new Error(formatSocialDataError(error as Error, 'advanced tweet search'));
        }
    };
  • Defines the tool description and input schema (including parameters like query, maxResults, time ranges, retweet filter, and language) for advancedTweetSearch.
    advancedTweetSearch: {
        description: 'Advanced tweet search with operators and filters, bypassing API tier restrictions',
        inputSchema: {
            type: 'object',
            properties: {
                query: {
                    type: 'string',
                    description: 'Search query with advanced operators (e.g., "AI OR ML -crypto lang:en")'
                },
                maxResults: {
                    type: 'number',
                    description: 'Maximum number of results to return (default: 10, max: 100)',
                    minimum: 1,
                    maximum: 100
                },
                startTime: {
                    type: 'string',
                    description: 'Start time for search in ISO 8601 format (e.g., "2024-01-01T00:00:00Z")'
                },
                endTime: {
                    type: 'string',
                    description: 'End time for search in ISO 8601 format'
                },
                includeRetweets: {
                    type: 'boolean',
                    description: 'Whether to include retweets in results (default: true)'
                },
                language: {
                    type: 'string',
                    description: 'Language code to filter tweets (e.g., "en", "es", "fr")'
                }
            },
            required: ['query']
        }
    },
  • src/tools.ts:736-737 (registration)
    Registers the advancedTweetSearch tool (and other SocialData tools) into the main TOOLS object by spreading SOCIALDATA_TOOLS. This TOOLS export is used by the MCP server for tool discovery via ListToolsRequestHandler.
    // SocialData.tools enhanced research and analytics
    ...SOCIALDATA_TOOLS
  • src/index.ts:426-429 (registration)
    Dispatches calls to the advancedTweetSearch handler in the main CallToolRequestHandler switch statement in the MCP server.
    case 'advancedTweetSearch': {
        const args = request.params.arguments as any;
        response = await handleAdvancedTweetSearch(client, args);
        break;
Behavior3/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 'bypassing API tier restrictions' which is valuable behavioral context about capability beyond standard search. However, it doesn't disclose other important behaviors like rate limits, authentication requirements, whether results are real-time or historical, or what format the results return.

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 perfectly concise - a single sentence that communicates the core functionality ('advanced tweet search with operators and filters') and unique value proposition ('bypassing API tier restrictions') with zero wasted words. It's front-loaded with the most important information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 6 parameters, 100% schema coverage, but no output schema and no annotations, the description provides adequate but incomplete context. It explains the 'what' and hints at unique capabilities, but doesn't address result format, pagination, error conditions, or how it differs from other search tools in the sibling list.

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?

The schema description coverage is 100%, so the schema already fully documents all 6 parameters. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. This meets the baseline of 3 for high schema coverage, but doesn't provide additional semantic context about how parameters interact or advanced usage patterns.

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

Purpose5/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 ('advanced tweet search') and resources ('tweets'), and explicitly distinguishes it from potential siblings by mentioning 'bypassing API tier restrictions' - a unique capability not implied by other search tools like 'searchTweets' or 'historicalTweetSearch'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool ('advanced tweet search with operators and filters'), but doesn't explicitly state when NOT to use it or name specific alternatives. It implies this is for complex searches beyond basic functionality, but lacks explicit comparison to sibling tools like 'searchTweets'.

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