Repository navigation
Restrict MCP filesystem tools and confirm file transfers - #305
Merged
Mike Krüger (mkrueger) merged 6 commits intoNov 24, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
requested review from
a team
and
a balanced review from Copilot
November 20, 2026 16:12
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The suggested fallback command can enable recursion despite recursive: false because boolean values are formatted separately from their flags; inline boolean formatting and true/false round-trip coverage are needed.
1 open issue
What changed in this PR
This PR extends the shell’s MCP confirmation mechanism to local filesystem reads through dir and cat, while preserving their read-only classification and interactive shell behavior.
Changes:
- Requires explicit approval for MCP filesystem reads and refuses clients without confirmation support.
- Binds filesystem approval to the command, working directory, and shell state.
- Updates help and documentation, with metadata, execution, retry, and HTTP confirmation tests.
| File | Description |
|---|---|
docs/mcp.md |
Documents filesystem approval requirements and context binding. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Mcp/ToolOperations.cs |
Adds filesystem confirmation prompts and working-directory checks. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Mcp/McpAnnotationAttribute.cs |
Broadens the confirmation property’s XML comment beyond destructive commands. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Mcp/ConfirmationRequestState.cs |
Generalizes the class summary to command confirmation. |
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 requiring MCP confirmation. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/CatCommand.cs |
Marks file reads as requiring MCP confirmation. |
CosmosDBShell.Tests/ToolOperationsTests.cs |
Checks filesystem tool annotations and help text. |
CosmosDBShell.Tests/ToolOperationsCallToolTests.cs |
Covers approval outcomes, directory binding, and replay rejection. |
CosmosDBShell.Tests/McpConfirmationTests.cs |
Adds HTTP approval and denial coverage for filesystem reads. |
Review effort: Balanced
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 4 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
added a commit
that referenced
this pull request
Nov 23, 2026
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)
added a commit
that referenced
this pull request
Nov 23, 2026
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>
Vsevolod Kukol (sevoku)
approved these changes
Nov 23, 2026
Mike Krüger (mkrueger)
deleted the
dev/mkrueger/confirm-mcp-filesystem-reads
branch
November 24, 2026 09:03
Mike Krüger (mkrueger)
added a commit
that referenced
this pull request
Nov 24, 2026
* Require confirmation for MCP filesystem reads Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit bab00db) * Preserve boolean options in MCP confirmation commands (cherry picked from commit 05e42db) * Prevent emulator startup updates from breaking PostgreSQL (cherry picked from commit 4e022ca) * Restrict MCP filesystem tools and confirm file transfers (#305) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix MCP confirmation context formatting Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Pin passing emulator image for integration tests (#305) 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
added a commit
that referenced
this pull request
Nov 24, 2026
Use the preview image verified by PR #305 and prevent startup package updates from replacing PostgreSQL modules. Keep all test profiles and assertions enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
cat,dir, andjqserver-side for MCP. These commands remain available in the interactive shell, but MCP clients cannot invoke them, even with confirmation support.importandexportexecute, including import dry runs and exports withforce. Clients without confirmation support are refused before execution.Confirmation safety
Approval is single-use, expires, and is bound to the exact command, local working directory, and shell state. Prompts show the account, navigation context, file paths, and options. A changed working directory or shell context requires a new confirmation. Interactive shell behavior and Cosmos DB navigation/listing (
cdandls) are unchanged.These command 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.2in [1.2] Restrict MCP filesystem tools and confirm file transfers #306; its builds and the same 180 tests also pass.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.