Skip to content

Cherry-pick #16306 to dev: generate DT add-MCP action inline instead of v4 modify front door#16312

Closed
Alive-Fish with Copilot wants to merge 4 commits into
devfrom
copilot/cherry-pick-pr-16306-dev
Closed

Cherry-pick #16306 to dev: generate DT add-MCP action inline instead of v4 modify front door#16312
Alive-Fish with Copilot wants to merge 4 commits into
devfrom
copilot/cherry-pick-pr-16306-dev

Conversation

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Synchronizes PR #16306 (fix(fx-core): generate DT add-MCP action inline instead of v4 modify front door) from release/6.12 to dev. Previously, with DT on, atk add action --api-plugin-type mcp routed through the v4 modify front door, producing an incomplete oauth/register in m365agents.yml and coupling DT to TEAMSFX_V4_ENABLED.

Changes (cherry-picked)

  • Inline DT add-MCP (FxCore.declarativeAgent.ts): DT-on writes the URL-only ai-plugin.json and wires oauth/register / dcr/register via the shared injector directly in core.addPlugin, independent of TEAMSFX_V4_ENABLED. The v4 add-mcp-server modify template is untouched.
  • URL-derived naming: oauth/register name / registrationId derive from the MCP server URL (shared with the create flow), making re-adds idempotent (one registration per server).
  • Best-effort auth resolution: endpoint resolution and yml injection are split into two steps, so a failed auth-metadata probe (unreachable server / no resource_metadata) still writes the registration action for the developer to complete.
  • Feature flag: TEAMSFX_MCP_FOR_DA_DT defaults on; FeatureFlagManager.listEnabled now honours default-on flags.
  • CLI: regenerated AddPluginInputs / AddPluginOptions; added MCP no-auth / with-auth / edge-case e2e coverage.

Conflict resolution notes

  • FxCore.declarativeAgent.ts conflicted only because dev had already dropped a callCoreMethod: line from the old v4-dispatch block that this change deletes wholesale; the resolved file is byte-identical to the source commit with no dev-specific change lost.
  • Commit 3 of the source PR (test-infra) is intentionally omitted. It makes template-version tests version-independent for the release branch's rc versioning and the version-parsing useLocalTemplate logic — both refactored away on dev, which now uses a config-flag useLocalTemplate and a stable version. dev's utils.test.ts / generator.test.ts already pass without it, and applying it would target tests dev has removed.

…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.
…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.
Copilot AI changed the title [WIP] Cherry-pick changes from PR #16306 to dev branch Cherry-pick #16306 to dev: generate DT add-MCP action inline instead of v4 modify front door Jul 8, 2026
Copilot AI requested a review from Alive-Fish July 8, 2026 05:26
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

E2E Test Selection — AI Selected

Why these tests: The fx-core changes target declarativeAgent logic (FxCore.declarativeAgent.ts, AddPluginInputs/Options) and feature flags, so all declarativeAgent/* tests are included; the three MCP test files are returned directly as changed e2e tests (rule 7); feature/multienv covers the featureFlags.ts change impact.

Cases selected (14):

  • ./declarativeAgent/DeclarativeAgentBasic.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithApiKeyAuth.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithOAuth.tests.ts
  • ./declarativeAgent/DeclarativeAgentInvalidManifestShape.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithEntra.tests.ts
  • ./declarativeAgent/DeclarativeAgentWithNoneAuth.tests.ts
  • ./declarativeAgent/typespec/typespec.withoutAction.tests.ts
  • ./declarativeAgent/typespec/typespec.withAction.tests.ts
  • ./declarativeAgent/addKnowledge/AddWebSearchByAll.tests.ts
  • ./declarativeAgent/addKnowledge/AddWebSearchByUrl.tests.ts
  • ./declarativeAgent/mcp/DeclarativeAgentMCPNoAuth.tests.ts
  • ./declarativeAgent/mcp/DeclarativeAgentMCPWithAuth.tests.ts
  • ./declarativeAgent/mcp/DeclarativeAgentMCPAuthEdgeCases.tests.ts
  • ./feature/multienv.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.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.28%. Comparing base (cac6a2b) to head (d466617).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
...ckages/fx-core/src/core/FxCore.declarativeAgent.ts 97.05% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #16312      +/-   ##
==========================================
+ Coverage   87.26%   87.28%   +0.02%     
==========================================
  Files         631      633       +2     
  Lines       33084    33133      +49     
  Branches     7715     7724       +9     
==========================================
+ Hits        28870    28920      +50     
- Misses       2401     2407       +6     
+ Partials     1813     1806       -7     
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 82.40% <97.05%> (+4.02%) ⬆️

... and 12 files with indirect coverage changes

🚀 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.

@Alive-Fish

Copy link
Copy Markdown
Contributor

@copilot fix patch coverage

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix patch coverage

Fixed patch coverage: added three unit tests to FxCore.declarativeAgent.test.ts covering the previously-uncovered added lines in the DT add-MCP inline flow — the injectMCPAuthActionToYml failure warning path, the addAction error return, and the name_for_human folder-name fallback. All added source lines are now covered.

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.

[Cherry-pick] PR #16306 needs to be synchronized to other branches

2 participants