.NET: Add Foundry Toolbox MCP skills discovery sample#6134
Conversation
Add a new sample demonstrating MCP-based skills discovery from a Foundry Toolbox endpoint using AgentSkillsProviderBuilder and AIContextProviders. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new .NET Foundry agent sample showing how to connect to a Foundry Toolbox MCP endpoint and use MCP-based Agent Skills as AI context.
Changes:
- Adds
Agent_Step26_FoundryToolboxMcpSkillssample with MCP transport, bearer-token handler, skills discovery, and agent creation. - Adds README usage/prerequisite guidance for the new sample.
- Registers the sample in the AgentsWithFoundry README and .NET solution.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
dotnet/samples/02-agents/AgentsWithFoundry/README.md |
Adds Step26 to the Foundry agents sample table. |
dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step26_FoundryToolboxMcpSkills/README.md |
Documents the new sample, prerequisites, env vars, and run command. |
dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step26_FoundryToolboxMcpSkills/Program.cs |
Implements the Foundry Toolbox MCP skills sample. |
dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step26_FoundryToolboxMcpSkills/Agent_Step26_FoundryToolboxMcpSkills.csproj |
Defines the new sample project and dependencies. |
dotnet/agent-framework-dotnet.slnx |
Adds the new sample project to the solution. |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 90%
✓ Correctness
The sample is missing the
Foundry-Features: Toolboxes=V1Previewheader in theHttpClientTransportOptionsfor the MCP transport, despite the PR description explicitly claiming it is included. Step25 adds this viaAdditionalHeaders(lines 51-54 of Step25's Program.cs) and the header is described as required for toolbox operations. Without it, the MCP connection to the Foundry Toolbox endpoint will likely fail at runtime. All other API usage (AgentSkillsProviderBuilder, AsAIAgent overload, AIContextProviders, RunAsync) is correct.
✓ Security Reliability
The PR adds a clean sample demonstrating MCP-based skills discovery. The main finding is a missing
Foundry-Features: Toolboxes=V1Previewheader that the PR description claims is present (matching Step25's pattern). Without it, the sample may fail at runtime if the Foundry Toolbox MCP endpoint requires this preview feature flag. Resource management (using/await using) and auth patterns are correct.
✓ Test Coverage
This PR adds a new sample project (Agent_Step26_FoundryToolboxMcpSkills) demonstrating MCP-based skills discovery. The repository's consistent pattern is that sample projects do not have dedicated test projects — they are demonstrative code meant to be run manually against live Azure services. The core library code exercised by this sample (AgentSkillsProviderBuilder.UseMcpSkills, AgentMcpSkillsSource) already has comprehensive unit test coverage in AgentMcpSkillsSourceTests.cs (10 test methods covering discovery, edge cases, invalid inputs, path traversal, binary resources) and AgentSkillsProviderBuilderTests.cs. No test coverage gaps were identified.
✗ Design Approach
I found one blocking design issue: the new Step26 sample constructs its MCP transport without the
Foundry-Features: Toolboxes=V1Previewheader, even though the existing Foundry toolbox samples and handlers in this repo treat that header as part of the toolbox request pattern. That means the sample does not actually match the Step25 contract it claims to demonstrate and can fail against preview toolbox MCP endpoints.
Flagged Issues
-
dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step26_FoundryToolboxMcpSkills/Program.cs:35-42creates the MCP transport withoutAditionalHeaders["Foundry-Features"] = "Toolboxes=V1Preview", which the established Foundry toolbox pattern requires (see Step25'sProgram.cs:44-56,FoundryToolboxBearerTokenHandler.cs:13-19, and related tests). The sample will not match the documented contract and may fail against preview toolbox MCP endpoints.
Automated review by semenshi's agents
- Add Foundry-Features: Toolboxes=V1Preview header to MCP transport options, matching the Step25 pattern - Document skill://index.json prerequisite in README Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…yToolboxMcpSkills/Program.cs Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
Adds a new sample demonstrating MCP-based skills discovery from a Foundry Toolbox endpoint using
AgentSkillsProviderBuilderandAIContextProviders.AgentSkillsProviderBuilder.UseMcpSkills()and injects them into an agentFoundry-Featuresheader and bearer token auth