referenceFree

how_to_build_a_deep_research_mcp_server

This is a minimal example of a Deep Research style MCP server for searching and fetching files from the OpenAI file storage service.

MCP for Deep Research

This is a minimal example of a Deep Research style MCP server for searching and fetching files from the OpenAI file storage service.

For a reference of how to call this service from the Responses API, with Deep Research see this cookbook. To see how to call the MCP server with the Agents SDK, checkout this cookbook!

The Deep Research agent relies specifically on Search and Fetch tools. Search should look through your object store for a set of specfic, top-k IDs. Fetch, is a tool that takes objectIds as arguments and pulls back the relevant resources.

Set up & run

Store your internal file(s) in OpenAI Vector Storage

Python setup:

python3 -m venv env
source env/bin/activate
pip install -r requirements.txt

Run the server:

python main.py

The server will start on http://0.0.0.0:8000/sse/ using SSE transport. If you want to reach the server from the public internet, there are a variety of ways to do that including with ngrok:

brew install ngrok 
ngrok config add-authtoken <your_token>
ngrok http 8000

You should now be able to reach your local server from your client.

Files

Example Flow diagram for MCP Server

../../../images/mcp_dr.png

Example request

# system_message includes reference to internal file lookups for MCP.
system_message = """
You are a professional researcher preparing a structured, data-driven report on behalf of a global health economics team. Your task is to analyze the health question the user poses.

Do:
- Focus on data-rich