.NET: Add MCP long-running task support for MCP client tools#5994
Open
peibekwe wants to merge 4 commits into
Open
.NET: Add MCP long-running task support for MCP client tools#5994peibekwe wants to merge 4 commits into
peibekwe wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new .NET (alpha) Microsoft.Agents.AI.Mcp package that enables Microsoft Agent Framework agents to transparently invoke MCP tools using the MCP long-running tasks extension (SEP-2663), including polling to completion and best-effort remote cancellation.
Changes:
- Introduces
McpClientTaskExtensions.ListAgentToolsWithTaskSupportAsync(...)to wrap task-capable MCP tools (Optional/Required) in a task-awareAIFunction. - Implements
TaskAwareMcpClientAIFunctionandMcpTaskOptionsto drivetools/call(task-augmented) →tasks/getpolling →tasks/result, with fallback to non-task invocation when needed. - Adds unit tests + an end-to-end sample demonstrating transparent long-running task handling, and wires the sample into sample verification + solution.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Mcp/Microsoft.Agents.AI.Mcp.csproj | New alpha MCP integration package project definition and dependencies. |
| dotnet/src/Microsoft.Agents.AI.Mcp/McpClientTaskExtensions.cs | Adds extension method to list tools and wrap task-capable ones for agent usage. |
| dotnet/src/Microsoft.Agents.AI.Mcp/McpTaskOptions.cs | Defines configurable task lifecycle options (TTL hint + remote-cancel behavior). |
| dotnet/src/Microsoft.Agents.AI.Mcp/TaskAwareMcpClientAIFunction.cs | Implements the task-aware wrapper driving call/poll/result + cancellation handling. |
| dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/Microsoft.Agents.AI.Mcp.UnitTests.csproj | Adds new unit test project for the MCP task-aware client functionality. |
| dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/InMemoryMcpServerFixture.cs | In-proc server/client fixture for testing tasks behavior without sockets/processes. |
| dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/TestTools.cs | Test helper to create MCP tools with specific task support metadata. |
| dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/ListAgentToolsWithTaskSupportTests.cs | Validates wrapping behavior + null client argument validation. |
| dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/TaskAwareMcpClientAIFunctionTests.cs | Validates happy paths, TTL propagation, cancellation, and failure behavior. |
| dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/McpTaskOptionsTests.cs | Verifies option defaults. |
| dotnet/samples/02-agents/ModelContextProtocol/README.md | Adds the new long-running task client sample to the MCP samples index. |
| dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_LongRunningTask_Client/README.md | New sample documentation describing task support behavior and usage. |
| dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_LongRunningTask_Client/Program.cs | New sample demonstrating stdio MCP server + client wrapper + Run/RunStreaming. |
| dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_LongRunningTask_Client/Agent_MCP_LongRunningTask_Client.csproj | New sample project wiring required dependencies and project references. |
| dotnet/eng/verify-samples/AgentsSamples.cs | Registers the new sample for verification. |
| dotnet/agent-framework-dotnet.slnx | Adds new package, test project, and sample to the solution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds Microsoft Agent Framework client-side support for the MCP tasks extension.
A new
Microsoft.Agents.AI.Mcp(alpha) package introducesMcpClient.ListAgentToolsWithTaskSupportAsync, which wraps any MCP tool advertising task support with a task-awareAIFunction. The wrapper transparently drives the lifecycle inside the agent's function-calling loop.Contribution Checklist