Skip to content

Python: Call MCP tools with optional taskSupport through plain tools/call - #9690

Closed
NingLin Liu (ninglinLiu) wants to merge 1 commit into
microsoft:mainfrom
ninglinLiu:fix/mcp-optional-task-support
Closed

NingLin Liu (ninglinLiu) wants to merge 1 commit into
microsoft:mainfrom
ninglinLiu:fix/mcp-optional-task-support

Conversation

@ninglinLiu

@ninglinLiu NingLin Liu (ninglinLiu) commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

Since the MCP 2.x migration, MCPTool._load_tools_locked skips every tool whose execution.taskSupport is "required" or "optional". Per the MCP spec, "optional" means a client may add task augmentation, but a plain tools/call is still valid; only "required" tools need the Tasks extension. As reported in #9675, Foundry Toolbox marks its Power BI and Foundry IQ tools as "optional", so they all disappear from the agent after upgrading to 1.23, even though they worked as plain calls on 1.21.

python/packages/core/AGENTS.md already documents the intended behavior: "Tools that advertise execution.taskSupport == "required" are skipped with a warning; optional and task-free tools continue through ordinary tools/call." The code didn't match it.

Description & Review Guide

  • What are the major changes? The skip check in _load_tools_locked now only applies to taskSupport == "required", and the warning says "requires" instead of "(might) require". "optional" tools are loaded and invoked through the existing plain tools/call path (no task augmentation is sent).
  • What is the impact of these changes? Tools advertising "optional" task support are available again. "required" tools are still skipped with the same warning, and "forbidden"/unset tools are unchanged.
  • The existing test_load_tools_skips_task_capable_tools test is renamed to test_load_tools_skips_only_task_required_tools and now checks that the "optional" tool is loaded (with its _meta), is called through call_tool, and that only the "required" tool is logged as skipped. It fails on main and passes with the change.

Tests: pytest packages/core/tests/core/test_mcp.py (463 passed, 2 skipped); ruff check and ruff format --check on the changed files are clean.

Related Issue

Fixes #9675

No open PR exists for this issue. The issue hasn't been labeled ready-for-implementation yet; this small change brings the code in line with the behavior already documented in python/packages/core/AGENTS.md, and I'm happy to adjust if maintainers prefer a different direction (e.g. making it configurable).

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: issue analysis, implementation, test update, and this PR description were prepared with AI assistance and reviewed/tested by the author.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow fix matches the documented behavior, includes focused regression coverage, and has no unresolved findings.

No open issues 🎉

What changed in this PR

Restores Python MCP tools with optional task support, addressing #9675 while preserving the existing plain tools/call invocation path.

Changes:

  • Skips only tools that require the Tasks extension and clarifies the warning.
  • Updates regression coverage to verify optional tools load with metadata and are invoked, while required tools remain excluded.
File Description
python/​packages/​core/​tests/​core/​test_mcp.py Updates assertions for tool loading, metadata, invocation, and skip warnings.
python/​packages/​core/​agent_framework/​_mcp.py Allows optional-task tools through the existing loading and invocation path.

Review effort: Balanced

@jpalvarezl

Copy link
Copy Markdown
Member

Thank you for the contribution. However, the fix requires a couple of documentation updates as well. For the sake of speed, we will move forward with our own fix this time: #9746

This branch was successfully deployed

No deployments
github-app-auth — dd1a604a Deployed Oct 25, 2026 by ninglinLiu via team_check #7432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: MCP tools with execution.taskSupport "optional" are skipped, although they can be called without Tasks

3 participants