Skip to content

fix(fx-core): generate DT add-MCP action inline instead of v4 modify front door#16306

Merged
wh-alice merged 3 commits into
release/6.12from
fix/mcp-da-dt-add-mcp
Jul 8, 2026
Merged

fix(fx-core): generate DT add-MCP action inline instead of v4 modify front door#16306
wh-alice merged 3 commits into
release/6.12from
fix/mcp-da-dt-add-mcp

Conversation

@Alive-Fish

Copy link
Copy Markdown
Contributor

Summary

Fixes the Dynamic Tool Discovery (DT) "add MCP action" flow (atk add action --api-plugin-type mcp). Previously, with DT on, the flow routed through the v4 modify front door + add-mcp-server template, which produced an incomplete oauth/register action in m365agents.yml and coupled DT to TEAMSFX_V4_ENABLED. DT now generates the plugin manifest and auth wiring directly in core.addPlugin, independent of v4.

What changed

  • Inline DT add-MCP (FxCore.declarativeAgent.ts): DT-on add action --api-plugin-type mcp writes the URL-only ai-plugin.json (no static tools list, no enable_dynamic_discovery) and wires oauth/register / dcr/register via the shared injector — no longer via modifyProjectFrontDoor. Works with TEAMSFX_V4_ENABLED off.
  • URL-derived naming: the oauth/register action name and registrationId are derived from the MCP server URL (shared verbatim with the create flow), so re-adding the same server is idempotent (one registration per server) and different servers get distinct registrations. Fixes the previous action_<n>-based naming that could skip creating a needed registration.
  • Auth-metadata probe: when the caller doesn't pass --mcp-da-auth-metadata-url, the MCP server is probed to discover it (mirrors the create flow) so oauth / oauth-dynamic resolve real authorization/token/well-known URLs instead of empty ones.
  • Feature flag: TEAMSFX_MCP_FOR_DA_DT is enabled by default; FeatureFlagManager.listEnabled now includes default-on flags.
  • CLI: regenerated AddPluginInputs / AddPluginOptions for the DT auth-type + credential options.
  • e2e: added MCP no-auth / with-auth / edge-case coverage.

The v4 add-mcp-server modify template is intentionally untouched — the shipped DT flow no longer depends on it.

Testing

  • packages/fx-core unit: tests/core/FxCore.declarativeAgent.test.ts (inline flow, oauth/entra-sso/oauth-dynamic naming, metadata probe) + tests/common/featureFlags.test.ts — green.
  • tsc -p ./ clean.
  • e2e env matrix validated locally with atk new: dynamic (V4 on) vs static (V4 off).

…front door

DT-on 'add action --api-plugin-type mcp' now writes the URL-only ai-plugin manifest and wires oauth/register directly in core.addPlugin, independent of TEAMSFX_V4_ENABLED. The oauth/register action name and registrationId are derived from the MCP server URL so re-adding the same server is idempotent, and the server is probed for auth metadata when none is provided. Enable TEAMSFX_MCP_FOR_DA_DT by default and fix FeatureFlagManager.listEnabled for default-on flags. Add e2e coverage for MCP no-auth/auth/edge-case flows.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

❌ VscUse Test Plan — Tests unknown

Why these tests: PR fixes the DA DT add-MCP action flow with auth wiring changes; changed e2e test files map directly to the three DA_MCP_*_Remote plans (no-auth, OAuth, Entra SSO edge cases) and Feature_DA_Add_MCP_Server covers the VS Code UI add-MCP-server flow.

Branch diff: fix/mcp-da-dt-add-mcprelease/6.12

Plans run:

  • DA_MCP_None_Remote
  • DA_MCP_Oauth_Remote
  • DA_MCP_Entra_SSO_Remote
  • Feature_DA_Add_MCP_Server

Step Status
1️⃣ Build VSIX (CD) ✅ Done
2️⃣ Build Docker image ✅ Done
3️⃣ Run UI tests ❌ Tests unknown
ℹ️ How were these tests selected?

GitHub Copilot (Claude Sonnet 4.6, high reasoning) analysed the PR title, description, and the diff between
fix/mcp-da-dt-add-mcp and release/6.12
to pick the most relevant test plans from packages/tests/vscuse/Index.md.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Test Selection — AI Selected

Why these tests: The fx-core changes are focused on declarativeAgent (FxCore.declarativeAgent.ts, AddPluginInputs/Options) and featureFlags; the directly modified e2e test files are all in declarativeAgent/mcp/, so all declarativeAgent/* tests are selected as the most targeted set covering the affected area.

Cases selected (13):

  • ./declarativeAgent/DeclarativeAgentBasic.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithApiKeyAuth.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithOAuth.tests.ts
  • ./declarativeAgent/DeclarativeAgentInvalidManifestShape.tests.ts
  • ./declarativeAgent/mcp/DeclarativeAgentMCPNoAuth.tests.ts
  • ./declarativeAgent/mcp/DeclarativeAgentMCPAuthEdgeCases.tests.ts
  • ./declarativeAgent/mcp/DeclarativeAgentMCPWithAuth.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithEntra.tests.ts
  • ./declarativeAgent/typespec/typespec.withoutAction.tests.ts
  • ./declarativeAgent/typespec/typespec.withAction.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithNoneAuth.tests.ts
  • ./declarativeAgent/addKnowledge/AddWebSearchByAll.tests.ts
  • ./declarativeAgent/addKnowledge/AddWebSearchByUrl.tests.ts

View pipeline run

Need to run more tests?

Comment on this PR:

  • /e2e-run ./path/to/test.tests.ts — add specific cases to AI selection
  • /e2e-run-all — run all e2e cases

Then re-run the workflow.

…solution fails

The DT add-MCP inline path wrapped endpoint resolution and yml injection in one try/catch, so a failed auth-metadata probe (unreachable server / no resource_metadata) skipped the oauth/register injection entirely — leaving the ai-plugin referencing a registration that was never created. Split into two best-effort steps (mirroring the create flow): endpoint resolution failure now leaves endpoints empty but the oauth/register (or dcr/register) action is still written for the developer to complete. Verified end-to-end via the CLI add-action flow.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

❌ VscUse Test Plan — Tests failure

Why these tests: PR fixes the DT add-MCP action flow in FxCore.declarativeAgent.ts and adds MCP e2e tests (NoAuth, WithAuth, AuthEdgeCases), so MCP-specific DA plans and the add-action OAuth plan are the most relevant coverage.

Branch diff: fix/mcp-da-dt-add-mcprelease/6.12

Plans run:

  • DA_MCP_None_Remote
  • DA_MCP_Oauth_Remote
  • DA_MCP_Entra_SSO_Remote
  • Feature_DA_Add_MCP_Server
  • DA_Add_Action_Import_Existing_API_Basic_OAuth

Step Status
1️⃣ Build VSIX (CD) ✅ Done
2️⃣ Build Docker image ✅ Done
3️⃣ Run UI tests ❌ Tests failure

🎯 Actual UI test run
🔗 Full pipeline results
📊 Detailed test report

ℹ️ How were these tests selected?

GitHub Copilot (Claude Sonnet 4.6, high reasoning) analysed the PR title, description, and the diff between
fix/mcp-da-dt-add-mcp and release/6.12
to pick the most relevant test plans from packages/tests/vscuse/Index.md.

Read package.json via require (the same cached object utils.ts/templateHelper.ts use) so mutating .version in a test actually affects the code under test; a default JSON import yielded a separate object under vitest, so version mutations were silently ignored and tests read the release-bumped (rc) version.

Fix assertions that only passed due to that import/require mismatch: VS beta -> templates-vs@0.0.0-rc, VSC rc -> templates@0.0.0-rc/ts.zip, templateHelper alpha -> useLocalTemplate() true. Control packageJson.version in the local-vs-remote generator test so it runs the version comparison instead of the rc short-circuit.
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

❌ VscUse Test Plan — Tests failure

Why these tests: PR fixes the Declarative Agent Dynamic Tool Discovery add-MCP action flow (auth wiring, oauth/register, dcr/register), directly mapping to DA_MCP_* remote plans and the Feature_DA_Add_MCP_Server VS Code UI feature plan.

Branch diff: fix/mcp-da-dt-add-mcprelease/6.12

Plans run:

  • DA_MCP_None_Remote
  • DA_MCP_Oauth_Remote
  • DA_MCP_Entra_SSO_Remote
  • Feature_DA_Add_MCP_Server

Step Status
1️⃣ Build VSIX (CD) ✅ Done
2️⃣ Build Docker image ✅ Done
3️⃣ Run UI tests ❌ Tests failure

🎯 Actual UI test run
🔗 Full pipeline results
📊 Detailed test report

ℹ️ How were these tests selected?

GitHub Copilot (Claude Sonnet 4.6, high reasoning) analysed the PR title, description, and the diff between
fix/mcp-da-dt-add-mcp and release/6.12
to pick the most relevant test plans from packages/tests/vscuse/Index.md.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/6.12@62b9014). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ckages/fx-core/src/core/FxCore.declarativeAgent.ts 85.29% 2 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##             release/6.12   #16306   +/-   ##
===============================================
  Coverage                ?   87.01%           
===============================================
  Files                   ?      628           
  Lines                   ?    32864           
  Branches                ?     7732           
===============================================
  Hits                    ?    28595           
  Misses                  ?     2438           
  Partials                ?     1831           
Files with missing lines Coverage Δ
packages/fx-core/src/common/featureFlags.ts 96.92% <100.00%> (ø)
...s/fx-core/src/question/options/AddPluginOptions.ts 100.00% <ø> (ø)
...ckages/fx-core/src/core/FxCore.declarativeAgent.ts 81.05% <85.29%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/fx-core/src/common/featureFlags.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants