docs/integrations/chatgpt.mdx
ChatGPT supports MCP servers through remote HTTP connections in two modes: Chat mode for interactive conversations and Deep Research mode for comprehensive information retrieval.
<Tip> **Developer Mode Required for Chat Mode**: To use MCP servers in regular ChatGPT conversations, you must first enable Developer Mode in your ChatGPT settings. This feature is available for ChatGPT Pro, Team, Enterprise, and Edu users. </Tip> <Note> OpenAI's official MCP documentation and examples are built with **FastMCP v2**! Learn more from their [MCP documentation](https://platform.openai.com/docs/mcp) and [Developer Mode guide](https://platform.openai.com/docs/guides/developer-mode). </Note>First, let's create a simple FastMCP server:
from fastmcp import FastMCP
import random
mcp = FastMCP("Demo Server")
@mcp.tool
def roll_dice(sides: int = 6) -> int:
"""Roll a dice with the specified number of sides."""
return random.randint(1, sides)
if __name__ == "__main__":
mcp.run(transport="http", port=8000)
Your server must be accessible from the internet. For development, use ngrok:
ngrok http 8000
Note your public URL (e.g., https://abc123.ngrok.io) for the next steps.
Chat mode lets you use MCP tools directly in ChatGPT conversations. See OpenAI's Developer Mode guide for the latest requirements.
https://your-server.ngrok.io/mcp/Example usage:
Use annotations={"readOnlyHint": True} to skip confirmation prompts for read-only tools:
@mcp.tool(annotations={"readOnlyHint": True})
def get_status() -> str:
"""Check system status."""
return "All systems operational"
@mcp.tool() # No annotation - ChatGPT may ask for confirmation
def delete_item(id: str) -> str:
"""Delete an item."""
return f"Deleted {id}"
Deep Research mode provides systematic information retrieval with citations. See OpenAI's MCP documentation for the latest Deep Research specifications.
<Warning> **Search and Fetch Required**: Without Developer Mode, ChatGPT will reject any server that doesn't have both `search` and `fetch` tools. Even in Developer Mode, Deep Research only uses these two tools. </Warning>Deep Research tools must follow this pattern:
@mcp.tool()
def search(query: str) -> dict:
"""
Search for records matching the query.
Must return {"ids": [list of string IDs]}
"""
# Your search logic
matching_ids = ["id1", "id2", "id3"]
return {"ids": matching_ids}
@mcp.tool()
def fetch(id: str) -> dict:
"""
Fetch a complete record by ID.
Return the full record data for ChatGPT to analyze.
"""
# Your fetch logic
return {
"id": id,
"title": "Record Title",
"content": "Full record content...",
"metadata": {"author": "Jane Doe", "date": "2024"}
}
ChatGPT will use your search and fetch tools to find and cite relevant information.