-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Description
I’m using MCP tools (HTTP) with OAuth On‑Behalf‑Of in a FastAPI AG‑UI endpoint. I want Human‑in‑the‑Loop approvals for MCP tool calls. The SDK executes approvals via _try_execute_function_calls, but MCP tools attached to ChatAgent are not visible in the orchestrator’s collect_server_tools(), so approved MCP calls fail to execute.
Expected
If an MCP tool is attached to a ChatAgent and is connected (or can be connected), its functions should be visible to tool‑execution in the approval flow, or the SDK should expose a supported way to retrieve “effective tools” including MCP functions before executing approvals.
Actual
Approved MCP tool calls fail to execute. Logs show tool invocation failure or “function not found,” because MCP tools are not included in collect_server_tools().
Is this architecture supported? My implementation works with inline tools. Basically, within my FastAPI endpoint I wrap the agent like so:
async with create_authenticated_mcp_tool(agent_state) as mcp_tool:
request_agent = create_agent_with_mcp_tools(mcp_tool)
wrapped_agent = AgentFrameworkAgent(
agent=request_agent,
state_schema=None,
predict_state_config=None,
)The create_authenticated_mcp_tool reads the agent state to retrieve the user assertion and generate the proper JWT for the MCP Server.
I used the ag_ui code that is not yet published as a package but available on the master branch.
Code Sample
Error Messages / Stack Traces
```JSON
Log of the resolve_approval_responses (request)
{
"approval": {
"type": "function_approval_response",
"id": "call_emf5tTsLBBNXd1onwM2bx5Xb",
"approved": true,
"function_call": {
"type": "function_call",
"call_id": "call_emf5tTsLBBNXd1onwM2bx5Xb",
"name": "cour_cassation_fr_summary_search",
"arguments": "{\"query\":\"encadrement des loyers Cour de cassation\",\"page\":0,\"operator\":\"or\",\"date_start\":\"2014-01-01\",\"date_end\":\"2026-01-13\",\"sort\":\"date\"}"
}
},
"code.filepath": "src/agent_framework_ag_ui/_orchestrators.py",
"code.function": "DefaultOrchestrator.run.<locals>._resolve_approval_responses",
"code.lineno": 520,
"idx": 0,
"logfire.msg_template": "Processing approval {idx}: {approval}"
}Log of the result of the tool execution (nothing happened)
{
"approved_function_results": [
{
"type": "function_approval_response",
"id": "call_emf5tTsLBBNXd1onwM2bx5Xb",
"approved": true,
"function_call": {
"type": "function_call",
"call_id": "call_emf5tTsLBBNXd1onwM2bx5Xb",
"name": "cour_cassation_fr_summary_search",
"arguments": "{\"query\":\"encadrement des loyers Cour de cassation\",\"page\":0,\"operator\":\"or\",\"date_start\":\"2014-01-01\",\"date_end\":\"2026-01-13\",\"sort\":\"date\"}"
}
}
],
"code.filepath": "src/agent_framework_ag_ui/_orchestrators.py",
"code.function": "DefaultOrchestrator.run.<locals>._resolve_approval_responses",
"code.lineno": 521,
"logfire.msg_template": "Result: {approved_function_results}"
}And this is what ends up being send to the LLM as the tool output:
Error: Tool call invocation failed.
### Package Versions
1.0.0b260107
### Python Version
3.13
### Additional Context
_No response_