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.py3886782%114, 174, 183, 247, 257–258, 279, 369, 396, 430–431, 433–441, 443–445, 448–449, 495, 510, 528, 569, 582, 625, 675, 696, 702–706, 709, 711, 755, 768, 771–773, 776–777, 780–781, 803, 810, 813–816, 818–823, 840–844, 984
   _tools.py7566990%241, 287, 338, 340, 368, 538, 570–571, 673, 675, 695, 713, 727, 739, 744, 746, 753, 786, 840–842, 883, 906, 908–917, 926–932, 968, 978, 1219, 1555, 1633–1637, 1758, 1827, 1920, 1926, 1969–1970, 1983–1984, 2113, 2154–2155, 2183–2185, 2227–2228, 2293–2294, 2301–2302
TOTAL17700289683% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2632 154 💤 0 ❌ 0 🔥 1m 1s ⏱️

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

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

Labels

Projects

None yet

2 participants