feat(mcp): add file delete tool#20
Merged
Merged
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
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.
Problem
AFS MCP clients had precise tools for reading files and making localized text edits, but they did not have a first-class way to delete an entire file, symlink, or empty directory from a workspace. That left agents without an explicit whole-path delete operation in both the local stdio MCP server and the hosted control-plane MCP server.
Delete handling also needs to preserve the existing workspace guarantees: root must not be removable, non-empty directories must be refused, edits should leave the workspace dirty until checkpointed, and hosted MCP mutations should write accurate changelog entries.
Proposed solution
Add a
file_deleteMCP tool to both local and hosted MCP surfaces. The tool uses the existing Redis-backed filesystemRmbehavior, so it inherits the established safety checks for root deletion and non-empty directories while supporting files, symlinks, and empty directories.The change also wires
file_deleteinto MCP profile gating as a write-capable tool, updates the MCP reference docs, and extends automated coverage for tool listing, profile access, file deletion, empty-directory deletion, root refusal, non-empty directory refusal, and hosted changelog behavior.During QA, hosted empty-directory deletion exposed a changelog issue: the mutation helper derived the operation from version snapshots, while directories are not versioned. The helper now derives delete operations from the before/after filesystem stats, so empty-directory deletion records
rmdirand file/symlink deletion recordsdelete.Validation
go test ./cmd/afs -run 'TestAFSMCP|TestMCP'go test ./internal/controlplane -run 'TestHostedMCP|TestMCPProfile'make testmake commandsgit diff --check origin/main...HEAD