Skip to main content
Glama
Aas-ee
by Aas-ee

search

Perform web searches across multiple engines like Bing, Baidu, DuckDuckGo, and more without needing API keys. Customize queries, set result limits, and choose preferred search engines for tailored results.

Instructions

Search the web using multiple engines (e.g., Baidu, Bing, DuckDuckGo, CSDN, Exa, Brave, Juejin(掘金)) with no API key required

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enginesNo
limitNo
queryYes

Implementation Reference

  • The handler function for the 'search' tool. It takes query, limit, and engines parameters, executes the search using executeSearch, formats results as JSON text content, and handles errors.
    async ({query, limit = 10, engines = ['bing']}) => {
        try {
            console.error(`Searching for "${query}" using engines: ${engines.join(', ')}`);
    
            const results = await executeSearch(query.trim(), engines, limit);
    
            return {
                content: [{
                    type: 'text',
                    text: JSON.stringify({
                        query: query.trim(),
                        engines: engines,
                        totalResults: results.length,
                        results: results
                    }, null, 2)
                }]
            };
        } catch (error) {
            console.error('Search tool execution failed:', error);
            return {
                content: [{
                    type: 'text',
                    text: `Search failed: ${error instanceof Error ? error.message : 'Unknown error'}`
                }],
                isError: true
            };
        }
  • Zod input schema for the 'search' tool defining parameters: query (required string), limit (number 1-50, default 10), engines (array of allowed engines with transformation for filtering).
        query: z.string().min(1, "Search query must not be empty"),
        limit: z.number().min(1).max(50).default(10),
        engines: z.array(getEnginesEnum()).min(1).default([config.defaultSearchEngine])
            .transform(requestedEngines => {
                // 如果有配置允许的搜索引擎,过滤请求的引擎
                if (config.allowedSearchEngines.length > 0) {
                    const filteredEngines = requestedEngines.filter(engine =>
                        config.allowedSearchEngines.includes(engine));
    
                    // 如果所有请求的引擎都被过滤掉,使用默认引擎
                    return filteredEngines.length > 0 ?
                        filteredEngines :
                        [config.defaultSearchEngine];
                }
                return requestedEngines;
            })
    },
  • Registers the 'search' tool (name configurable via MCP_TOOL_SEARCH_NAME env var, default 'search') on the MCP server with description, schema, and handler.
    server.tool(
        searchToolName,
        getSearchDescription(),
        {
            query: z.string().min(1, "Search query must not be empty"),
            limit: z.number().min(1).max(50).default(10),
            engines: z.array(getEnginesEnum()).min(1).default([config.defaultSearchEngine])
                .transform(requestedEngines => {
                    // 如果有配置允许的搜索引擎,过滤请求的引擎
                    if (config.allowedSearchEngines.length > 0) {
                        const filteredEngines = requestedEngines.filter(engine =>
                            config.allowedSearchEngines.includes(engine));
    
                        // 如果所有请求的引擎都被过滤掉,使用默认引擎
                        return filteredEngines.length > 0 ?
                            filteredEngines :
                            [config.defaultSearchEngine];
                    }
                    return requestedEngines;
                })
        },
        async ({query, limit = 10, engines = ['bing']}) => {
            try {
                console.error(`Searching for "${query}" using engines: ${engines.join(', ')}`);
    
                const results = await executeSearch(query.trim(), engines, limit);
    
                return {
                    content: [{
                        type: 'text',
                        text: JSON.stringify({
                            query: query.trim(),
                            engines: engines,
                            totalResults: results.length,
                            results: results
                        }, null, 2)
                    }]
                };
            } catch (error) {
                console.error('Search tool execution failed:', error);
                return {
                    content: [{
                        type: 'text',
                        text: `Search failed: ${error instanceof Error ? error.message : 'Unknown error'}`
                    }],
                    isError: true
                };
            }
        }
    );
  • Helper function that executes parallel searches across multiple engines, distributes the limit evenly, handles individual engine failures gracefully, and aggregates results.
    const executeSearch = async (query: string, engines: string[], limit: number): Promise<SearchResult[]> => {
        // Clean up the query string to ensure it won't cause issues due to spaces or special characters
        const cleanQuery = query.trim();
        console.error(`[DEBUG] Executing search, query: "${cleanQuery}", engines: ${engines.join(', ')}, limit: ${limit}`);
    
        if (!cleanQuery) {
            console.error('Query string is empty');
            throw new Error('Query string cannot be empty');
    
        }
    
        const limits = distributeLimit(limit, engines.length);
    
        const searchTasks = engines.map((engine, index) => {
            const engineLimit = limits[index];
            const searchFn = engineMap[engine as SupportedEngine];
    
            if (!searchFn) {
                console.warn(`Unsupported search engine: ${engine}`);
                return Promise.resolve([]);
            }
    
            return searchFn(query, engineLimit).catch(error => {
                console.error(`Search failed for engine ${engine}:`, error);
                return [];
            });
        });
    
        try {
            const results = await Promise.all(searchTasks);
            return results.flat().slice(0, limit);
        } catch (error) {
            console.error('Search execution failed:', error);
            throw error;
        }
    };
  • Mapping of supported search engines to their respective search functions imported from engines directories.
    const engineMap: Record<SupportedEngine, (query: string, limit: number) => Promise<SearchResult[]>> = {
        baidu: searchBaidu,
        bing: searchBing,
        linuxdo: searchLinuxDo,
        csdn: searchCsdn,
        duckduckgo: searchDuckDuckGo,
        exa: searchExa,
        brave: searchBrave,
        juejin: searchJuejin,
    };
  • src/index.ts:20-21 (registration)
    Calls setupTools on the MCP server instance, which registers all tools including 'search'.
    // Set up server tools
    setupTools(server);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'no API key required' which is useful context about authentication needs, but fails to describe critical behaviors like rate limits, result format, pagination, or whether this is a read-only operation. For a search tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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 perfectly concise - a single sentence that efficiently communicates the core functionality and key feature (no API key). Every word earns its place with no redundancy or unnecessary elaboration.

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

Completeness2/5

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

For a search tool with 3 parameters, 0% schema description coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain what results look like, how they're structured, whether there are usage limits, or provide sufficient parameter guidance. The 'no API key required' is helpful but doesn't compensate for the overall lack of context.

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 0%, so the description must compensate for parameter documentation. It mentions 'multiple engines' and lists examples that correspond to the 'engines' parameter enum values, adding some semantic context. However, it doesn't explain the 'query' or 'limit' parameters at all, leaving half the parameters undocumented in both schema and description.

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's purpose: 'Search the web using multiple engines' with specific examples provided (Baidu, Bing, etc.). It distinguishes itself from sibling tools (which fetch specific articles from single sources) by offering multi-engine web search. However, it doesn't specify the exact verb+resource combination (e.g., 'retrieve web search results') with complete precision.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'no API key required,' suggesting this tool is accessible without authentication. However, it provides no explicit guidance on when to use this tool versus the sibling article-fetching tools, nor does it mention any exclusions or alternatives for different search 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

Related 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/Aas-ee/open-webSearch'

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