Skip to main content
Glama
qpd-v
by qpd-v

deep_research

Explore in-depth research topics by extracting and analyzing web content with controlled depth, branching, and relevance scoring. Supports real-time web research with structured data integration.

Instructions

Perform deep research on a topic with content extraction and analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxBranchingNoMaximum number of related paths to explore
maxDepthNoMaximum depth of related content exploration
minRelevanceScoreNoMinimum relevance score for including content
timeoutNoResearch timeout in milliseconds
topicYesResearch topic or question

Implementation Reference

  • Core handler implementing the deep_research tool logic: initializes ResearchSession, performs parallel searches on derived queries, deduplicates results, processes top and remaining URLs, completes session, and returns formatted ResearchResult with timings.
    public async startResearch(topic: string, options: DeepResearchOptions = {}): Promise<ResearchResult> { const startTime = Date.now(); const timings: { [key: string]: number } = {}; console.log('[Performance] Starting research for topic:', topic); console.log('[Performance] Options:', options); // Create new research session const session = new ResearchSession(topic, { maxDepth: options.maxDepth, maxBranching: options.maxBranching, timeout: options.timeout, minRelevanceScore: options.minRelevanceScore, maxParallelOperations: options.maxParallelOperations }); console.log('[Performance] Created research session:', session.id); this.activeSessions.set(session.id, session); try { console.log('[Performance] Starting parallel search...'); const parallelSearchStart = Date.now(); const queries = [ topic, `${topic} tutorial`, `${topic} guide`, `${topic} example`, `${topic} implementation`, `${topic} code`, `${topic} design pattern`, `${topic} best practice` ]; console.log('[Performance] Search queries:', queries); const searchResults = await this.parallelSearch.parallelSearch(queries); timings.parallelSearch = Date.now() - parallelSearchStart; console.log('[Performance] Parallel search complete. Duration:', timings.parallelSearch, 'ms'); const deduplicationStart = Date.now(); const allResults = searchResults.results.flatMap(result => result.results); console.log('[Performance] Total results:', allResults.length); const uniqueResults = this.deduplicateResults(allResults); console.log('[Performance] Unique results:', uniqueResults.length); const sortedResults = uniqueResults.sort((a, b) => b.relevanceScore - a.relevanceScore); timings.deduplication = Date.now() - deduplicationStart; console.log('[Performance] Deduplication complete. Duration:', timings.deduplication, 'ms'); // Process top results first console.log('[Performance] Processing top 5 results...'); const topProcessingStart = Date.now(); const topResults = sortedResults.slice(0, 5); await Promise.all(topResults.map(r => { console.log('[Performance] Processing URL:', r.url); return session.processUrl(r.url); })); timings.topResultsProcessing = Date.now() - topProcessingStart; console.log('[Performance] Top results processing complete. Duration:', timings.topResultsProcessing, 'ms'); // Process remaining results console.log('[Performance] Processing remaining results...'); const remainingProcessingStart = Date.now(); const remainingResults = sortedResults.slice(5); await Promise.all(remainingResults.map(r => { console.log('[Performance] Processing URL:', r.url); return session.processUrl(r.url); })); timings.remainingResultsProcessing = Date.now() - remainingProcessingStart; console.log('[Performance] Remaining results processing complete. Duration:', timings.remainingResultsProcessing, 'ms'); // Complete the session console.log('[Performance] Completing session...'); await session.complete(); // Format and return results console.log('[Performance] Formatting results...'); const results = this.formatResults(session); // Add timing information timings.total = Date.now() - startTime; results.timing.operations = { parallelSearch: timings.parallelSearch, deduplication: timings.deduplication, topResultsProcessing: timings.topResultsProcessing, remainingResultsProcessing: timings.remainingResultsProcessing, total: timings.total }; console.log('[Performance] Research complete. Total duration:', timings.total, 'ms'); console.log('[Performance] Operation timings:', timings); return results; } catch (error) { console.error(`[Performance] Error in research session ${session.id}:`, error); throw error; } finally { // Cleanup this.activeSessions.delete(session.id); await this.parallelSearch.cleanup(); } }
  • src/index.ts:87-124 (registration)
    Registration of the 'deep_research' tool in the MCP server's listTools handler, defining name, description, and input schema.
    { name: 'deep_research', description: 'Perform deep research on a topic with content extraction and analysis', inputSchema: { type: 'object', properties: { topic: { type: 'string', description: 'Research topic or question' }, maxDepth: { type: 'number', description: 'Maximum depth of related content exploration', minimum: 1, maximum: 2 }, maxBranching: { type: 'number', description: 'Maximum number of related paths to explore', minimum: 1, maximum: 3 }, timeout: { type: 'number', description: 'Research timeout in milliseconds', minimum: 30000, maximum: 55000 }, minRelevanceScore: { type: 'number', description: 'Minimum relevance score for including content', minimum: 0, maximum: 1 } }, required: ['topic'] } },
  • MCP CallToolRequest handler case for 'deep_research', validates args and delegates to DeepResearch.startResearch instance.
    case 'deep_research': { const args = request.params.arguments as unknown as DeepResearchArgs; if (!args?.topic) { throw new McpError(ErrorCode.InvalidParams, 'Topic is required'); } console.log(`Starting deep research on topic: ${args.topic}`); const result = await deepResearch.startResearch(args.topic, { maxDepth: Math.min(args.maxDepth || 2, 2), maxBranching: Math.min(args.maxBranching || 3, 3), timeout: Math.min(args.timeout || 55000, 55000), minRelevanceScore: args.minRelevanceScore || 0.7 }); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
  • TypeScript interface defining input arguments for deep_research tool, matching the inputSchema.
    interface DeepResearchArgs { topic: string; maxDepth?: number; maxBranching?: number; timeout?: number; minRelevanceScore?: number; }
  • Interface for options passed to startResearch method.
    export interface DeepResearchOptions { maxDepth?: number; maxBranching?: number; timeout?: number; minRelevanceScore?: number; maxParallelOperations?: number; }

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/qpd-v/mcp-DEEPwebresearch'

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