Skip to main content
Glama
Sacode

SearxNG MCP Server

by Sacode

web_search

Search the web through a privacy-respecting metasearch engine, returning results in human-readable text or structured JSON format with filtering options.

Instructions

Perform a web search using SearxNG and return formatted results.

Results are returned in either text format (human-readable) or JSON format depending on the result_format parameter selected.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query string to look for on the web
result_countNoMaximum number of results to return
categoriesNoCategories to filter by (e.g., 'general', 'images', 'news', 'videos')
languageNoLanguage code for results (e.g., 'all', 'en', 'ru', 'fr')all
time_rangeNoTime restriction for results
result_formatNoOutput format - 'text' for human-readable, 'json' for structured datatext

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'web_search' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Handles input parameters (defining the schema), performs the search via SearxNGClient, formats results in text or JSON, and includes error handling.
    @mcp.tool()
    async def web_search(
        query: str = _QUERY_FIELD,
        result_count: int = _RESULT_COUNT_FIELD,
        categories: list[str] | None = _CATEGORIES_FIELD,
        language: str | None = _LANGUAGE_FIELD,
        time_range: Literal["day", "week", "month", "year"] | None = _TIME_RANGE_FIELD,
        result_format: Literal["text", "json"] = _RESULT_FORMAT_FIELD,
        ctx: Context | None = None,
    ) -> str | list[SearxngResult]:
        """
        Perform a web search using SearxNG and return formatted results.
    
        Results are returned in either text format (human-readable) or JSON format
        depending on the result_format parameter selected.
    
        """
        try:
            # Inform about the search operation
            if ctx:
                await ctx.info("Starting web search...")
    
            # Validate inputs
            if result_count <= 0:
                raise ValueError("result_count must be greater than 0")
    
            # Perform the search using SearxNG
            response = await searxng_client.search(
                query=query,
                categories=categories,
                language=language,
                time_range=time_range,
            )
    
            results = response.results[:result_count]
    
            # Format results according to requested format
            if result_format == "json":
                # Return JSON-formatted results
                return results
            else:
                # Return human-readable text
                formatted_results = []
                for i, result in enumerate(results, 1):
                    title = result.title
                    url = result.url
                    content = result.content[:200] + "..."
                    formatted_results.append(f"{i}. [{title}]({url})\n   {content}")
    
                return "\n\n".join(formatted_results)
    
        except Exception as e:
            logger.error(f"Error during web search: {e}")
            if ctx:
                await ctx.info(f"Error during search: {e}")
            raise
Behavior2/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 that results are returned in text or JSON format based on a parameter, which adds some context about output behavior. However, it fails to disclose critical traits such as whether this is a read-only operation, potential rate limits, authentication needs, error handling, or any side effects. For a search tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured, consisting of two sentences that efficiently convey the core functionality and output format options. It avoids unnecessary details and is front-loaded with the main purpose. However, it could be slightly more polished by integrating the format explanation more seamlessly, but overall it's efficient with zero waste.

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?

Given the tool's moderate complexity (6 parameters, 1 required) and the presence of an output schema (which reduces the need to describe return values in the description), the description is somewhat complete but has gaps. It covers the basic action and output format but lacks usage guidelines, behavioral context, and deeper parameter insights. With no annotations and only partial compensation in the description, it's adequate but not fully comprehensive for effective agent use.

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%, meaning all parameters are well-documented in the input schema itself. The description adds minimal value beyond the schema by briefly mentioning the result_format parameter's effect on output format. However, it doesn't provide additional semantic context, examples, or usage tips for parameters like categories or time_range. Given the high schema coverage, a baseline score of 3 is appropriate as the description doesn't compensate with extra insights.

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

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs a web search using SearxNG and returns formatted results. It specifies the action ('perform a web search'), resource ('web'), and output format ('formatted results'), making the purpose explicit. However, it doesn't differentiate from siblings since there are none, so it doesn't reach the highest score of 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions the result_format parameter but doesn't explain when to choose text vs. JSON, nor does it discuss any prerequisites, limitations, or typical use cases. This lack of contextual guidance leaves the agent without direction on optimal usage.

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/Sacode/searxng-simple-mcp'

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