Skip to content

Commit 3904d09

Browse files
Allow MCP call in function approval request
Co-authored-by: eavanvalkenburg <[email protected]>
1 parent 3866935 commit 3904d09

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎python/packages/core/agent_framework/_types.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ def __init__(
19841984
self,
19851985
*,
19861986
id: str,
1987-
function_call: FunctionCallContent | MutableMapping[str, Any],
1987+
function_call: FunctionCallContent | MCPServerToolCallContent | MutableMapping[str, Any],
19881988
annotations: Sequence[Annotations | MutableMapping[str, Any]] | None = None,
19891989
additional_properties: dict[str, Any] | None = None,
19901990
raw_representation: Any | None = None,
@@ -2009,7 +2009,10 @@ def __init__(
20092009
self.id = id
20102010
# Convert dict to FunctionCallContent if needed (for SerializationMixin support)
20112011
if isinstance(function_call, MutableMapping):
2012-
self.function_call = FunctionCallContent.from_dict(function_call)
2012+
if function_call.get("type") == "mcp_server_tool_call":
2013+
self.function_call = MCPServerToolCallContent.from_dict(function_call)
2014+
else:
2015+
self.function_call = FunctionCallContent.from_dict(function_call)
20132016
else:
20142017
self.function_call = function_call
20152018
# Override the type for this specific subclass

‎python/packages/core/tests/core/test_types.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,15 @@ def test_function_approval_serialization_roundtrip():
547547
# The Contents union will need to be handled differently when we fully migrate
548548

549549

550+
def test_function_approval_accepts_mcp_call():
551+
"""Ensure FunctionApprovalRequestContent supports MCP server tool calls."""
552+
mcp_call = MCPServerToolCallContent(call_id="c-mcp", tool_name="tool", server_name="srv", arguments={"x": 1})
553+
req = FunctionApprovalRequestContent(id="req-mcp", function_call=mcp_call)
554+
555+
assert isinstance(req.function_call, MCPServerToolCallContent)
556+
assert req.function_call.call_id == "c-mcp"
557+
558+
550559
# region BaseContent Serialization
551560

552561

0 commit comments

Comments
 (0)