Skip to main content
Glama

x_search

Search and analyze X content using Grok's AI to extract insights from posts, images, and videos with customizable filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes
modelNogrok-4-1-fast-reasoning
allowed_x_handlesNo
excluded_x_handlesNo
from_dateNo
to_dateNo
enable_image_understandingNo
enable_video_understandingNo
include_inline_citationsNo
max_turnsNo

Implementation Reference

  • Implementation of the x_search tool handler in src/server.py.
    async def x_search(
        prompt: str,
        model: str = "grok-4-1-fast-reasoning",
        allowed_x_handles: Optional[List[str]] = None,
        excluded_x_handles: Optional[List[str]] = None,
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
        enable_image_understanding: bool = False,
        enable_video_understanding: bool = False,
        include_inline_citations: bool = False,
        max_turns: Optional[int] = None
    ):
    
        if allowed_x_handles and excluded_x_handles:
            raise ValueError("Cannot specify both allowed_x_handles and excluded_x_handles")
        if allowed_x_handles and len(allowed_x_handles) > 10:
            raise ValueError("allowed_x_handles max 10")
        if excluded_x_handles and len(excluded_x_handles) > 10:
            raise ValueError("excluded_x_handles max 10")
        
        client = Client(api_key=XAI_API_KEY)
        
        tool_params = build_params(
            allowed_x_handles=allowed_x_handles,
            excluded_x_handles=excluded_x_handles,
            from_date=datetime.strptime(from_date, "%d-%m-%Y") if from_date else None,
            to_date=datetime.strptime(to_date, "%d-%m-%Y") if to_date else None,
            enable_image_understanding=enable_image_understanding,
            enable_video_understanding=enable_video_understanding,
        )
        
        include_options = []
        if include_inline_citations:
            include_options.append("inline_citations")

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/merterbak/Grok-MCP'

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