Skip to content

Python: Add MCP hosting helpers#7209

Merged
eavanvalkenburg merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:hosting-mcp-helpers
Jul 21, 2026
Merged

Python: Add MCP hosting helpers#7209
eavanvalkenburg merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:hosting-mcp-helpers

Conversation

@eavanvalkenburg

@eavanvalkenburg eavanvalkenburg commented Jul 20, 2026

Copy link
Copy Markdown
Member

Motivation & Context

Agent Framework needs a small, framework-neutral boundary for exposing agents and workflows through MCP without owning the MCP server, transport, authentication, or deployment model. This adds native MCP conversion helpers and optional adapters while preserving application control over the server architecture.

Description & Review Guide

  • What are the major changes? Adds the agent-framework-hosting-mcp package with mcp_to_run(...), mcp_from_run(...), AgentMCPTool, and WorkflowMCPTool; adds stateless, session-aware, manual, FastMCP, and workflow samples; adds unit and streamable HTTP integration coverage; and updates package registration, CI, lifecycle documentation, and the hosting specification.
  • What is the impact of these changes? Applications can expose an Agent Framework agent or workflow as an MCP tool while continuing to use native MCP SDK servers and transports. The adapters can derive aligned tool schemas, selectively expose chat options, and integrate with application-owned agent sessions or workflow factories.
  • What do you want reviewers to focus on? The boundary between package-owned conversion/schema alignment and application-owned MCP server, session security, concurrency, workflow continuation, and transport concerns.

Related Issue

Fixes #6592

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 is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • 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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5d6987cd-1b67-4ba1-8b54-3c50da6e7607
Copilot AI review requested due to automatic review settings July 20, 2026 11:54
@giles17 giles17 added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Jul 20, 2026
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/hosting-mcp/agent_framework_hosting_mcp
   _agent_tool.py65887%72, 74, 82, 97, 151, 155, 163, 167
   _conversion.py500100% 
   _workflow_tool.py59394%94, 108, 140
TOTAL45032511488% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9164 33 💤 0 ❌ 0 🔥 2m 26s ⏱️

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 a new Python hosting helper package (agent-framework-hosting-mcp) that provides a framework-neutral boundary for exposing Agent Framework agents/workflows as MCP tools, plus samples, tests, and supporting registration/docs updates (Fixes #6592).

Changes:

  • Introduces agent-framework-hosting-mcp with conversion helpers (mcp_to_run, mcp_from_run) and adapters (MCPAgentTool, MCPWorkflowTool) for app-owned MCP servers.
  • Adds MCP hosting samples (manual, FastMCP, agent-derived, session-aware, workflow-derived) and corresponding unit + streamable HTTP integration coverage.
  • Registers the new package in the Python workspace/CI and documents the MCP hosting channel in the hosting spec.

Reviewed changes

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

Show a summary per file
File Description
python/uv.lock Adds the new workspace member and locked deps for agent-framework-hosting-mcp.
python/pyproject.toml Registers agent-framework-hosting-mcp as a workspace package.
python/PACKAGE_STATUS.md Tracks agent-framework-hosting-mcp as alpha.
python/AGENTS.md Lists the new MCP hosting helpers package in the Python agents index.
docs/specs/002-python-hosting-channels.md Documents the MCP hosting channel boundary and API surface.
.github/workflows/python-merge-tests.yml Includes hosting-mcp in path filters and integration test matrix.
.github/workflows/python-integration-tests.yml Adds hosting-mcp tests to integration runs.
python/samples/04-hosting/mcp/README.md Provides an overview and run instructions for the MCP hosting samples.
python/samples/04-hosting/mcp/pyproject.toml Adds a runnable sample environment definition for MCP hosting.
python/samples/04-hosting/mcp/manual_app.py Manual low-level MCP server sample using direct conversion helpers.
python/samples/04-hosting/mcp/fastmcp_app.py FastMCP sample using function-signature-derived tool schema + conversions.
python/samples/04-hosting/mcp/agent_app.py Low-level server sample using MCPAgentTool for schema+execution alignment.
python/samples/04-hosting/mcp/session_app.py Session-aware sample using AgentState + app-owned per-session locking.
python/samples/04-hosting/mcp/workflow_app.py Workflow sample using MCPWorkflowTool with typed input derivation.
python/packages/hosting-mcp/pyproject.toml New package definition, dependencies, and test/tooling configuration.
python/packages/hosting-mcp/README.md Package-level documentation for the conversion seam and adapters.
python/packages/hosting-mcp/AGENTS.md Defines the intended boundary and public API for contributors.
python/packages/hosting-mcp/LICENSE Adds MIT license file for the new package.
python/packages/hosting-mcp/agent_framework_hosting_mcp/init.py Exposes the public API surface and package version.
python/packages/hosting-mcp/agent_framework_hosting_mcp/_conversion.py Implements MCP↔Agent Framework argument/result conversions.
python/packages/hosting-mcp/agent_framework_hosting_mcp/_agent_tool.py Implements an agent-backed MCP tool adapter with optional session persistence.
python/packages/hosting-mcp/agent_framework_hosting_mcp/_workflow_tool.py Implements a workflow-backed MCP tool adapter with schema derivation and output conversion.
python/packages/hosting-mcp/agent_framework_hosting_mcp/py.typed Marks the package as typed for downstream type-checkers.
python/packages/hosting-mcp/tests/hosting_mcp/test_conversion.py Unit tests for conversion helpers.
python/packages/hosting-mcp/tests/hosting_mcp/test_agent_tool.py Unit tests for MCPAgentTool schema + session behavior.
python/packages/hosting-mcp/tests/hosting_mcp/test_workflow_tool.py Unit tests for MCPWorkflowTool schema derivation and behavior.
python/packages/hosting-mcp/tests/hosting_mcp/test_integration.py Streamable HTTP integration test invoking a locally-hosted MCP server.

Comment thread python/packages/hosting-mcp/tests/hosting_mcp/test_integration.py Outdated
Comment thread python/samples/04-hosting/mcp/README.md Outdated

@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: 5 | Confidence: 90% | Result: All clear

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


Automated review by eavanvalkenburg's agents

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5d6987cd-1b67-4ba1-8b54-3c50da6e7607
Comment thread python/samples/04-hosting/mcp/workflow_app.py
Comment thread python/packages/hosting-mcp/agent_framework_hosting_mcp/_agent_tool.py Outdated
@eavanvalkenburg
eavanvalkenburg added this pull request to the merge queue Jul 21, 2026
Merged via the queue into microsoft:main with commit a1f3e53 Jul 21, 2026
39 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.

Hosting: MCP channel

5 participants