azure-ai-agents: MCP usage errors with Azure AI Foundry
- Packages:
azure-ai-projects: 1.0.0b10azure-ai-agents: 1.2.0b1
- Operating System: macOS Sequoia 15.5
- Python Version: 3.11.8
Describe the bug I've been having issues using the MCP integrations with Azure AI Foundry agents. Specifically, there are two things:
- An
AssertionErroris frequently occurring. It's happened for both GitMCP and Tavily's MCP servers. I have yet to try more MCP servers, but I suspect I'll continue to see these errors coming up. See the error below. - I'm seeing repeated failures to invoke the tools provided to the agent for these MCP servers, resulting in unsatisfactory answers. See below for the error.
- Perhaps I need to provide more specific instructions to the agent to guide it towards invoking the tools provided? I would think the agent would be smart enough to know as is without more specific prompting.
Error to problem 1
The result with the error:
{
"data": {
"response": "I encountered an issue while trying to get the current weather information for Seattle. You can check a reliable weather website or app for real-time updates. Alternatively, if you need general information about Seattle's climate or typical weather patterns, feel free to ask!"
},
"meta": {
"run_steps": [
{
"id": "step_hgixrj0R0tORvoMZpTkf14cN",
"object": "thread.run.step",
"created_at": 1754658900,
"run_id": "run_cT1NcPI13R3b88JJA9oDq179",
"assistant_id": "asst_GyjPbDs3XfMbSrv0VehZmcFv",
"thread_id": "thread_jlp4vdxxi3HlI7F5E67A6jEC",
"type": "message_creation",
"status": "completed",
"cancelled_at": null,
"completed_at": 1754658901,
"expires_at": null,
"failed_at": null,
"last_error": null,
"step_details": {
"type": "message_creation",
"message_creation": {
"message_id": "msg_q8TpSGSexr47v7Pb0nImYnbc"
}
},
"usage": {
"prompt_tokens": 152,
"completion_tokens": 52,
"total_tokens": 204,
"prompt_token_details": {
"cached_tokens": 0
}
}
},
{
"id": "step_ovu486RNvTcTKZ0zIBUmEB72",
"object": "thread.run.step",
"created_at": 1754658900,
"run_id": "run_cT1NcPI13R3b88JJA9oDq179",
"assistant_id": "asst_GyjPbDs3XfMbSrv0VehZmcFv",
"thread_id": "thread_jlp4vdxxi3HlI7F5E67A6jEC",
"type": "tool_calls",
"status": "completed",
"cancelled_at": null,
"completed_at": 1754658900,
"expires_at": null,
"failed_at": null,
"last_error": null,
"step_details": {
"type": "tool_calls",
"tool_calls": [
{
"id": "call_UWl9nlG2w8akjCWKLMpgdeKi",
"type": "mcp",
"arguments": "{\"location\":\"Seattle, WA\"}",
"name": "weather",
"server_label": "tavily",
"output": "content_type='system_error' name='AssertionError' text=\"Encountered exception: <class 'AssertionError'>.\""
}
]
},
"usage": {
"prompt_tokens": 106,
"completion_tokens": 19,
"total_tokens": 125,
"prompt_token_details": {
"cached_tokens": 0
}
}
}
]
}
}
Error to problem 2
{
"data": {
"response": "I currently don't have real-time capabilities to check the latest weather. However, you can easily find the current weather in Seattle by checking a weather website or app like Weather.com, the Weather Channel, or a local news website. Alternatively, you can use a digital assistant on your phone or smart device to get the latest weather update."
},
"meta": {
"run_steps": [
{
"id": "step_47k5HIxdJe4D1T02IvGfzqZ5",
"object": "thread.run.step",
"created_at": 1754659678,
"run_id": "run_HF0DgO0m9n8PhVZyYqMKz7JL",
"assistant_id": "asst_xOCNz0JcZ2yMbzbDDZ96FIee",
"thread_id": "thread_uKI5zjsP5xAIhXfJ9rEO0x43",
"type": "message_creation",
"status": "completed",
"cancelled_at": null,
"completed_at": 1754659679,
"expires_at": null,
"failed_at": null,
"last_error": null,
"step_details": {
"type": "message_creation",
"message_creation": {
"message_id": "msg_ThsZroUC9qje77hFJuPTuSR8"
}
},
"usage": {
"prompt_tokens": 106,
"completion_tokens": 68,
"total_tokens": 174,
"prompt_token_details": {
"cached_tokens": 0
}
}
}
]
}
}
To Reproduce Steps to reproduce the behavior:
- Create a Foundry agent integrated with the Tavily MCP server:
server_label: "tavily"server_url: "https://mcp.tavily.com/mcp/?tavilyApiKey=<MY_TAVILY_API_KEY>",allowed_tools: ["tavily-search"]
- Ask the agent something like "What is the weather in Seattle today?"
- Repeat the above two steps a handful of times to see both problems outlined above.
Expected behavior I would expect two things:
- No assertion errors when the
tavily-searchtool is invoked. - The tool always being invoked (although I understand there's a level of non-determinism to agents).
Screenshots N/A
Additional context
- The agent is using model
gpt-4owith a provided temperature of0.7. - The agent's instructions are very basic:
You are a helpful assistant. When appropriate, use the available tools to help answer the user's query..
Also, when the tool is successfully invoked, accomplished after changing the prompt to be more enforcing, I am still seeing a failure result:
"detail": "An unexpected error occurred: Failed to process query: Agent run failed: server_error - Sorry, something went wrong.",
This is the only context I receive in the logs which isn't particularly insightful. I can remote debug into your SDK, although more insightful logging would be ideal.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dargilco @glharper @howieleung @jhakulin @nick863 @trangevi.
@jacobreesmontgomery We are aware of multiple issues involving MCP tool usage in Agents and are triaging them now.
@apryiomka FYI
I’m facing the same issue. Is there any update or workaround available?
Having the exact same issue, it was working fine Friday but now getting the unhelpful 'server_error' response. Is there any update on this?
@jacobreesmontgomery can you please confirm the region for the ai service account where you observe the error?
@jacobreesmontgomery can you please confirm the region for the ai service account where you observe the error?
eastus2
We're facing the same issue. all our agents in dev and prod are down.
We were able to identify the issue. We will be rolling out a hotfix in production soon.
We were able to identify the issue. We will be rolling out a hotfix in production soon.
Hi how soon will it be live? I really need it today😅. Is REST an alternative until than or is that also broken?
The fix was deployed in the following production regions:
- West US 2
- West US
- Norway East
- Switzerland North
- UAE North
- South India
More regions will be deployed tomorrow. The fix should be deployed in all regions by the end of week. Your connected AI Service Account, not the project, must be in one of the list regions.
All working in Switzerland North again this morning!
More regions will be deployed tomorrow. The fix should be deployed in all regions by the end of week. Your connected AI Service Account, not the project, must be in one of the list regions.
Is swedencentral planned for today? 🥺
Can you update us here as you continue to deploy to more regions please? I'm EAST US2.
Hello, can you please provide an update for the East region?
The fix is now available in these regions:
- West US 3
- Japan East
- UK South
- Poland Central
More regions, including East US 2 should be available on Wednesday. East US and Sweden Central should be available on Thursday.
Thanks.
Hi apryiomka, Ty for the help, Has the fix already been applied in the East 2 region?
The fix is now available in these regions:
- France Central
- Australia East
- East US 2
Tomorrow we plan to deploy in East US and Sweden Central. Thanks everyone for your patience.
@apryiomka Great to hear. Please let us know when you've deployed to East US & Sweden Central. Eager to start using it again. 😄 Thanks for excellent communication!
@apryiomka, thanks for your help. I'm still seeing that server_error though in certain MCP cases like with the remote Tavily MCP server. I'm also seeing the above assertion error still when trying to use the GitMCP server.