Overview
Beyond thefunction tools you define yourself, you can give a model new capabilities by connecting it to a remote Model Context Protocol (MCP) server. The model calls that server’s tools to reach and control external services when it needs them to answer a prompt.
The mcp tool connects a user-supplied remote MCP server to an Agent API request. Agent API discovers the server’s tools when the request starts and calls them like native tools during the run, so you don’t have to write a custom function tool for each one.
The example below connects to the public DeepWiki MCP server, which needs no authentication, and asks the model to answer a question about a GitHub repository using the server’s tools.
output array, with long MCP tool outputs truncated.
Response
Response
Defer tool definitions
By default, every MCP tool definition the request exposes enters the model’s initial context. Setdefer_loading to true when a server has many tools or large schemas, or when you connect several servers at once. The model can then search the catalog and load only the schemas it needs. The field is per server, so set it on each one you want deferred. Omitting the field, or setting it to false, keeps the default eager behavior.
Deferred loading spends extra model turns before the first tool call. Set max_steps high enough that the model can search the catalog and still call the tools it finds. Otherwise a run can end right after the search and answer without ever calling a tool.
In the example below, none of DeepWiki’s three tool definitions start in the model’s context. The model searches the catalog, loads only what the search matches, and calls the tool it found.
output array, with long MCP tool outputs truncated.
Response
Response
tool_search_output item is one search of the deferred catalog. The search can cover every deferred server or narrow to one, and it returns only the tools it matches — one of DeepWiki’s three above. A search can also return no match, and the model can then search again, so a run may hold several of these items. Calls still appear as mcp_call. Agent API still discovers each server’s tools when the request starts, so deferred loading does not eliminate discovery time or change discovery failure behavior.
Three small tools is a modest catalog, so the extra search step buys little here. Deferred loading pays off as the catalog grows: more servers, more tools, larger schemas, or a context window you would otherwise exceed.
Authentication
Unlike the DeepWiki server above, most MCP servers require authentication. The most common scheme is an OAuth access token, which you pass in theauthorization field of the mcp tool:
This example uses the GitHub MCP Server. Create a GitHub personal access token with access to the repositories you want the model to inspect, and export it as
GITHUB_MCP_TOKEN.Parameters
Response shape
When anmcp tool is used, the response output array can include two MCP-specific item types alongside the final message item:
mcp_list_tools— emitted once per server, listing the tools discovered when the request starts.mcp_call— emitted for each tool the model invokes on the server.
defer_loading: true, the array can also include tool_search_output items when the model searches the deferred catalog. Tool invocations still appear as mcp_call items.
mcp_list_tools
Each entry in
tools has the following fields:
mcp_call
tool_search_output
Emitted only with defer_loading: true, once per search the model runs against the deferred catalog.
Each entry in
tools is a namespace for one server:
Example response
output array:
Error handling
A discovery failure happens when a server cannot be reached or returns an unusable response as its tools are listed at the start of the run. Because discovery runs before the model, the whole request fails with
external_connector_error and returns no output array.
Tool-call failures during the run do not fail the request. The error is returned to the model in-band on the mcp_call item (as above), so the model can recover or explain it in its final answer.
Risks and safety
Themcp tool lets you connect models to external services — a powerful capability that carries risk. Remote MCP servers are third-party services that have not been verified by Perplexity. They can let a model read, send, and receive data, and take actions in the connected service, and each server is subject to its own terms and conditions. Connect only servers you trust.
Use allowed_tools to limit which server tools the model can call. For servers with write or admin actions, prefer read-only server modes, read-only tokens, or a small allowlist of read-only tools.
Limitations
Themcp tool is backward-compatible with OpenAI’s Responses MCP API. The following OpenAI MCP features are temporarily not supported: