New Tool Radar

AI Agents & Automation

How to Add an MCP Server to an OpenAI Agents SDK Agent

Add an MCP server to an OpenAI Agents SDK agent so it can use the server's tools alongside its function tools.

Schematic with three steps: Connect the MCP server; Pass the server to the agent; Ask a question the MCP tool can.

The OpenAI Agents SDK has built-in MCP integration: an agent can list tools from a remote MCP server next to its own function tools, and the model chooses between them. Connect the server before you create the agent, pass it in the agent’s MCP server list, and manage the server lifecycle yourself: connect it before the run and close it when the run is done. Check the tool list before you trust it, because an MCP server can expose tools you did not expect.

What you need

  • Python with the openai-agents package installed and an API key
  • The address of an MCP server you trust
  • An agent with at least one function tool already working

Step 1: Connect the MCP server

Create the MCP server client for your server type, such as a remote server over streamable HTTP, and connect it before the run. The SDK expects you to manage this lifecycle yourself.

Step 2: Pass the server to the agent

Add the connected server to the agent’s MCP server list, next to its function tools. The agent will include the server’s tools in the list of tools available to the model on every run.

Step 3: Ask a question the MCP tool can answer and check the tool list

Ask the agent a question only the MCP tool can answer, and confirm it called the MCP tool, not a function tool. Open the list of tools the agent saw and remove any server tool the agent should not have.

Worked example: synthetic MCP tool call

The table below is a synthetic example. It shows the expected result of MCP tools; no server was connected.

Check Expected Result
MCP tools listed for the agent Yes Pass
Agent calls the MCP tool Yes Pass
Answer uses the tool result Yes Pass
Unexpected tools removed Yes Pass

Expected result (UNTESTED). the agent lists the MCP tools, calls the right one, and answers from its result. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • You must connect the server before passing it to the agent and close it when done; the SDK does not manage that for you.
  • An MCP server can expose tools you did not expect, so check the tool list before the first real run.
  • Every tool you add is a permission you grant, so only connect servers you trust.

Sources

See all