Skip to content

[Fabric] Extract shared Core HTTP and capacity foundation - #3855

Merged
Amos Hersch (AmosHersch) merged 2 commits into
mainfrom
amoshersch-shared-fabric-foundation
Oct 6, 2026
Merged

Amos Hersch (AmosHersch) merged 2 commits into
mainfrom
amoshersch-shared-fabric-foundation

Conversation

@AmosHersch

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

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the no-new-tool shared Fabric prerequisite for the user-authorized reorganization of 11 existing drafts: #3846, #3852, #3841, #3842, #3843, #3853, #3851, #3849, #3848, #3847, and #3850. Their existing PR numbers are being preserved. The coordinator will rebase those layers sequentially and register the native stack; this PR does not modify their branches or stack metadata. Another author's #3701 remains outside this work.

Depends on #3854, not directly on main. This diff is one foundation commit, 21655d0f8af45619013675656caf4a179329e261, relative to parent/base 4cd80df719783ed6b83583bfc4dd7b20aacfa982 on amoshersch-tool-catalog-stream-fix. The inherited engineering fix is unchanged.

Inspected all 11 original source diffs and revalidated their pushed heads before publication. Extracts only demonstrated common plumbing:

  • The existing authenticated send path now has one private response-returning helper, with the existing buffered completion default. Create/search retain their legacy stream wrapper, authentication, response/default handling, and exact error behavior.
  • A Fabric-local validated Retry-After parser returns a typed value, not an error message or retry policy. A query-value encoder preserves existing percent escapes while encoding raw delimiters, invalid percent sequences, and raw + as data. Normal .NET URI canonicalization remains enabled.
  • One source-generated FabricCapacityMetadata contract with five required fields, open string values, and shared nonempty/nonblank validation. Get operations still need their requested-ID equality check. Workspace/item output models are deliberately not unified.
  • One asynchronous counting HTTP test double, focused helper/model tests, and direct create/search service regression tests. Existing tests are retained. The Core test README documents reuse. Changelog entry not applicable: internal refactor with no user-facing change. The changelog-only removal was verified as one file with three deletions; product builds/tests were not rerun.

No new tools, command hierarchy, REST framework, packages, project/configuration changes, configurable retries, authentication redesign, endpoint-following behavior, or engineering fixes. The combined Fabric catalog still contains 48 tools, with exactly core_create-item and core_search-catalog in Core.

The URI tests use actual HttpClient-constructed request URIs and the official continuation examples for capacities, workspaces, and items. %3D is not doubled to %253D; escaped reserved characters remain escaped; %41/%7e canonicalize normally to A/~. Response tokens are not rewritten, and metadata URLs are not followed.

GitHub issue number?

N/A — explicitly authorized prerequisite for reorganizing the existing Fabric drafts listed above; no new issue was requested or opened.

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 MCP-tool-specific and Azure-tool-specific items are not applicable to this no-new-tool foundation. Tool names, registrations, descriptions, options, and the service interface are unchanged. Only the internal Core test/developer README changed, not a package README. ToolDescriptionEvaluator is not run/pending for the later tool layers; no score is claimed here.

Validation performed in this foundation

.NET SDK 10.0.401. All resource interactions in the Core suite use offline HTTP/credential doubles. The host suite covers stdio and loopback HTTP discovery/startup, not live Fabric authentication.

Command Result
dotnet build '.\tools\Fabric.Mcp.Tools.Core\src\Fabric.Mcp.Tools.Core.csproj' --no-restore --nologo --verbosity quiet Passed; 0 warnings, 0 errors
dotnet build '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Fabric.Mcp.Tools.Core.Tests.csproj' --no-restore --nologo --verbosity quiet Passed; 0 warnings, 0 errors
dotnet test --project '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Fabric.Mcp.Tools.Core.Tests.csproj' --no-build --no-restore Passed; 102/102, none skipped
dotnet build '.\servers\Fabric.Mcp.Server\src\Fabric.Mcp.Server.csproj' --no-restore --nologo --verbosity quiet Passed; 0 warnings, 0 errors
dotnet build '.\servers\Fabric.Mcp.Server\tests\Fabric.Mcp.Server.Tests\Fabric.Mcp.Server.Tests.csproj' --nologo --verbosity quiet Passed; 0 warnings, 0 errors
dotnet test --project '.\servers\Fabric.Mcp.Server\tests\Fabric.Mcp.Server.Tests\Fabric.Mcp.Server.Tests.csproj' --no-build --no-restore Passed; 3/3, none skipped
& '.\servers\Fabric.Mcp.Server\src\bin\Debug\fabmcp.exe' 'tools' 'list' '--name-only' Passed; stdout parses as status-200 JSON, 48 combined tools, exactly the two existing Core names; startup stderr remains separate
git diff --cached --check before commit and git diff --check Passed

The initial no-restore build reported the expected missing project.assets.json in this new worktree. dotnet build '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Fabric.Mcp.Tools.Core.Tests.csproj' --nologo --verbosity quiet restored the existing dependencies and passed; no dependency manifests or SDK settings were changed. Existing Core/host AOT analyzers and the source-generated serialization/schema tests passed; a native publish was not run.

Changed-file formatting commands — both passed:

dotnet format '.\tools\Fabric.Mcp.Tools.Core\src\Fabric.Mcp.Tools.Core.csproj' --no-restore --verify-no-changes --include '.\tools\Fabric.Mcp.Tools.Core\src\AssemblyInfo.cs' '.\tools\Fabric.Mcp.Tools.Core\src\Models\CoreJsonContext.cs' '.\tools\Fabric.Mcp.Tools.Core\src\Models\FabricCapacityMetadata.cs' '.\tools\Fabric.Mcp.Tools.Core\src\Services\FabricCoreService.cs' '.\tools\Fabric.Mcp.Tools.Core\src\Services\FabricCoreHttpHelpers.cs' --verbosity quiet
dotnet format '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Fabric.Mcp.Tools.Core.Tests.csproj' --no-restore --verify-no-changes --include '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Services\FabricCoreServiceBaselineTests.cs' '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Services\FabricCoreHttpHelpersTests.cs' '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Models\FabricCapacityMetadataTests.cs' '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\TestSupport\FabricCoreHttpMessageHandler.cs' --verbosity quiet

Invoke-Cspell.ps1 — passed, 11 files checked, 0 issues, using this exact file scope and isolated session-local -PackageInstallCache/npm_config_cache locations (removed afterward):

.\eng\common\spelling\Invoke-Cspell.ps1 -FileList @(
    '.\tools\Fabric.Mcp.Tools.Core\src\AssemblyInfo.cs',
    '.\tools\Fabric.Mcp.Tools.Core\src\Models\CoreJsonContext.cs',
    '.\tools\Fabric.Mcp.Tools.Core\src\Models\FabricCapacityMetadata.cs',
    '.\tools\Fabric.Mcp.Tools.Core\src\Services\FabricCoreService.cs',
    '.\tools\Fabric.Mcp.Tools.Core\src\Services\FabricCoreHttpHelpers.cs',
    '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Services\FabricCoreServiceBaselineTests.cs',
    '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Services\FabricCoreHttpHelpersTests.cs',
    '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\Models\FabricCapacityMetadataTests.cs',
    '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\TestSupport\FabricCoreHttpMessageHandler.cs',
    '.\tools\Fabric.Mcp.Tools.Core\tests\Fabric.Mcp.Tools.Core.Tests\README.md',
    '.\servers\Fabric.Mcp.Server\changelog-entries\amoshersch-fabric-core-foundation.yaml'
)

No live Fabric calls, OBO, recorded/playback infrastructure, deployment, credential changes, full solution tests, or evaluator execution. Those omissions are explicitly accepted for this reorganization, not claimed as passing validation.

Inherited #3854 evidence — not rerun or changed here

The base PR separately records Pester 5/5, script-fixture 7/7, a successful trimmed Fabric publish/npm package, and independent packaged tool discovery. Its Build-Local.ps1 -VerifyNpx did not fully pass because the existing clear-npx-cache helper hit the environment's protected npm cache option. This foundation does not claim that inherited command passed, does not rerun it, and includes no workaround or other engineering change. There are no PowerShell, project-file, or npm-package changes in this diff.

Reuse contract for the dependent layers

In Fabric.Mcp.Tools.Core.Services:

// Private on FabricCoreService; caller owns the returned response.
private Task<HttpResponseMessage> SendFabricHttpRequestAsync(
    HttpMethod method, string url, string? jsonContent = null,
    Dictionary<string, string>? headers = null,
    HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead,
    CancellationToken cancellationToken = default);

// Internal static FabricCoreHttpHelpers; no status/message/retry policy.
internal static RetryConditionHeaderValue? GetRetryAfter(HttpResponseMessage response);
internal static string EncodeContinuationToken(string token);

Fabric.Mcp.Tools.Core.Models.FabricCapacityMetadata is a public sealed class with required, mutable properties ordered Guid Id, string DisplayName, string Sku, string Region, string State; it is registered once as CoreJsonContext.Default.FabricCapacityMetadata. Its internal static IsValid([NotNullWhen(true)] FabricCapacityMetadata? capacity) checks null/empty/blank values without restricting future string values.

Fabric.Mcp.Tools.Core.Tests.TestSupport.FabricCoreHttpMessageHandler(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> send) exposes int CallCount with interlocked increments/volatile reads. Capture request details in the callback; retain specialized body/cancellation doubles and every operation-specific assertion.

Existing layer Adaptation on top of this foundation
#3846 Get Capacity Reuse the DTO/context registration and IsValid plus requested-ID equality. Replace inline authentication/send with the common send using ResponseHeadersRead; use the shared parser while retaining FabricCapacityGetThrottledException. Rename its counting handler to the shared handler.
#3852 List Capacities Drop duplicate send/encoder/DTO additions. Use common send with ResponseHeadersRead, common encoding/header parsing, and IsValid for each entry. Keep page/result models and their independent unchanged continuation strings. Reuse the common handler.
#3841 Get Workspace Drop the duplicate send helper; preserve buffered completion and its own workspace whitelist/validation/throttling exception. Use the shared parser and replace StubHttpMessageHandler with the common handler.
#3842 List Workspaces Reuse the send with ResponseHeadersRead, common encoder/parser and common handler. Keep role normalization, workspace/tag models, response validation and messages local.
#3843 List Items Drop duplicate send/encoder helpers; keep its original buffered completion, item whitelist, folder/type validation and throttling exception. Use common encoder/parser and handler.
#3853 Create Workspace Reuse the send with ResponseHeadersRead; replace GetWorkspaceRetryAfter with the common parser. Keep creation status, Location handling and uncertain-mutation policy local. Replace its handler and map RequestCount assertions to CallCount.
#3851 Update Workspace Reuse buffered send and the parser; keep update-specific response fields, validation and WorkspaceUpdateThrottledException wording. Reuse the common handler.
#3849 Update Item Replace SendFabricApiRequestForResponseAsync with the common send, explicitly preserving ResponseHeadersRead. Keep its stricter integer-only GetUpdateRetryAfterSeconds contract unless an equivalent projection is separately proven; do not add HTTP-date behavior. Keep exceptions/uncertain outcomes and map the handler's RequestCount to CallCount.
#3848 Delete Item Reuse buffered send and common parser, preserving nullable-header fallback wording and status behavior. Replace its handler using callback capture for existing LastRequest assertions; keep all request/body checks.
#3847 Delete Workspace Reuse the send with ResponseHeadersRead and common parser; retain cancellation checks, status handling and deletion-specific outcomes. Reuse the common handler.
#3850 Assign Workspace to Capacity Replace inline authentication/send with the common send and ResponseHeadersRead; retain the 202-only contract, long nullable seconds output and date-ignored behavior. If using the parser, consume only its nonnegative Delta, never a formatted message or backend body. Map RequestCount to CallCount and capture LastRequest in the callback.

Keep the foundation's single stream wrapper/send helper, not one replacement per rebased layer. Use named cancellationToken: arguments with the new optional completion parameter. Leave API-returned continuation strings unchanged, preserve reserved escapes in requests, allow normal unreserved canonicalization, and never disable URI canonicalization or follow metadata URLs. Retain tool-specific error/status mappings and all meaningful tests.

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.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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 narrowly scoped foundation is documented, AOT-registered, and comprehensively regression-tested with no unresolved issues found.

Review effort: Balanced
Findings: None

What changed in this PR

Extracts reusable Fabric Core HTTP, pagination, throttling, capacity-model, and testing foundations without changing registered tools.

Changes:

  • Adds shared authenticated HTTP and URI/header helpers.
  • Adds source-generated capacity metadata and validation.
  • Adds focused regression tests, documentation, and changelog entry.
File Description
src/​AssemblyInfo.cs Exposes internals to Core tests.
src/​Models/​CoreJsonContext.cs Registers capacity metadata for source generation.
src/​Models/​FabricCapacityMetadata.cs Defines and validates shared capacity metadata.
src/​Services/​FabricCoreService.cs Extracts the response-returning HTTP sender.
src/​Services/​FabricCoreHttpHelpers.cs Adds retry-header parsing and token encoding.
tests/​.../​FabricCapacityMetadataTests.cs Tests serialization, schema, and validation.
tests/​.../​FabricCoreHttpHelpersTests.cs Tests retry parsing and URI encoding.
tests/​.../​FabricCoreServiceBaselineTests.cs Protects existing create/search behavior.
tests/​.../​FabricCoreHttpMessageHandler.cs Adds a thread-safe HTTP test double.
tests/​.../​README.md Documents shared test foundations.
changelog-entries/​amoshersch-fabric-core-foundation.yaml Records the internal refactoring.

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

@AmosHersch
Amos Hersch (AmosHersch) force-pushed the amoshersch-shared-fabric-foundation branch from 21655d0 to a67bf4a Compare October 6, 2026 08:34
@AmosHersch
Amos Hersch (AmosHersch) merged commit 867f562 into main Oct 6, 2026
20 of 21 checks passed
@AmosHersch
Amos Hersch (AmosHersch) deleted the amoshersch-shared-fabric-foundation branch October 6, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server-Fabric.Mcp Microsoft Fabric MCP Server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants