Add MCP client roots support and dynamic tool compatibility fallback#11
Merged
carldebilly merged 8 commits intomainfrom Mar 21, 2026
Merged
Add MCP client roots support and dynamic tool compatibility fallback#11carldebilly merged 8 commits intomainfrom
carldebilly merged 8 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two MCP-focused capabilities to Repl:
It also restructures the MCP documentation to better separate:
In addition, this PR aligns MCP-specific public APIs under the
Repl.Mcpnamespace.What changed
MCP client roots
Added a new MCP-only abstraction:
IMcpClientRootsMcpClientRootThis allows MCP handlers and module presence predicates to access client workspace roots when the connected client supports them.
The service also supports session-scoped fallback roots ("soft roots") for clients that do not implement native MCP roots.
Dynamic tool compatibility fallback
Added a new opt-in option:
DynamicToolCompatibilityModeReplMcpServerOptions.DynamicToolCompatibilityWhen
DiscoverAndCallShimis enabled, the server:discover_toolsandcall_toolon the firsttools/listnotifications/tools/list_changedtools/listThis is intended for applications with genuinely dynamic tool graphs, especially when targeting clients that ignore or mishandle
tools/list_changed.Session-aware MCP generation
The MCP server now builds tools, resources, and prompts dynamically per session, using the MCP session service provider. This allows session-scoped services such as
IMcpClientRootsto influence:MCP namespace alignment
Public MCP-specific APIs are now exposed from
Repl.Mcpinstead of the rootReplnamespace, including:IMcpClientRootsMcpClientRootDynamicToolCompatibilityModeInteractivityModeToolNamingSeparatorReplMcpServerOptionsMcpReplExtensionsThis keeps MCP concepts grouped under the package namespace instead of making MCP-only abstractions appear as core Repl primitives.
Documentation
The MCP docs were reorganized into:
docs/mcp-server.mdfor the main guide and basic troubleshootingdocs/mcp-advanced.mdfor advanced usage patternsdocs/mcp-internals.mdfor concepts and under-the-hood behaviordocs/mcp-transports.mdfor transport and HTTP hosting scenariosThe docs now also include:
Why
Some MCP scenarios require session-aware behavior:
This PR provides a structured way to support those cases without affecting the default behavior for static MCP servers.
Validation
Validated with:
dotnet build src/Repl.McpTests/Repl.McpTests.csproj --no-restore -p:NuGetAudit=falsedotnet test --project src/Repl.McpTests/Repl.McpTests.csproj --no-build --output Normal --no-progressResult:
109tests passedNotes