Skip to content

[1.2] Restrict MCP filesystem tools and confirm file transfers - #306

Merged
Mike Krüger (mkrueger) merged 6 commits into
rel/1.2from
dev/mkrueger/backport/1.2-confirm-mcp-filesystem-reads
Nov 24, 2026
Merged

Mike Krüger (mkrueger) merged 6 commits into
rel/1.2from
dev/mkrueger/backport/1.2-confirm-mcp-filesystem-reads

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Backport of #305 to rel/1.2, including the updated MCP filesystem policy. The policy changes and tests are cherry-picked without changes.

  • Block cat, dir, and jq server-side for MCP, even for clients with confirmation support. Interactive shell use remains available.
  • Require explicit user confirmation before MCP import and export execute, including import dry runs and exports with force. Clients without confirmation support fail closed.
  • Prompts explain local-file reads/uploads and local-file writes/overwrites, and show the account, navigation context, exact command, file paths, options, and working directory.

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 (cd and ls) are unchanged.

These restrictions are not a filesystem sandbox: other commands, including bulk file inputs and theme operations, can still access local files. Use only trusted MCP clients.

Validation

  • Application and test projects build successfully with zero warnings on rel/1.2.
  • All 180 focused MCP tests pass, including HTTP coverage for clients with current and 2025-11-25 protocol versions, hard-blocked commands, transfer approval/refusal, import dry runs, forced exports, working-directory binding, and replay rejection.
  • The same builds and 180 tests pass for Restrict MCP filesystem tools and confirm file transfers #305.

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit bab00db)
@github-code-quality

github-code-quality Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

rel/1.2 088cc6e dev/mkrueger/backpor... 386dc71 +/-
76% 75% -1%
View coverage of the 10 most impacted files.
File rel/1.2 088cc6e dev/mkrueger/backpor... 386dc71 +/-
D:\a\CosmosDBSh...atchExecutor.cs 68% 17% -51%
D:\a\CosmosDBSh...eItemCommand.cs 79% 60% -19%
D:\a\CosmosDBSh...\EditCommand.cs 60% 56% -4%
D:\a\CosmosDBSh...hell\Program.cs 85% 83% -2%
D:\a\CosmosDBSh...ucketCommand.cs 34% 32% -2%
D:\a\CosmosDBSh...ThemeCommand.cs 72% 71% -1%
D:\a\CosmosDBSh...placeCommand.cs 84% 83% -1%
D:\a\CosmosDBSh...QueryCommand.cs 52% 52% 0%
D:\a\CosmosDBSh...lInterpreter.cs 80% 80% 0%
D:\a\CosmosDBSh...elcomeScreen.cs 81% 96% +15%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 23, 2026 12:06 UTC

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.

🟢 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

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.

🟢 Approval recommended

No active review issues are recorded for the filesystem-read confirmation backport.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mkrueger Mike Krüger (mkrueger) changed the title [1.2] Require confirmation for MCP filesystem reads [1.2] Restrict MCP filesystem tools and confirm file transfers 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>
@mkrueger
Mike Krüger (mkrueger) merged commit 4e905d5 into rel/1.2 Nov 24, 2026
5 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/backport/1.2-confirm-mcp-filesystem-reads branch November 24, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants