Skip to content

Python: Add Python parity for InvokeMcpTool in declarative workflow - #5630

Merged
Peter Ibekwe (peibekwe) merged 9 commits into
mainfrom
peibekwe/declarative-mcp-tool-python
May 5, 2026
Merged

Python: Add Python parity for InvokeMcpTool in declarative workflow#5630
Peter Ibekwe (peibekwe) merged 9 commits into
mainfrom
peibekwe/declarative-mcp-tool-python

Conversation

@peibekwe

Copy link
Copy Markdown
Contributor

Motivation and Context

Adds Python implementation of the InvokeMcpTool declarative workflow action, achieving parity with the .NET implementation. Workflow authors can now dispatch MCP calls directly from YAML.

The PR also includes sample to showcase the use of the new action.

Fixes #5625

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 May 4, 2026 21:05
@moonbox3 Evan Mattson (moonbox3) added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels May 4, 2026
@github-actions github-actions Bot changed the title Add Python parity for InvokeMcpTool in declarative workflow Python: Add Python parity for InvokeMcpTool in declarative workflow May 4, 2026
@moonbox3

Evan Mattson (moonbox3) commented May 4, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/declarative/agent_framework_declarative/_workflows
   _declarative_builder.py3751197%177, 209, 273, 364, 386, 447, 449, 477, 541, 544, 965
   _executors_mcp.py2642989%136, 139, 331–334, 337–338, 381, 384, 390, 393, 402, 412, 416, 431, 434, 447, 450, 461–463, 475–477, 514–515, 577, 608
   _factory.py151298%469, 524
   _mcp_handler.py184796%92, 271–272, 390–392, 413
TOTAL32711374788% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
6369 30 💤 0 ❌ 0 🔥 1m 51s ⏱️

@github-actions github-actions Bot 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.

Automated Code Review

Reviewers: 4 | Confidence: 89% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by peibekwe's agents

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.

Pull request overview

Adds Python declarative-workflow support for InvokeMcpTool, bringing the Python SDK closer to the existing .NET MCP action support and exposing the feature through the declarative workflow factory, executor, handler, tests, and samples.

Changes:

  • Adds the Python InvokeMcpTool executor/handler path, including approval-flow support and WorkflowFactory(mcp_tool_handler=...).
  • Exposes the new MCP workflow types through declarative package exports and core re-exports.
  • Adds unit tests plus a new declarative sample demonstrating MCP-backed document search with a downstream agent.

Reviewed changes

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

Show a summary per file
File Description
python/samples/03-workflows/declarative/invoke_mcp_tool/workflow.yaml New sample workflow invoking an MCP tool, storing results, and passing context to an agent.
python/samples/03-workflows/declarative/invoke_mcp_tool/main.py Sample runner for the MCP workflow, including optional approval prompts.
python/packages/declarative/tests/test_invoke_mcp_tool_executor.py New executor-focused tests for validation, output handling, approval flow, and errors.
python/packages/declarative/tests/test_default_mcp_tool_handler.py New handler-focused tests for caching, lifecycle, normalization, and error mapping.
python/packages/declarative/AGENTS.md Documents the new MCP transport abstractions in the declarative package overview.
python/packages/declarative/agent_framework_declarative/_workflows/_mcp_handler.py Implements the MCP handler protocol and default streamable-HTTP-backed handler.
python/packages/declarative/agent_framework_declarative/_workflows/_factory.py Threads mcp_tool_handler through WorkflowFactory.
python/packages/declarative/agent_framework_declarative/_workflows/_executors_mcp.py Adds the InvokeMcpTool executor, result parsing, approval flow, and conversation integration.
python/packages/declarative/agent_framework_declarative/_workflows/_declarative_builder.py Registers InvokeMcpTool, validates required fields, and enforces handler presence.
python/packages/declarative/agent_framework_declarative/_workflows/__init__.py Re-exports MCP executor and handler symbols from the workflows package.
python/packages/declarative/agent_framework_declarative/__init__.py Re-exports MCP workflow symbols from the declarative package root.
python/packages/core/agent_framework/declarative/__init__.pyi Updates type stubs for the new declarative MCP exports.
python/packages/core/agent_framework/declarative/__init__.py Updates lazy core re-exports to surface the new declarative MCP types.

@github-actions github-actions Bot 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.

Automated Code Review

Reviewers: 3 | Confidence: 83% | Result: All clear

Reviewed: Correctness, Security Reliability, Design Approach


Automated review by peibekwe's agents

Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
@peibekwe
Peter Ibekwe (peibekwe) added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit f25e817 May 5, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Port InvokeMCP action support to Python in Declarative

6 participants