Skip to content

fix(eng): keep tool catalog stderr out of prompt validation JSON - #3854

Merged
Amos Hersch (AmosHersch) merged 1 commit into
mainfrom
amoshersch-tool-catalog-stream-fix
Oct 6, 2026
Merged

Amos Hersch (AmosHersch) merged 1 commit into
mainfrom
amoshersch-tool-catalog-stream-fix

Conversation

@AmosHersch

@AmosHersch Amos Hersch (AmosHersch) commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Extracts the bottom engineering prerequisite for the planned Fabric tool PR stack, so the existing tool drafts can depend on one shared fix instead of carrying duplicate changes to eng/scripts/Test-ToolSelectionPrompts.ps1.

The prompt validator currently merges native startup diagnostics from stderr into the JSON returned by tools list --name-only. This removes only that stream merge: stdout is still parsed verbatim, stderr remains visible, and the existing exit-code, empty-output, and JSON-error handling stays unchanged. Script help documents this contract.

Adds five focused Pester cases covering clean stdout, valid stdout plus visible stderr, malformed stdout, valid JSON on stderr with invalid stdout, and rejection of non-JSON stdout prefixes rather than manufacturing a catalog. The tests execute the production capture/parsing statements with a real child PowerShell process, without building or invoking Azure/Fabric resources.

Source attribution: adapted the narrow engineering fix and regression tests from Hasan Abo-Shally's #3701, specifically commit 0c8bc64a3bf5e80928bbcb9b904a9aa777acba21. Original-author and Copilot co-author trailers are preserved in this PR's single commit. The Get Item implementation and the author's fork branch are not included or modified.

No tools are added or changed. No other validators, runtime/authentication code, dependencies, project files, provisioning, existing tool PR refs, or native stack metadata are changed. Main was rechecked at d4df988aae3ba1de008efe10f664f12817bdcc24; searches found no separate equivalent engineering PR before publication.

GitHub issue number?

N/A — engineering prerequisite extracted for the approved Fabric draft reorganization. Related prior art: #3701.

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

The release changelog and MCP-tool-specific checklist items are not applicable to this internal engineering-validation-only change. No product release behavior, tool descriptions, or live resource operations change.

Validation

PowerShell 7.6.6, isolated Pester 5.7.1, and the existing .NET SDK 10.0.401; no global.json or machine-wide tool configuration changes.

  • Invoke-Pester -Path .\eng\scripts\Test-ToolSelectionPrompts.Tests.ps1 -Output Detailed -CI — passed, 5/5. Before the production fix, the same suite passed 4/5 and failed specifically on valid stdout plus stderr with a ConvertFrom-Json error.
  • Full Test-ToolSelectionPrompts.ps1 -SkipServerBuild execution against a local native stub, using isolated prompt/build metadata — 7/7 scenarios passed. In addition to the stream cases, empty stdout remained a skip/failure, and native exit 7 retained its warning/skip path without attempting JSON parsing. This is script-level fixture evidence, not a full server test; the original generated build metadata was restored afterward.
  • dotnet build .\servers\Fabric.Mcp.Server\src\Fabric.Mcp.Server.csproj --no-restore --nologo --verbosity quiet — passed, 0 warnings and 0 errors after the normal build script restored existing dependencies. The first no-restore attempt reported the expected missing project.assets.json in the fresh worktree.
  • .\eng\scripts\Build-Local.ps1 -ServerName Fabric.Mcp.Server -VerifyNpx — not fully passed. The real trimmed Fabric publish and local npm packaging succeeded, but the existing clear-npx-cache helper failed because npm config get cache reports that the cache option is protected. No cache-helper, npm, or configuration workaround is included in this PR.
  • npx -y '.\.work\packages_npm\Fabric.Mcp.Server\wrapper\microsoft-fabric-mcp-1.5.0-alpha.12345.tgz' tools list --name-only — passed independently, returning status 200 and 48 tool names while retaining the real startup stderr diagnostic. Used a session-local npm cache and disabled telemetry; no Fabric resource commands were invoked.
  • .\eng\common\spelling\Invoke-Cspell.ps1 -FileList @('.\eng\scripts\Test-ToolSelectionPrompts.ps1', '.\eng\scripts\Test-ToolSelectionPrompts.Tests.ps1') with a session-local -PackageInstallCache — passed, 2 files checked, 0 issues.
  • PowerShell parsing of both changed scripts and git diff --check — passed.

Broader Azure builds, full solution tests, ToolDescriptionEvaluator, live Fabric/Azure calls, deployments, and credential changes were not performed. Hosted CI and owner review remain outstanding.

Ownership

Both changed files match /eng/ in CODEOWNERS: microsoft/azure-mcp, microsoft/azure-sdk-eng, and microsoft/fabric-mcp. This draft is intentionally independently reviewable by Azure MCP/EngSys before the Fabric foundation and tool layers are stacked above it.

Invoking Livetests

Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.

Read the tool catalog only from stdout while leaving stderr diagnostics visible. Add focused native-process Pester coverage for valid, malformed, and contaminated stdout without changing exit-code handling.

Adapted the engineering fix and regression tests from Hasan Abo-Shally's #3701 (commit 0c8bc64). No Fabric tool implementation is included.

Co-authored-by: Hasan Abo-Shally <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@AmosHersch
Amos Hersch (AmosHersch) marked this pull request as ready for review October 6, 2026 07:32
Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:32

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.

Copilot review overview

🟢 Approval recommended

The focused implementation matches its documented contract and has comprehensive regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Separates tool-catalog stderr diagnostics from stdout JSON parsing, preventing native startup logs from breaking prompt validation.

Changes:

  • Parse only stdout while keeping stderr visible.
  • Add five focused Pester regression tests.
  • Document the stream-handling contract.
File Description
eng/​scripts/​Test-ToolSelectionPrompts.ps1 Separates stderr from catalog JSON.
eng/​scripts/​Test-ToolSelectionPrompts.Tests.ps1 Tests valid and malformed stream scenarios.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AmosHersch
Amos Hersch (AmosHersch) merged commit aab35e1 into main Oct 6, 2026
26 of 36 checks passed
@AmosHersch
Amos Hersch (AmosHersch) deleted the amoshersch-tool-catalog-stream-fix branch October 6, 2026 08:33
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