Skip to main content
Glama

live_search

Search the web in real-time to get current answers with source citations. Use this tool for fact-checking, current events, and up-to-date information from news, social media, and RSS feeds.

Instructions

Searches the web in real-time and provides answers with sources. This is like having Grok browse the internet for you. It searches the web, news, X (Twitter), and even RSS feeds, then synthesizes everything into a comprehensive answer. You'll get citations so you can verify the information. Great for current events, fact-checking, or anything requiring up-to-date information. Args: prompt: Your question or search query model: Which Grok model to use (default is grok-4) mode: "on" to enable search (default), "off" to disable return_citations: Whether to include source links (default True) from_date: Start date for search results (YYYY-MM-DD format) to_date: End date for search results (YYYY-MM-DD format) max_search_results: How many sources to check (default 20) country: Filter results by country code (e.g., "us", "uk") rss_links: List of RSS feed URLs to include sources: Custom source configuration (overrides country/rss_links if provided) system_prompt: Instructions for how to handle the search results Returns a dict with 'content' (the answer), 'citations' (sources used), 'usage' (tokens), and 'num_sources_used'.

Input Schema

NameRequiredDescriptionDefault
promptYes
modelNogrok-4
modeNoon
return_citationsNo
from_dateNo
to_dateNo
max_search_resultsNo
countryNo
rss_linksNo
sourcesNo
system_promptNo

Input Schema (JSON Schema)

{ "properties": { "country": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Country" }, "from_date": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "From Date" }, "max_search_results": { "default": 20, "title": "Max Search Results", "type": "integer" }, "mode": { "default": "on", "title": "Mode", "type": "string" }, "model": { "default": "grok-4", "title": "Model", "type": "string" }, "prompt": { "title": "Prompt", "type": "string" }, "return_citations": { "default": true, "title": "Return Citations", "type": "boolean" }, "rss_links": { "anyOf": [ { "items": { "type": "string" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Rss Links" }, "sources": { "anyOf": [ { "items": { "additionalProperties": true, "type": "object" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Sources" }, "system_prompt": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "System Prompt" }, "to_date": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "To Date" } }, "required": [ "prompt" ], "type": "object" }

Implementation Reference

  • The core handler function for the 'live_search' tool. It is decorated with @mcp.tool() which registers it with the MCP server. The function sends a chat completion request to the xAI API with search_parameters enabled, handling web, news, X, and RSS sources, and returns the response content, citations, and usage info.
    @mcp.tool() async def live_search( prompt: str, model: str = "grok-4", mode: str = "on", return_citations: bool = True, from_date: Optional[str] = None, to_date: Optional[str] = None, max_search_results: int = 20, country: Optional[str] = None, rss_links: Optional[List[str]] = None, sources: Optional[List[Dict[str, Any]]] = None, system_prompt: Optional[str] = None ) -> Dict[str, Any]: """ Searches the web in real-time and provides answers with sources. This is like having Grok browse the internet for you. It searches the web, news, X (Twitter), and even RSS feeds, then synthesizes everything into a comprehensive answer. You'll get citations so you can verify the information. Great for current events, fact-checking, or anything requiring up-to-date information. Args: prompt: Your question or search query model: Which Grok model to use (default is grok-4) mode: "on" to enable search (default), "off" to disable return_citations: Whether to include source links (default True) from_date: Start date for search results (YYYY-MM-DD format) to_date: End date for search results (YYYY-MM-DD format) max_search_results: How many sources to check (default 20) country: Filter results by country code (e.g., "us", "uk") rss_links: List of RSS feed URLs to include sources: Custom source configuration (overrides country/rss_links if provided) system_prompt: Instructions for how to handle the search results Returns a dict with 'content' (the answer), 'citations' (sources used), 'usage' (tokens), and 'num_sources_used'. """ messages = [] if system_prompt: messages.append({ "role": "system", "content": system_prompt }) messages.append({ "role": "user", "content": prompt }) search_params: Dict[str, Any] = { "mode": mode, "return_citations": return_citations } if from_date: search_params["from_date"] = from_date if to_date: search_params["to_date"] = to_date if max_search_results != 20: search_params["max_search_results"] = max_search_results if sources: search_params["sources"] = sources elif country or rss_links: default_sources = [] if country: default_sources.extend([ {"type": "web", "country": country}, {"type": "news", "country": country}, {"type": "x"} ]) else: default_sources.extend([ {"type": "web"}, {"type": "news"}, {"type": "x"} ]) if rss_links: for link in rss_links: default_sources.append({"type": "rss", "links": [link]}) search_params["sources"] = default_sources request_data = { "model": model, "messages": messages, "search_parameters": search_params } client = create_client() response = await client.post("/chat/completions", json=request_data) response.raise_for_status() data = response.json() choice = data["choices"][0] result = { "content": choice["message"]["content"], "usage": data.get("usage", {}), } if return_citations and "citations" in choice["message"]: result["citations"] = choice["message"]["citations"] if "num_sources_used" in data.get("usage", {}): result["num_sources_used"] = data["usage"]["num_sources_used"] await client.aclose() return result
  • src/server.py:364-364 (registration)
    The @mcp.tool() decorator registers the live_search function as an MCP tool.
    @mcp.tool()
  • The docstring provides the input schema (parameters) and output description for the live_search tool.
    """ Searches the web in real-time and provides answers with sources. This is like having Grok browse the internet for you. It searches the web, news, X (Twitter), and even RSS feeds, then synthesizes everything into a comprehensive answer. You'll get citations so you can verify the information. Great for current events, fact-checking, or anything requiring up-to-date information. Args: prompt: Your question or search query model: Which Grok model to use (default is grok-4) mode: "on" to enable search (default), "off" to disable return_citations: Whether to include source links (default True) from_date: Start date for search results (YYYY-MM-DD format) to_date: End date for search results (YYYY-MM-DD format) max_search_results: How many sources to check (default 20) country: Filter results by country code (e.g., "us", "uk") rss_links: List of RSS feed URLs to include sources: Custom source configuration (overrides country/rss_links if provided) system_prompt: Instructions for how to handle the search results Returns a dict with 'content' (the answer), 'citations' (sources used), 'usage' (tokens), and 'num_sources_used'. """

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