Repository navigation
[1.2] Restrict MCP filesystem tools and confirm file transfers - #306
Merged
Mike Krüger (mkrueger) merged 6 commits intoNov 24, 2026
Merged
Mike Krüger (mkrueger) merged 6 commits into
Mike Krüger (mkrueger) merged 6 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit bab00db)
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
(cherry picked from commit 05e42db)
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the backport requiring user confirmation for filesystem reads.
No open issues 🎉
What changed in this PR
Backports #305 to rel/1.2, requiring explicit user approval before MCP clients can list local files with dir or read them with cat. Interactive shell behavior and Cosmos DB navigation remain unchanged.
Changes:
- Makes filesystem reads confirmable while preserving their read-only annotations.
- Binds approval to the exact command, working directory, and shell state; fixes boolean option formatting.
- Updates help and documentation and adds confirmation, replay-protection, and HTTP regression tests.
| File | Description |
|---|---|
docs/mcp.md |
Documents filesystem confirmation requirements and approval scope. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Mcp/ToolOperations.cs |
Gates filesystem reads, binds approval context, and formats boolean options. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Mcp/McpAnnotationAttribute.cs |
Clarifies that confirmation also applies to non-destructive commands. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Mcp/ConfirmationRequestState.cs |
Generalizes the confirmation-state documentation. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/HelpCommand.cs |
Explains filesystem confirmation in command help. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/DirCommand.cs |
Marks directory listing as restricted and confirmable. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/CatCommand.cs |
Marks file reading as restricted and confirmable. |
CosmosDBShell.Tests/ToolOperationsTests.cs |
Checks filesystem tool annotations and help text. |
CosmosDBShell.Tests/ToolOperationsCallToolTests.cs |
Covers approval gating, directory binding, replay rejection, and boolean formatting. |
CosmosDBShell.Tests/McpConfirmationTests.cs |
Tests filesystem approval and refusal over HTTP. |
Review effort: Balanced
(cherry picked from commit 4e022ca)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid the rolling preview regression that returns HTTP 500 instead of 409 for duplicate creates. Keep all emulator assertions enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
deleted the
dev/mkrueger/backport/1.2-confirm-mcp-filesystem-reads
branch
November 24, 2026 09:03
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
Backport of #305 to
rel/1.2, including the updated MCP filesystem policy. The policy changes and tests are cherry-picked without changes.cat,dir, andjqserver-side for MCP, even for clients with confirmation support. Interactive shell use remains available.importandexportexecute, including import dry runs and exports withforce. Clients without confirmation support fail closed.Approval is single-use, expires, and is bound to the exact command, local working directory, and shell state. Changed context requires a new confirmation. Interactive behavior and Cosmos DB navigation/listing (
cdandls) are unchanged.These restrictions are not a filesystem sandbox: other commands, including
bulkfile inputs and theme operations, can still access local files. Use only trusted MCP clients.Validation
rel/1.2.CI emulator stability
The rolling Linux preview image changed after the previous passing run and began returning HTTP 500 instead of the expected HTTP 409 for duplicate creates (
PostgresError(SqlState(E24000))). CI now pins the exact image digest from passing run 44800367029. All test assertions remain enabled; no emulator failures are ignored. The same pin is applied in both #305 and #306.