Skip to main content
Glama

text_web_search

Search the web for information using text queries to retrieve relevant results from the internet.

Instructions

Perform a text web search using the provided query using DDGS.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to fetch results for. It should be a non-empty string.
regionNoOptional region to search in.uk-en
max_resultsNoThe maximum number of results to return. Default is 10, maximum is 100.
pagesNoThe number of pages to fetch. Default is 1, maximum is 10.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'text_web_search' tool, which performs a web search using the DDGS library based on the provided query, region, max_results, and pages parameters. It logs the search and returns the list of results.
    async def text_web_search(
        self,
        ctx: Context,
        query: Annotated[
            str,
            Field(
                ...,
                description="The search query to fetch results for. It should be a non-empty string.",
            ),
        ],
        region: Annotated[
            str | None,
            Field(default="uk-en", description="Optional region to search in."),
        ] = "uk-en",
        max_results: Annotated[
            int | None,
            Field(
                default=10,
                ge=1,
                le=100,
                description="The maximum number of results to return. Default is 10, maximum is 100.",
            ),
        ] = 10,
        pages: Annotated[
            int | None,
            Field(
                default=1,
                ge=1,
                le=10,
                description="The number of pages to fetch. Default is 1, maximum is 10.",
            ),
        ] = 1,
    ) -> list[dict[str, Any]]:
        """Perform a text web search using the provided query using DDGS."""
        await ctx.info(f"Performing text web search for query: {query}")
        results = DDGS().text(  # ty: ignore[unresolved-attribute]
            query=query, region=region, max_results=max_results, page=pages
        )
        if results:
            await ctx.info(f"Found {len(results)} results for the query.")
        return results
  • Registration of the 'text_web_search' tool in the PyMCP class's tools list, including its function name and tags.
    {
        "fn": "text_web_search",
        "tags": ["meta-search", "text-search", "searchexample"],
    },
  • Input schema defined via Pydantic Annotated types and Field descriptions for the tool parameters: query (required str), region (optional str, default 'uk-en'), max_results (optional int, 1-100, default 10), pages (optional int, 1-10, default 1). Output is list[dict[str, Any]].
    async def text_web_search(
        self,
        ctx: Context,
        query: Annotated[
            str,
            Field(
                ...,
                description="The search query to fetch results for. It should be a non-empty string.",
            ),
        ],
        region: Annotated[
            str | None,
            Field(default="uk-en", description="Optional region to search in."),
        ] = "uk-en",
        max_results: Annotated[
            int | None,
            Field(
                default=10,
                ge=1,
                le=100,
                description="The maximum number of results to return. Default is 10, maximum is 100.",
            ),
        ] = 10,
        pages: Annotated[
            int | None,
            Field(
                default=1,
                ge=1,
                le=10,
                description="The number of pages to fetch. Default is 1, maximum is 10.",
            ),
        ] = 1,
    ) -> list[dict[str, Any]]:
Behavior2/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. It mentions 'using DDGS' but doesn't disclose behavioral traits like rate limits, authentication needs, response format, or potential errors. This is a significant gap for a web search tool with no annotation coverage.

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 a single, efficient sentence with zero waste, front-loaded with the core purpose. It's appropriately sized for the tool's complexity.

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 has an output schema and 100% schema coverage, the description is minimally adequate. However, for a web search tool with no annotations, it lacks context on behavior, limitations, or error handling, making it incomplete for optimal 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?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond what the schema provides, such as query examples or region details, meeting the baseline for high coverage.

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 action ('Perform a text web search') and resource ('using DDGS'), with a specific verb and resource. However, it doesn't differentiate from sibling tools, which are unrelated (e.g., generate_password, greet), so no sibling distinction is needed or provided.

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?

No guidance on when to use this tool versus alternatives is provided. The description only states what it does, without context, prerequisites, or exclusions, leaving the agent to infer usage scenarios.

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/anirbanbasu/pymcp'

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