
Deep Research
STDIOAI-powered research assistant using Gemini LLMs for deep, iterative research exploration.
AI-powered research assistant using Gemini LLMs for deep, iterative research exploration.
Your AI-Powered Research Assistant. Conduct iterative, deep research using Google Gemini 2.5 Flash with Google Search Grounding and URL context. No web-scraping dependency is required.
The goal of this project is to provide the simplest yet most effective implementation of a deep research agent. It's designed to be easily understood, modified, and extended, aiming for a codebase under 500 lines of code (LoC).
Key Features:
flowchart TB subgraph Input Q[User Query] B[Breadth Parameter] D[Depth Parameter] end DR[Deep Research] --> SQ[SERP Queries] --> PR[Process Results] subgraph Results[Results] direction TB NL((Learnings)) ND((Directions)) end PR --> NL PR --> ND DP{depth > 0?} RD["Next Direction: - Prior Goals - New Questions - Learnings"] MR[Markdown Report] %% Main Flow Q & B & D --> DR %% Results to Decision NL & ND --> DP %% Circular Flow DP -->|Yes| RD RD -->|New Context| DR %% Final Output DP -->|No| MR %% Styling classDef input fill:#7bed9f,stroke:#2ed573,color:black classDef process fill:#70a1ff,stroke:#1e90ff,color:black classDef recursive fill:#ffa502,stroke:#ff7f50,color:black classDef output fill:#ff4757,stroke:#ff6b81,color:black classDef results fill:#a8e6cf,stroke:#3b7a57,color:black class Q,B,D input class DR,SQ,PR process class DP,RD recursive class MR output class NL,ND results
What are Persona Agents?
In deep-research
, we utilize the concept of "persona agents" to guide the behavior of the Gemini language models. Instead of simply prompting the LLM with a task, we imbue it with a specific role, skills, personality, communication style, and values. This approach helps to:
Examples of Personas in use:
By leveraging persona agents, deep-research
aims to achieve more targeted, consistent, and high-quality research outcomes from the Gemini language models.
Core modules:
src/deep-research.ts
— orchestrates queries, batching, analysis, and synthesis
generateSerpQueries()
uses Gemini to propose SERP-style queries from your prompt and prior learningsprocessSerpResult()
splits content, batches Gemini calls with tools enabled, extracts learnings and citationsconductResearch()
runs analysis passes over semantic chunkswriteFinalReport()
builds the final professional Markdown reportsrc/ai/providers.ts
— GoogleGenAI wrapper for Gemini 2.5 Flash, batching, token control, optional toolssrc/ai/text-splitter.ts
— RecursiveCharacter and Semantic splitterssrc/mcp-server.ts
— MCP server entry point and typessrc/run.ts
— CLI entry pointPipeline highlights:
generateBatch
, generateBatchWithTools
)deep-research-mcp-server/ ├─ src/ │ ├─ ai/ │ │ ├─ providers.ts # Gemini wrapper, tools, batching, caching │ │ └─ text-splitter.ts # Semantic/recursive splitters │ ├─ mcp-server.ts # MCP server entry/types │ ├─ deep-research.ts # Orchestrator: queries → analysis → synthesis │ ├─ prompt.ts # System + templates │ ├─ feedback.ts # Refinement/feedback loop │ ├─ output-manager.ts # Report/output formatting │ ├─ progress-manager.ts # CLI progress │ ├─ terminal-utils.ts # CLI helpers │ ├─ types.ts # Zod schemas/types │ └─ utils/ # JSON/sanitize helpers ├─ dist/ # Build output ├─ .env.example # Environment template ├─ package.json # Scripts/deps └─ README.md
Clone the repository:
git clone [your-repo-link-here]
Install dependencies:
npm install
Set up environment variables: Create a .env.local
file in the project root:
# Required GEMINI_API_KEY="your_gemini_key" # Recommended defaults GEMINI_MODEL=gemini-2.5-flash GEMINI_MAX_OUTPUT_TOKENS=65536 CONCURRENCY_LIMIT=5 # Gemini tools (enable as needed) ENABLE_GEMINI_GOOGLE_SEARCH=true ENABLE_GEMINI_CODE_EXECUTION=false ENABLE_GEMINI_FUNCTIONS=false
Build the project:
npm run build
To run deep-research
as an MCP tool, start the MCP server:
node --env-file .env.local dist/mcp-server.js
You can then invoke the deep-research
tool from any MCP-compatible agent using the following parameters:
query
(string, required): The research query.depth
(number, optional, 1-5): Research depth (default: moderate).breadth
(number, optional, 1-5): Research breadth (default: moderate).existingLearnings
(string[], optional): Pre-existing research findings to guide research.Example MCP Tool Arguments (JSON shape):
{ "name": "deep-research", "arguments": { "query": "State of multi-agent research agents in 2025", "depth": 3, "breadth": 3, "existingLearnings": [ "Tool use improves grounding", "Batching reduces latency" ] } }
const mcp = new ModelContextProtocolClient(); // Assuming MCP client is initialized async function invokeDeepResearchTool() { try { const result = await mcp.invoke("deep-research", { query: "Explain the principles of blockchain technology", depth: 2, breadth: 4 }); if (result.isError) { console.error("MCP Tool Error:", result.content[0].text); } else { console.log("Research Report:\n", result.content[0].text); console.log("Sources:\n", result.metadata.sources); } } catch (error) { console.error("MCP Invoke Error:", error); } } invokeDeepResearchTool();
To run deep-research
directly from the command line:
npm run start "your research query"
Example:
npm run start "what are latest developments in ai research agents"
For interactive testing and debugging of the MCP server, use the MCP Inspector:
npx @modelcontextprotocol/inspector node --env-file .env.local dist/mcp-server.js
GEMINI_API_KEY
to the MCP server process; model and tool flags via env.CONCURRENCY_LIMIT
to balance speed vs rate limits.GEMINI_API_KEY
— requiredGEMINI_MODEL
— defaults to gemini-2.5-flash
GEMINI_MAX_OUTPUT_TOKENS
— defaults to 65536
CONCURRENCY_LIMIT
— defaults to 5
ENABLE_GEMINI_GOOGLE_SEARCH
— enable Google Search Grounding toolENABLE_GEMINI_CODE_EXECUTION
— enable code execution toolENABLE_GEMINI_FUNCTIONS
— enable function callingOptional providers (planned/behind flags): Exa/Tavily can be integrated later; Firecrawl is not required for the current pipeline.
git clone https://github.com/ssdeanx/deep-research-mcp-server cd deep-research-mcp-server npm i && npm run build
Create .env.local
(see Setup)
Run as MCP server (Inspector)
npx @modelcontextprotocol/inspector node --env-file .env.local dist/mcp-server.js
npm run start "state of multi-agent research agents in 2025"
# Abstract Concise overview of the research goal, scope, method, and key findings. # Table of Contents ... # Introduction Context and framing. # Body Evidence-backed sections with citations. # Methodology How sources were found and analyzed. # Limitations Assumptions and risks. # Key Learnings Bulleted insights and takeaways. # References Normalized citations to visited URLs.
npm run build
and tsc --noEmit
must pass.README.md
and .env.example
when changing env/config.ENABLE_EXA_PRIMARY
), Google grounding for augmentation.GEMINI_API_KEY
is set in .env.local
and processes are started with --env-file .env.local
.ENABLE_GEMINI_GOOGLE_SEARCH
, ENABLE_GEMINI_CODE_EXECUTION
, ENABLE_GEMINI_FUNCTIONS
.CONCURRENCY_LIMIT
(e.g., 3) or rerun with fewer simultaneous queries.GEMINI_MAX_OUTPUT_TOKENS
.MIT License - Free and Open Source. Use it freely!
✨ Highlights of the latest changes. See also Roadmap.
Performance: