Describe the bug
When using a hosted MCP server, realtime agents will occasionally attempt to perform a function_call instead of an mcp_call when invoking a tool from that server.
For example, I have a hosted MCP tool called metrics_get_data. When I try to invoke it, the following error occurs:
Error handling function call $t: Tool metrics_get_data not found
Inspecting the agent’s history shows that the tool was called as a function_call:
{
"arguments": "{\"metricID\":\"iz270IOmPBgHJLwjKPdtX\"}",
"itemId": "item_CRIzUATkoCK37YdpjH6b4",
"name": "metrics_get_data",
"output": null,
"status": "in_progress",
"type": "function_call"
}
However, metrics_get_data exists in the MCP tools list, not in the function tools list - yet the agent treats it as a function call.
Tool Lists (Sanitized)
MCP Tools
[
{ "name": "metrics_list" },
{ "name": "get_current_user" },
{ "name": "metrics_get_data" },
{ "name": "documentation_search" },
...
]
Function Tools
[
{ "type": "function", "name": "browserCreateHyperlink" },
{ "type": "function", "name": "browserNavigateToPage" },
...
]
Even though metrics_get_data clearly belongs in the MCP tool list, the agent’s request type is incorrectly set to function_call.
Debug Information
- Agents SDK version:
0.1.9
- Runtime environment:
Node.js 18.17.1
Steps to Reproduce
- Set up a hosted MCP server with several tools.
- Provide that server to a realtime agent as shown below:
const agent = new RealtimeAgent({
name: 'Cora AI Assistant',
instructions: `You are an AI assistant. You have MCP tools and function tools available to you. Your available MCP tools are get_orders, create_order, ...`,
tools: [
hostedMcpTool({
serverLabel: 'mcp',
serverUrl: environment.mcpURL,
requireApproval: 'never'
}),
// additional function tools here
],
});
- Optionally, include a list of the available MCP tools in the system prompt.
- Attempt to invoke an MCP tool (e.g., metrics_get_data).
In my testing, this error occurs roughly 50% of the time when MCP tools are listed in the system prompt. If tools are not listed in the system prompt the error does not happen as often, but still often enough to render our agent unreliable at best.
Expected Behavior
The realtime agent should correctly recognize and invoke tools based on their type:
MCP tools → mcp_call
Function tools → function_call
metrics_get_data should trigger an mcp_call, not a function_call.****
Describe the bug
When using a hosted MCP server, realtime agents will occasionally attempt to perform a
function_callinstead of anmcp_callwhen invoking a tool from that server.For example, I have a hosted MCP tool called
metrics_get_data. When I try to invoke it, the following error occurs:Error handling function call $t: Tool metrics_get_data not foundInspecting the agent’s history shows that the tool was called as a
function_call:{ "arguments": "{\"metricID\":\"iz270IOmPBgHJLwjKPdtX\"}", "itemId": "item_CRIzUATkoCK37YdpjH6b4", "name": "metrics_get_data", "output": null, "status": "in_progress", "type": "function_call" }However,
metrics_get_dataexists in the MCP tools list, not in the function tools list - yet the agent treats it as a function call.Tool Lists (Sanitized)
MCP Tools
[ { "name": "metrics_list" }, { "name": "get_current_user" }, { "name": "metrics_get_data" }, { "name": "documentation_search" }, ... ]Function Tools
[ { "type": "function", "name": "browserCreateHyperlink" }, { "type": "function", "name": "browserNavigateToPage" }, ... ]Even though
metrics_get_dataclearly belongs in the MCP tool list, the agent’s request type is incorrectly set tofunction_call.Debug Information
0.1.9Node.js 18.17.1Steps to Reproduce
In my testing, this error occurs roughly 50% of the time when MCP tools are listed in the system prompt. If tools are not listed in the system prompt the error does not happen as often, but still often enough to render our agent unreliable at best.
Expected Behavior
The realtime agent should correctly recognize and invoke tools based on their type:
MCP tools→mcp_callFunction tools→function_callmetrics_get_datashould trigger anmcp_call, not afunction_call.****