Skip to content

Conversation

@eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Jan 9, 2026

Motivation and Context

Introduces a parameter for tools and prompt to configure how the results are parsed.
Three values:

  • True -> use the default parsing which transforms the MCP types to AF Types
  • Callable -> allows you to pass a function that get's called with the result
  • None -> no parsing, MCP types returned directly

Fixes #2884 by doing a more robust check before attempting to use, also returns the ClosedResourceError to the user, so it's easier to decide on recovery by the user.
Fixes #2848 by introducing paging support in the load_tools and load_prompts method
Fixes #3153 to further enhance json parsing
Closes #3013 by adding a test to test_tools that validates that case

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings January 9, 2026 14:14
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 9, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _mcp.py3776283%115, 175, 184, 248, 258–259, 280, 370, 392–395, 405, 440, 442, 446–447, 449–450, 453–454, 457–458, 504, 519, 537, 578, 684, 697–702, 724, 739, 742–744, 759–760, 766–768, 787, 796, 799–801, 816–817, 821–825, 842–846, 986
   _tools.py7576990%241, 287, 338, 340, 368, 538, 570–571, 673, 675, 695, 713, 727, 739, 744, 746, 753, 786, 842–844, 885, 908, 910–919, 928–934, 970, 980, 1221, 1557, 1635–1639, 1760, 1829, 1922, 1928, 1971–1972, 1985–1986, 2115, 2156–2157, 2185–2187, 2229–2230, 2295–2296, 2303–2304
TOTAL17718289383% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2641 155 💤 0 ❌ 0 🔥 59.254s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces improvements to the MCP (Model Context Protocol) integration in the Python Agent Framework, addressing three key issues:

Key Changes:

  • Adds configurable result parsing with parse_tool_results and parse_prompt_results parameters (True/Callable/None)
  • Implements pagination support for load_tools() and load_prompts() methods to handle MCP servers with large tool/prompt catalogs
  • Introduces proactive connection validation via _is_connection_valid() and _ensure_connected() to handle connection loss gracefully

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
python/uv.lock Minor dependency updates (huggingface-hub, litellm, litellm-proxy-extras)
python/packages/core/tests/core/test_tools.py Adds comprehensive test for nested object arrays in JSON schema validation
python/packages/core/tests/core/test_mcp.py Extensive pagination tests, duplicate handling tests, and connection loss recovery tests
python/packages/core/agent_framework/_mcp.py Implements pagination loops, connection validation logic, and configurable result parsing in call_tool/get_prompt methods

Copy link
Contributor

@giles17 giles17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should also fix this issue? #2708

@eavanvalkenburg
Copy link
Member Author

I believe this should also fix this issue? #2708

maybe, we can have them check after it merged and released.

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jan 13, 2026
Merged via the queue into microsoft:main with commit b2893fb Jan 13, 2026
23 checks passed
howlowck pushed a commit to howlowck/agent-framework that referenced this pull request Jan 13, 2026
…on for loading and a param to control representation (microsoft#3154)

* pagination support (microsoft#2848) added a parse_tool_result param and connection loss (microsoft#2884)

* fix microsoft#3153

* improved connection handling

* improved logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

4 participants