-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
.Net Bug: OpenApiSpec plugin does not work if RetainArgumentTypes = True.
I’ve run into a bit of a dilemma.
I have an agent based on SK. In this SK, I have some APIs imported into SK as plugins via OpenApiSpec, and I also have some MCP servers imported as SK plugins. Some of these MCP server tools have inputs that are objects or enums.
If I don’t set RetainArgumentTypes as true, the OpenApiSpec plugins work well, but for MCP server tools that accept objects as input, the MCP server side will throw errors like:
JSON value could not be converted to ...

On the other hand, if I do set RetainArgumentTypes = true, MCP server tools work correctly, but OpenApiSpec plugins fail. For example, when calling REST APIs (e.g., POST http requests), the payload’s value is no longer a string but a JsonElement with ValueKind = String.


semantic-kernel/dotnet/src/Functions/Functions.OpenApi/RestApiOperationRunner.cs
Line 495 in 51f4fe5
if (!arguments.TryGetValue(RestApiOperation.PayloadArgumentName, out object? argument) || argument is not string payload)
Currently, I work around this by adding a FunctionInvocationFilters that checks whether the argument comes from an MCP tool or an OpenAPI tool and manually adjusts the argument type.
I believe this should ideally be fixed inside the SK package itself.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status