Skip to main content
Glama

deep-research

Conduct in-depth web research by submitting a question, keywords, and topic. Supports multiple search rounds and reference materials.

Instructions

Deep web information search tool that can conduct multi-round in-depth research based on keywords and topics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionYesUser question
referenceNoReference materials
keywordsNoSearch keywords, please provide 1~5 keywords. Each keyword must: include complete subject and predicate, avoid pronouns and references, have independent search value, avoid logical overlap between keywords, and be directly relevant to the question
topicNoSearch topicgeneral
roundsNoCurrent search round, defaults to 1

Implementation Reference

  • The main handler function for the 'deep-research' tool. It checks for TAVILY_API_KEY, parses input args using DeepResearchToolSchema, optionally performs web searches using Tavily, and returns a generated prompt with search results.
    async function deepResearch(args: unknown): Promise<ServerResult> {
      if (!CONFIG.TAVILY_API_KEY) {
        return {
          isError: true,
          content: [
            {
              type: 'text',
              text: 'Please configure the `TAVILY_API_KEY` environment variable, get it from https://tavily.com/',
            },
          ],
        };
      }
    
      const { question, reference = '', keywords = [], topic, rounds } = DeepResearchToolSchema.parse(args);
    
      let searchResults = reference;
      if (keywords.length) {
        const results = await Promise.allSettled(keywords.map((keyword) => searchTavily(keyword, { topic })));
    
        searchResults += results
          .filter((result): result is PromiseFulfilledResult<string> => result.status === 'fulfilled')
          .map((result) => result.value)
          .join('\n');
      }
    
      return {
        content: [
          {
            type: 'text',
            text: generatePrompt(question, searchResults, rounds),
          },
        ],
      };
    }
  • Zod schema for the 'deep-research' tool inputs: question (string), reference (optional string), keywords (optional array of strings), topic (enum: general/news/finance, default general), rounds (number, default 1).
    const DeepResearchToolSchema = z.object({
      question: z.string().describe('User question'),
      reference: z.string().optional().describe('Reference materials'),
      keywords: z
        .array(z.string())
        .min(0)
        .max(CONFIG.MAX_SEARCH_KEYWORDS)
        .optional()
        .describe(
          `Search keywords, please provide 1~${CONFIG.MAX_SEARCH_KEYWORDS} keywords. Each keyword must: include complete subject and predicate, avoid pronouns and references, have independent search value, avoid logical overlap between keywords, and be directly relevant to the question`,
        ),
      topic: z.enum(['general', 'news', 'finance']).default('general').describe('Search topic'),
      rounds: z.number().default(1).describe('Current search round, defaults to 1'),
    });
  • src/index.ts:162-171 (registration)
    The tool is registered with name 'deep-research' in the ListToolsRequestSchema handler, and the CallToolRequestSchema handler maps calls to the deepResearch function.
    mcpServer.server.setRequestHandler(ListToolsRequestSchema, () => ({
      tools: [
        {
          name: 'deep-research',
          description:
            'Deep web information search tool that can conduct multi-round in-depth research based on keywords and topics',
          inputSchema: zodToJsonSchema(DeepResearchToolSchema),
        },
      ],
    }));
  • Generates the LLM prompt used by the deep-research tool, including role definition, analysis steps, search strategy guidelines, and constraints based on current round.
    function generatePrompt(question: string, searchResults: string, rounds: number): string {
      return `# Role Definition
    You are a professional information search and analysis expert, specializing in:
    - Analyzing core information needs from user queries
    - Designing precise search strategies
    - Synthesizing and distilling information
    - Providing accurate and comprehensive answers
    
    # User Question
    ${question}
    
    # Current Environment
    Current Search Round: ${rounds}
    Maximum Search Rounds: ${CONFIG.MAX_PLANNING_ROUNDS}
    Current Time: ${new Date().toLocaleString()}
    
    # Known Information
    ${searchResults ?? 'No reference information available'}
    
    # Analysis Steps
    1. Resource Sufficiency Assessment
       - Carefully analyze if existing information is sufficient to answer the user's question
       - Identify information gaps or areas requiring additional verification
    
    2. Search Strategy (if needed)
       - Identify specific information points that need supplementation
       - Design precise search keywords (each keyword must meet these requirements):
         * Include complete subject and predicate
         * Avoid pronouns and references
         * Have independent search value
         * Avoid logical overlap between keywords
       - Keyword quantity limit: 1~${CONFIG.MAX_SEARCH_KEYWORDS}
    
    3. Continue Search (if needed)
       - Use current "Known Information" as reference parameter
       - Set rounds parameter to ${rounds + 1}
       - Output only search keywords, without any other content
    
    4. Direct Answer (if information is sufficient)
       - Provide complete answer based on available information
       - Ensure the answer is accurate, comprehensive, and logically clear
    
    # Output Requirements
    ## If Further Search is Needed
    - Output only the list of search keywords
    - One keyword per line
    - Do not include any other explanations or notes
    
    ## If Direct Answer is Possible
    - Provide a clear, structured answer
    - Reference relevant sources when necessary
    - Clearly indicate any uncertain information
    
    # Constraints
    - Current round has reached ${rounds}/${CONFIG.MAX_PLANNING_ROUNDS}, must provide direct answer if maximum rounds exceeded
    - Search keywords must be independent and precise, no ambiguity allowed
    - Prohibited to output content unrelated to search strategy`;
    }
  • Utility function that performs a Tavily search API call and formats results into a markdown string.
    async function searchTavily(keyword: string, options: TavilySearchOptions): Promise<string> {
      const tvly = tavily({ apiKey: CONFIG.TAVILY_API_KEY });
      const response = await tvly.search(keyword, options);
      let result = `## Search Results for \`${response.query}\`\n`;
      response.results.forEach((searchResult, index) => {
        result += `### Reference ${index + 1}:\n`;
        result += `Title: ${searchResult.title}\n`;
        result += `Content: ${searchResult.content}\n`;
      });
      return result;
    }
Behavior2/5

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

The description notes multi-round capability but does not explain what multi-round entails or any behavioral details. No annotations are provided, so the description should carry the burden, but it only gives a high-level overview. No disclosure of side effects, auth requirements, or error handling.

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 a single sentence, concise and front-loaded with the main purpose. It avoids unnecessary words but could be slightly more informative without increasing length significantly.

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?

The tool has 5 parameters, no output schema, and no annotations. The description only gives a high-level purpose but does not explain the return format, result structure, or how to use the tool effectively. It lacks completeness for a research tool with multi-round capability.

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 coverage is 100%, so parameters are well-documented in the schema. The tool description mentions 'keywords and topics' but does not add new information beyond the schema. It does not explain parameter usage or constraints further.

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 it is a deep web information search tool capable of multi-round research. It mentions keywords and topics, providing a clear purpose. However, it does not differentiate from siblings (none present) and could elaborate on the output or scope.

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 usage guidance is provided. The description does not specify when to use this tool over others, nor does it mention any prerequisites or limitations. It only describes the tool's function.

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/baranwang/mcp-deep-research'

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