Skip to main content
Glama
martinchen448

SearXNG MCP Server

search

Perform web searches across multiple search engines aggregated by SearXNG, with options to filter by categories, languages, time ranges, and safe search levels for comprehensive results.

Instructions

Search the web using SearXNG search engine.

This tool performs web searches across multiple search engines aggregated by SearXNG. You can filter by categories (general, images, videos, news, etc.), specific engines, language, and time range. Returns comprehensive results including titles, URLs, content snippets, and metadata.

Use this when you need to:

  • Search for information on the web

  • Find recent news or articles

  • Search for images or videos

  • Get diverse results from multiple search engines

  • Research a topic across different sources

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query string
categoriesNoList of categories to search (e.g., ['general', 'images', 'news']). Available: general, images, videos, news, music, files, social media, science, it, map
enginesNoList of specific search engines to use (e.g., ['google', 'bing', 'duckduckgo'])
languageNoLanguage code for results (default: 'en')en
pageNoPage number for pagination (default: 1)
time_rangeNoTime range filter for results
safesearchNoSafe search level: 0=off, 1=moderate, 2=strict (default: 0)

Implementation Reference

  • Registration of the 'search' tool including its name, description, and input schema in the list_tools handler.
                    Tool(
                        name="search",
                        description="""Search the web using SearXNG search engine.
                        
    This tool performs web searches across multiple search engines aggregated by SearXNG.
    You can filter by categories (general, images, videos, news, etc.), specific engines,
    language, and time range. Returns comprehensive results including titles, URLs, content
    snippets, and metadata.
    
    Use this when you need to:
    - Search for information on the web
    - Find recent news or articles
    - Search for images or videos
    - Get diverse results from multiple search engines
    - Research a topic across different sources""",
                        inputSchema={
                            "type": "object",
                            "properties": {
                                "query": {
                                    "type": "string",
                                    "description": "The search query string",
                                },
                                "categories": {
                                    "type": "array",
                                    "items": {"type": "string"},
                                    "description": "List of categories to search (e.g., ['general', 'images', 'news']). Available: general, images, videos, news, music, files, social media, science, it, map",
                                },
                                "engines": {
                                    "type": "array",
                                    "items": {"type": "string"},
                                    "description": "List of specific search engines to use (e.g., ['google', 'bing', 'duckduckgo'])",
                                },
                                "language": {
                                    "type": "string",
                                    "description": "Language code for results (default: 'en')",
                                    "default": "en",
                                },
                                "page": {
                                    "type": "integer",
                                    "description": "Page number for pagination (default: 1)",
                                    "default": 1,
                                    "minimum": 1,
                                },
                                "time_range": {
                                    "type": "string",
                                    "enum": ["day", "month", "year"],
                                    "description": "Time range filter for results",
                                },
                                "safesearch": {
                                    "type": "integer",
                                    "enum": [0, 1, 2],
                                    "description": "Safe search level: 0=off, 1=moderate, 2=strict (default: 0)",
                                    "default": 0,
                                },
                            },
                            "required": ["query"],
                        },
                    ),
  • The handler logic within call_tool that executes the 'search' tool: calls SearXNGClient.search, formats results, and returns as TextContent.
    if name == "search":
        response = await client.search(
            query=arguments["query"],
            categories=arguments.get("categories"),
            engines=arguments.get("engines"),
            language=arguments.get("language", "en"),
            page=arguments.get("page", 1),
            time_range=arguments.get("time_range"),
            safesearch=arguments.get("safesearch", 0),
        )
    
        # Format results for better readability
        formatted_results = {
            "query": response.query,
            "number_of_results": response.number_of_results,
            "results": [
                {
                    "title": r.title,
                    "url": r.url,
                    "content": r.content,
                    "engine": r.engine,
                    "score": r.score,
                }
                for r in response.results
            ],
            "suggestions": response.suggestions,
            "answers": response.answers,
        }
    
        return [
            TextContent(
                type="text",
                text=json.dumps(formatted_results, indent=2),
            )
        ]
  • Input schema definition for the 'search' tool, specifying parameters like query, categories, engines, etc.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The search query string",
            },
            "categories": {
                "type": "array",
                "items": {"type": "string"},
                "description": "List of categories to search (e.g., ['general', 'images', 'news']). Available: general, images, videos, news, music, files, social media, science, it, map",
            },
            "engines": {
                "type": "array",
                "items": {"type": "string"},
                "description": "List of specific search engines to use (e.g., ['google', 'bing', 'duckduckgo'])",
            },
            "language": {
                "type": "string",
                "description": "Language code for results (default: 'en')",
                "default": "en",
            },
            "page": {
                "type": "integer",
                "description": "Page number for pagination (default: 1)",
                "default": 1,
                "minimum": 1,
            },
            "time_range": {
                "type": "string",
                "enum": ["day", "month", "year"],
                "description": "Time range filter for results",
            },
            "safesearch": {
                "type": "integer",
                "enum": [0, 1, 2],
                "description": "Safe search level: 0=off, 1=moderate, 2=strict (default: 0)",
                "default": 0,
            },
        },
        "required": ["query"],
  • Core search implementation in SearXNGClient that performs HTTP request to SearXNG /search endpoint and parses response.
    async def search(
        self,
        query: str,
        categories: Optional[List[str]] = None,
        engines: Optional[List[str]] = None,
        language: str = "en",
        page: int = 1,
        time_range: Optional[str] = None,
        safesearch: int = 0,
        format: str = "json",
    ) -> SearchResponse:
        """Perform a search query on SearXNG.
    
        Args:
            query: The search query string
            categories: List of categories to search (e.g., ["general", "images"])
            engines: List of specific engines to use
            language: Language code for results (default: "en")
            page: Page number for pagination (default: 1)
            time_range: Time range filter ("day", "month", "year")
            safesearch: Safe search level (0=off, 1=moderate, 2=strict)
            format: Response format (default: "json")
    
        Returns:
            SearchResponse containing search results
    
        Raises:
            httpx.HTTPError: If the request fails
        """
        url = urljoin(self.base_url, "/search")
    
        params: Dict[str, Any] = {
            "q": query,
            "format": format,
            "language": language,
            "pageno": page,
            "safesearch": safesearch,
        }
    
        if categories:
            params["categories"] = ",".join(categories)
        if engines:
            params["engines"] = ",".join(engines)
        if time_range:
            params["time_range"] = time_range
    
        response = await self.client.get(url, params=params)
        response.raise_for_status()
    
        data = response.json()
        return SearchResponse(**data)
  • Pydantic model defining the structure of SearXNG search response used in the tool.
    class SearchResponse(BaseModel):
        """Response from SearXNG search API."""
    
        query: str
        number_of_results: int = Field(alias="number_of_results")
        results: List[SearchResult]
        suggestions: List[str] = []
        answers: List[Any] = []  # Can be strings or dicts
        infoboxes: List[Dict[str, Any]] = []
        unresponsive_engines: List[str] = []
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool does ('performs web searches across multiple search engines aggregated by SearXNG') and what it returns ('comprehensive results including titles, URLs, content snippets, and metadata'), but lacks details on rate limits, authentication needs, error handling, or pagination behavior beyond the 'page' parameter. It adequately covers basic behavior but misses advanced operational context.

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 well-structured and appropriately sized. It starts with a clear purpose statement, followed by a brief explanation of functionality, and ends with a bulleted list of use cases. Every sentence adds value without redundancy, and the information is front-loaded for quick comprehension.

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

Completeness4/5

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

Given the tool's moderate complexity (7 parameters, no output schema, no annotations), the description is reasonably complete. It explains the tool's purpose, usage guidelines, and basic behavior, but lacks details on output format specifics, error conditions, or advanced behavioral traits like rate limiting. It compensates well for the absence of annotations and output schema, though not fully.

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 7 parameters thoroughly. The description adds marginal value by mentioning filtering capabilities ('filter by categories, specific engines, language, and time range') and listing some category examples, but doesn't provide additional syntax, format details, or constraints beyond what the schema specifies. This meets the baseline for high schema coverage.

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 ('Search the web using SearXNG search engine') and resources ('across multiple search engines aggregated by SearXNG'). It distinguishes itself from sibling tools (get_config, get_suggestions, health_check) by focusing on web search functionality rather than configuration retrieval, suggestions, or system health checks.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool through a bulleted list: 'Use this when you need to: - Search for information on the web - Find recent news or articles - Search for images or videos - Get diverse results from multiple search engines - Research a topic across different sources'. This clearly defines appropriate use cases without mentioning alternatives, which is sufficient given the tool's distinct purpose among siblings.

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/martinchen448/searxng-mcp-server'

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