## Summary
Bumps the MCP C# SDK dependency from 1.1.0 to 2.1.0 across all 9
projects and aligns the implementation with the 2.x surface and the
2026-07-28 spec — not just a version bump.
### Compile fixes
- Removed the gateway's `Capabilities.Tasks = null` suppression and its
test: the experimental Tasks API was removed from SDK core in 2.0 (moved
to a separate, wire-incompatible `ModelContextProtocol.Extensions.Tasks`
package).
- Added `ResolveInputRequestsAsync` (new abstract MRTR member on
`McpClient`) overrides to the test doubles. MRTR forwarding is
deliberately out of scope for this PR; the gateway's server reports
`IsMrtrSupported == false`.
- Deleted all `MCPEXP001` pragmas — `ServerCapabilities.Extensions`
(which carries `io.modelcontextprotocol/interceptors`) is stable in 2.x.
`MCPEXP002` subclassing pragmas are kept.
### Spec deprecations (SEP-2577 / SEP-2575)
- The gateway intentionally keeps proxying `logging/setLevel` and
`resources/subscribe` for down-level clients/backends, with targeted
`MCP9005` suppressions.
- On negotiated `2026-07-28` connections the SDK rejects these methods
at the session layer (replaced by per-request `_meta` log levels and
`subscriptions/listen`), so the affected tests now pin `protocolVersion:
"2025-06-18"` through a new fixture parameter — making them genuine
down-level-compatibility tests.
### Defensive hardening
- `Tool.inputSchema` is required and validated on deserialization in
2.x. The gateway's `ListToolsHandler` now fetches the backend
`tools/list` result as raw JSON and runs
`GatewayProxyConfigurator.EnsureToolInputSchemas` before and after the
interceptor chain, coercing missing/invalid schemas to the spec-default
`{"type":"object"}` so down-level backends and schema-stripping
interceptors can't fail the request.
### Tests & docs
- New tests: end-to-end schema-stripping coercion,
`EnsureToolInputSchemas` unit cases, and `2026-07-28` protocol-version
negotiation through the gateway (implicitly exercising
`server/discover`).
- `CLAUDE.md` gains an "SDK 2.x / spec 2026-07-28 notes" section;
`ARCHITECTURE_PHASES.md` no longer lists `Tasks` as a mirrored
capability.
## Test plan
- [x] `dotnet build` — 0 errors, 0 warnings (library, tests, all 7
samples)
- [x] `dotnet test` — 105/105 passing (was 98: −1 removed Tasks test, +8
new)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Ola Hungerford <olahungerford@gmail.com>
6.7 KiB
Architecture Phases
This document captures the phased structural changes planned for the C# MCP interceptors SDK so we can reference them during implementation.
Product Rule
The package should expose two distinct surfaces:
WithInterceptors(...)/ interceptor server: pure SEP surfaceMcpInterceptorGateway: transparent proxy by default- Gateway SEP passthrough: opt-in advanced mode
- Shared chain execution/runtime: reused by both surfaces
This lets the package support both:
- SEP-aware clients that explicitly use
interceptors/listandinterceptor/invoke(chain execution is SDK-side orchestration over those two) - Transparent infrastructure deployments where clients do not need any code changes
Phase 1: Split Gateway Modes
Goal: make the gateway's public behavior explicit.
Changes:
- Add
ExposeInterceptorProtocoltoMcpInterceptorGatewayOptions, defaulting tofalse - In transparent mode, do not advertise interceptor extension capability
- In transparent mode, do not expose
interceptors/listorinterceptor/invoke - In opt-in SEP mode, preserve the current passthrough behavior
Expected result:
- Default gateway looks like a backend proxy, not a backend-plus-admin endpoint
- Advanced users can still enable interceptor protocol passthrough intentionally
Acceptance criteria:
- Transparent mode does not advertise interceptor capability
- Transparent mode does not handle
interceptor/*requests - SEP mode preserves current passthrough behavior and tests
Phase 2: Make Capability Mirroring Truly Transparent
Goal: align the gateway's advertised contract with the backend server more faithfully.
Changes:
- Extract capability composition into a dedicated internal component or helper
- Start from the backend
ServerCapabilitiesrather than hand-mirroring only selected properties - Mirror standard and experimental capability surfaces, including
ExperimentalandExtensionswhere present - Overlay interceptor capability only when
ExposeInterceptorProtocol = true
Expected result:
- The gateway remains aligned with the core SDK as new capabilities are added
- The gateway can honestly describe itself as transparent by default
Acceptance criteria:
- Transparent mode mirrors backend capabilities broadly
- Interceptor capability is only present in SEP mode
- Existing proxy behavior remains intact for supported primitives
Phase 3: Separate Proxy Core from SEP Bridge
Goal: separate transparent proxy concerns from SEP passthrough concerns.
Changes:
- Extract the built-in MCP proxying logic into a dedicated internal component
- Extract interceptor protocol passthrough into a dedicated internal bridge component
- Keep
InterceptorChainRunnerand related chain semantics shared - Centralize interceptor extension capability key handling behind one internal constant/provider
Current implementation note:
- Transparent proxy wiring lives in
GatewayProxyConfigurator - SEP bridge wiring lives in
GatewayInterceptorProtocolBridge - The extension capability key is centralized in
InterceptorProtocolConstants
Expected result:
- Transparent proxy and SEP bridge can evolve independently
- The gateway type becomes a coordinator rather than a monolith
Acceptance criteria:
- Proxy wiring can be enabled without SEP bridge wiring
- SEP bridge can be enabled or disabled explicitly
- Internal tests can target the components independently
Phase 4: Improve DI and Runtime Lifecycle Shape
Goal: align the builder path more closely with the core C# SDK's composition model.
Changes:
- Keep the current
WithInterceptorGateway(options)overload for convenience - Add a DI-native overload based on a factory or service-provider callback
- Refactor notification forwarding into an internal connection-bound forwarder abstraction
- Treat transport session identifiers as an implementation detail, not a public concept
Expected result:
- The builder path stays declarative and SDK-native
- Runtime ownership of backend/interceptor connections becomes easier to evolve
- The implementation remains compatible with current session-bearing transports without depending on sessions semantically
Acceptance criteria:
- Existing convenience builder API continues to work
- A service-provider-based configuration path exists
- Notification forwarding logic is isolated from proxy handler registration
Current implementation note:
- Builder DI now supports both direct options and
Func<IServiceProvider, McpInterceptorGatewayOptions> - Connection-bound forwarding registration lives in
GatewayConnectionForwardingRegistrar - Transport session identifiers are only used as an internal deduplication mechanism where available
Phase 5: Follow-Up Cleanup
Goal: tighten API roles after the bigger structural changes are done.
Changes:
- Keep extension methods as the primary low-level SEP client API
- Keep
InterceptingMcpClientas a convenience/orchestration layer rather than the canonical abstraction - Consider clarifying or making explicit wrapped-client disposal ownership
- Consolidate any duplicated transparent interception flow that remains after Phases 1-4
Expected result:
- Public API roles are clearer
- Future maintenance burden is lower
This phase is intentionally lower priority than Phases 1-4.
Future Feature: External SEP-Exposing Servers
This comes after the phase work above.
Goal: allow transparent gateways to source interceptors from external SEP servers rather than only from in-process/directly-provided clients.
Possible outcomes:
- Configuration-driven gateways (for example
mcp-interceptors.json) - Auth-aware or per-user interceptor selection
- Custom MCP middleware built on top of the extension's primitives
Likely direction:
- Introduce an interceptor client/provider abstraction in addition to direct
InterceptorClients - Support static, per-request, or per-identity interceptor resolution
- Keep chain semantics unchanged regardless of interceptor source
Current implementation note:
McpInterceptorGateway.CreateAsync(...)now supports static external interceptor connections viaMcpInterceptorServerConnectionOptions- Those connections use the same transport-driven pattern as
McpClient.CreateAsync(...) - Dynamic per-request interceptor resolution is now supported for the transparent proxy path via
InterceptorServerConnectionResolver - SEP passthrough still requires statically configured interceptor clients
Open Design Notes
- The interceptor extension capability key should stay aligned with the SEP for now
- If the SEP changes to a reverse-domain extension identifier, we should centralize the key and support a transition path
- Transparent mode should be the default because it matches the expected operational use of the gateway