Skip to content

Parameter Argument Errors Aren't Communicated #830

@Jaben

Description

@Jaben

Describe the bug
The MCPTool parameter arguments throw ArgumentExceptions which is won't communicate propertly. Since this is not an "MCPException" -- the LLM gets no real feedback on the error -- doomed to repeat it. This plays into issue #820 which would allow us to handle exceptions.

To Reproduce
Pass incorrect arguments to an MCP tool endpoint.

Expected behavior
Communicate to the LLM that the argument was wrong instead of "An error occurred invoking 'tool_thing'."

Logs

System.ArgumentException: The arguments dictionary is missing a value for the required parameter 'request'. (Parameter 'arguments')
 at Microsoft.Shared.Diagnostics.Throw.ArgumentException(String paramName, String message)
at Microsoft.Extensions.AI.AIFunctionFactory.ReflectionAIFunctionDescriptor.<>c__DisplayClass34_0.<GetParameterMarshaller>b__4(AIFunctionArguments arguments, CancellationToken _)
    at Microsoft.Extensions.AI.AIFunctionFactory.ReflectionAIFunction.InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken)
   at Microsoft.Extensions.AI.AIFunctionFactory.ReflectionAIFunction.InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken)
    at ModelContextProtocol.Server.AIFunctionMcpServerTool.InvokeAsync(RequestContext`1 request, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions