[BUG] foundry_agents_connect tool call fail with serialization error
Describe the bug
I'm using the Azure MCP server to query our AI Foundry agents.
While it succesfully fetched the agent I wanted interacting with and created a message; I got the following response (after the result was returned from the agent in AI Foundry)
There was an error finding or calling tool and command.
Failed to call namespace: foundry, command: foundry_agents_connect
Error: JsonTypeInfo metadata for type 'System.Collections.Generic.List1[<>f__AnonymousType04[System.String,System.String,System.Single,System.Collections.Generic.IReadOnlyList`1[Azure.AI.Agents.Persistent.FileSearchToolCallContent]]]' was not provided by TypeInfoResolver of type 'Azure.Mcp.Tools.Foundry.Commands.FoundryJsonContext'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically. The unsupported member type is located on type 'System.Object'. Path: $.Result.
Run again with the "learn=true" to get a list of available commands and their parameters.
Whatever I do, I keep getting this issue.
So probably something is wrong here?
Expected behavior
it should just return the data as is.
Actual behavior
It throws an error.
Reproduction Steps
using the Azure MCP server to query AI Foundry agents
Environment
No response
Thank you so much for reporting this issue, @michaelbrackedev - we'll prioritize investigating and getting a fix out soon.
@JasonYeMSFT could you add additional test coverage for these new Foundry tools at the same time?
I made a fix in the linked PR. To prevent this from happening again, I made some changes so future attempts to pass non-serializable objects in the command result will cause build failures.