Skip to main content
Glama
qwang07

Duck Duck MCP

by qwang07

search

Search the web using DuckDuckGo to find information, websites, and resources with configurable options for region, safe search, and result quantity.

Instructions

Search the web using DuckDuckGo

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
optionsNo

Implementation Reference

  • Handler for CallToolRequestSchema that implements the 'search' tool logic: validates input, performs web search using DuckDuckGo via 'duck-duck-scrape', processes results, and returns formatted JSON or error.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        const { name, arguments: args } = request.params;
    
        if (name !== "search") {
          throw Object.assign(
            new Error(`Unknown tool: ${name}`),
            { errorType: 'UNKNOWN_TOOL', name }
          );
        }
    
        const parsed = SearchArgsSchema.safeParse(args);
        if (!parsed.success) {
          throw Object.assign(
            new Error(`Invalid arguments: ${parsed.error}`),
            { errorType: 'INVALID_ARGS', details: parsed.error }
          );
        }
    
        const searchResults = await search(parsed.data.query, {
          region: parsed.data.options?.region || 'zh-cn',
          safeSearch: parsed.data.options?.safeSearch ? SafeSearchType[parsed.data.options.safeSearch] : SafeSearchType.MODERATE,
          maxResults: parsed.data.options?.numResults || 50
        });
    
        const response = processSearchResults(
          searchResults.results,
          parsed.data.query,
          {
            region: parsed.data.options?.region,
            safeSearch: parsed.data.options?.safeSearch ? SafeSearchType[parsed.data.options.safeSearch] : SafeSearchType.MODERATE
          }
        );
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(response, null, 2)
          }]
        };
      } catch (error) {
        const errorResponse = {
          type: 'search_error',
          message: error instanceof Error ? error.message : String(error),
          suggestion: '你可以尝试:1. 修改搜索关键词 2. 减少结果数量 3. 更换地区',
          context: {
            query: request.params.arguments?.query,
            options: request.params.arguments?.options
          }
        };
    
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(errorResponse, null, 2)
          }],
          isError: true
        };
      }
    });
  • Zod schema defining the input structure for the 'search' tool.
    const SearchArgsSchema = z.object({
      query: z.string(),
      options: z.object({
        region: z.string().default('zh-cn'),
        safeSearch: z.enum(['OFF', 'MODERATE', 'STRICT']).default('MODERATE'),
        numResults: z.number().default(50)
      }).optional()
    });
  • src/index.js:92-102 (registration)
    Registration of the 'search' tool in the ListToolsRequestSchema handler, providing name, description, and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "search",
            description: "Search the web using DuckDuckGo",
            inputSchema: zodToJsonSchema(SearchArgsSchema),
          }
        ],
      };
    });
  • Helper function that processes raw search results into a structured response with added metadata like content type, source, language detection, and topics.
    function processSearchResults(results, query, options) {
      return {
        type: 'search_results',
        data: results.map(result => ({
          title: result.title.replace(/'/g, "'").replace(/"/g, '"'),
          url: result.url,
          description: result.description.trim(),
          metadata: {
            type: detectContentType(result),
            source: new URL(result.url).hostname
          }
        })),
        metadata: {
          query,
          timestamp: new Date().toISOString(),
          resultCount: results.length,
          searchContext: {
            region: options.region || 'zh-cn',
            safeSearch: options.safeSearch?.toString() || 'MODERATE'
          },
          queryAnalysis: {
            language: detectLanguage(query),
            topics: detectTopics(results)
          }
        }
      };
    }
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 the search engine (DuckDuckGo) but doesn't describe rate limits, authentication needs, result format, pagination, or potential side effects. For a web search tool with zero annotation coverage, this leaves significant behavioral gaps.

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 extremely concise at just 5 words, front-loading the essential information with zero wasted words. Every word earns its place in conveying the core functionality.

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?

Given the tool has no annotations, no output schema, and 0% schema description coverage for its 2 parameters (including a nested object), the description is inadequate. It doesn't explain what the search returns, how results are structured, or provide any parameter guidance, leaving the agent with insufficient information for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the parameters have descriptions in the schema. The tool description mentions no parameters at all, failing to compensate for this gap. While 'query' is obvious for search, the 'options' object with region, safeSearch, and numResults remains completely 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 action ('Search') and the resource ('the web using DuckDuckGo'), providing a specific verb+resource combination. However, with no sibling tools mentioned, there's no opportunity to differentiate from alternatives, preventing a perfect score.

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, nor does it mention any prerequisites or contextual constraints. It simply states what the tool does without offering usage context.

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/qwang07/duck-duck-mcp'

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