Skip to content

Commit 012c79d

Browse files
authored
Deep research api (#1922)
1 parent 7299c12 commit 012c79d

File tree

6 files changed

+8
-89
lines changed

6 files changed

+8
-89
lines changed

examples/deep_research_api/how_to_build_a_deep_research_mcp_server/README.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,11 @@ You should now be able to reach your local server from your client.
3636

3737
## Files
3838

39-
- `main.py`: Main server code
39+
- `main.py`: [Main server code](https://github.com/openai/openai-cookbook/blob/main/examples/deep_research_api/how_to_build_a_deep_research_mcp_server/main.py)
4040

4141
## Example Flow diagram for MCP Server
4242

43-
```mermaid
44-
flowchart TD
45-
subgraph Connection_Setup
46-
A1[MCP Server starts up<br/>listening on /sse/] --> A2[Client opens SSE connection]
47-
A2 --> A3[Server confirms SSE connection]
48-
end
49-
50-
subgraph Tool_Discovery
51-
A3 --> B1[Client asks 'What tools do you support?']
52-
B1 --> B2[Server replies with Search & Fetch schemas]
53-
B2 --> B3[Client stores schemas in context]
54-
end
55-
56-
subgraph Search_Fetch_Loop
57-
B3 --> C1[Client issues search call]
58-
C1 --> C2[MCP Server routes to Search Tool]
59-
C2 --> C3[Search Tool queries Data Store<br/>returns one hit]
60-
C3 --> C4[Client issues fetch call]
61-
C4 --> C5[MCP Server routes to Fetch Tool]
62-
C5 --> C6[Fetch Tool retrieves document text]
63-
C6 --> C7[Client refines/repeats search<br/> cost-effectiveness, market revenue…]
64-
C7 --> C1
65-
end
66-
```
43+
![../../../images/mcp_dr.png](../../../images/mcp_dr.png)
6744

6845
## Example request
6946

examples/deep_research_api/introduction_to_deep_research_api.ipynb

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
"\n",
296296
"In the example below, we configure an MCP tool that lets Deep Research fetch your organizations internal semaglutide studies on demand. The MCP server is a proxy for the OpenAI File Storage service that automagically vectorizes your uploaded files for performant retrieval.\n",
297297
"\n",
298-
"If you would like to see _how_ we built this simple MCP server. Refer to [this related cookbook](<placeholder>)."
298+
"If you would like to see _how_ we built this simple MCP server. Refer to [this related cookbook]([<placeholder>](https://cookbook.openai.com/examples/deep_research_api/how_to_build_a_deep_research_mcp_server/readme))."
299299
]
300300
},
301301
{
@@ -454,46 +454,7 @@
454454
"\n",
455455
"This setup gives developers full control over how research tasks are framed, but also places greater responsibility on the quality of the input prompt. Here's an example of a generic rewriting_prompt to better direct the subsequent deep research query.\n",
456456
"\n",
457-
"```mermaid\n",
458-
"flowchart TD\n",
459-
" %% Interactive ChatGPT Flow with Clarifier\n",
460-
" subgraph ChatGPT Session\n",
461-
" direction TB\n",
462-
" U1([User Query])\n",
463-
" C[Clarifier<br/>lightweight model]\n",
464-
" Q[Clarifying Questions]\n",
465-
" UQ([User’s Answers])\n",
466-
" R[Rewriter<br/>lightweight model]\n",
467-
" EP[Enriched Prompt]\n",
468-
" DR[Deep Research<br/>o3-deep-research]\n",
469-
" O[Research Results]\n",
470-
"\n",
471-
" U1 --> C\n",
472-
" C --> Q\n",
473-
" Q --> UQ\n",
474-
" UQ --> R\n",
475-
" R --> EP\n",
476-
" EP --> DR\n",
477-
" DR --> O\n",
478-
" end\n",
479-
"\n",
480-
" %% Deep Research API Flow (no built-in clarifier)\n",
481-
" subgraph Deep Research API\n",
482-
" direction TB\n",
483-
" U2([User Query])\n",
484-
" R2[Rewriter<br/>optional]\n",
485-
" EP2[Enriched Prompt]\n",
486-
" DR2[Deep Research API<br/>o3-deep-research]\n",
487-
" O2[Research Results]\n",
488-
"\n",
489-
" U2 -->|include all details up-front| EP2\n",
490-
" EP2 --> DR2\n",
491-
" DR2 --> O2\n",
492-
"\n",
493-
" U2 -->|use prompt rewriter| R2\n",
494-
" R2 --> EP2\n",
495-
" end\n",
496-
"```\n",
457+
"![../../../images/intro_dr.png](../../../images/intro_dr.png)\n",
497458
"\n",
498459
"Here's an example of a rewriting prompt:"
499460
]

examples/deep_research_api/introduction_to_deep_research_api_agents.ipynb

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"\n",
1111
"This cookbook demonstrates how to build Agentic research workflows using the OpenAI Deep Research API and the OpenAI [Agents SDK](https://openai.github.io/openai-agents-python/). It is a continuation of [a fundamentals cookbook](https://cookbook.openai.com/examples/deep_research_api/introduction_to_deep_research_api), if you have not already familiarized yourself with that content, please consider doing so.\n",
1212
"\n",
13-
"You’ll learn how to orchestrate single and multi-agent pipelines, enrich user queries to maximize output quality, stream research progress, integrate web search and [MCP for internal file search](https://cookbook.openai.com/examples/deep_research_api/how_to_build_a_deep_research_mcp_server/README), and architect a robust research application.\n",
13+
"You’ll learn how to orchestrate single and multi-agent pipelines, enrich user queries to maximize output quality, stream research progress, integrate web search and [MCP for internal file search](https://cookbook.openai.com/examples/deep_research_api/how_to_build_a_deep_research_mcp_server/readme), and architect a robust research application.\n",
1414
"\n",
1515
"Consider using Deep Research Agents for tasks that require planning, synthesis, tool use, or multi-step reasoning. Do not use Deep Research for trivial fact lookups, simple Q&A, or short-form chat, a vanilla openai.responsesAPI would be faster and cheaper."
1616
]
@@ -260,28 +260,9 @@
260260
" - Streams intermediate events for transparency\n",
261261
" - Outputs final Research Artifact (which we later parse)\n",
262262
"\n",
263-
"```mermaid\n",
264-
"flowchart LR\n",
265-
" subgraph Triage\n",
266-
" TA[Triage Agent<br/>• Inspect query<br/>• Route based on context]\n",
267-
" end\n",
268-
" subgraph Clarifier\n",
269-
" CA[Clarifier Agent<br/>• Ask follow‐up questions<br/>• Receive answers]\n",
270-
" end\n",
271-
" subgraph Instruction\n",
272-
" IA[Instruction Builder Agent<br/>• Build precise research brief]\n",
273-
" end\n",
274-
" subgraph Research\n",
275-
" RA[Research Agent<br/> o3‐deep‐research <br/>• WebSearchTool<br/>• Internal MCP search<br/>• Stream events<br/>• Output Artifact]\n",
276-
" end\n",
277-
"\n",
278-
" TA -->|Missing context| CA\n",
279-
" TA -->|Context OK| IA\n",
280-
" CA --> IA\n",
281-
" IA --> RA\n",
282-
"```\n",
283-
"\n",
284-
"For more insight into _how_ the MCP server is build. [See this resource.](https://cookbook.openai.com/examples/deep_research_api/how_to_build_a_deep_research_mcp_server/README )"
263+
"![../../../images/agents_dr.png](../../../images/agents_dr.png)\n",
264+
"\n",
265+
"For more insight into _how_ the MCP server is build. [See this resource.](https://cookbook.openai.com/examples/deep_research_api/how_to_build_a_deep_research_mcp_server/readme )"
285266
]
286267
},
287268
{

images/agent_dr.png

100 KB
Loading

images/intro_dr.png

120 KB
Loading

images/mcp_dr.png

71.3 KB
Loading

0 commit comments

Comments
 (0)