Skip to content

fix(mcp): support recursive directory deletion in forget tool#1935

Merged
ZaynJarvis merged 1 commit intovolcengine:mainfrom
t0saki:fix/mcp-forget-recursive
May 9, 2026
Merged

fix(mcp): support recursive directory deletion in forget tool#1935
ZaynJarvis merged 1 commit intovolcengine:mainfrom
t0saki:fix/mcp-forget-recursive

Conversation

@t0saki
Copy link
Copy Markdown
Contributor

@t0saki t0saki commented May 9, 2026

Description

The MCP forget tool only forwarded uri to service.fs.rm, never exposing or forwarding a recursive flag. The underlying VikingFS.rm raises FailedPreconditionError("Cannot remove directory without --recursive: ...") whenever the target is a directory, so any directory URI passed to forget failed — contradicting the documented behavior ("Delete any viking:// URI") and diverging from the REST DELETE /api/v1/fs?recursive=... endpoint and the ov rm CLI.

Related Issue

Fixes #1928

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Documentation update
  • Test update

Changes Made

  • openviking/server/mcp_endpoint.py: add an optional recursive: bool = False parameter to forget and forward it to service.fs.rm. The docstring only gains one short sentence about the new flag to keep the MCP tool description token cost minimal.
  • tests/server/test_mcp_endpoint.py: add test_forget_directory_without_recursive_fails (expects FailedPreconditionError) and test_forget_directory_with_recursive_succeeds.
  • docs/zh/guides/06-mcp-integration.md and docs/en/guides/06-mcp-integration.md: list the optional recursive parameter for forget in the MCP tool table and note that directory deletion requires recursive=true.

The default stays False, matching the REST API and the ov rm CLI, so an agent cannot accidentally wipe a directory tree without an explicit user request.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

pytest tests/server/test_mcp_endpoint.py -x -q -> 32 passed.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

The MCP `forget` tool only forwarded `uri` to `fs.rm` and never set
`recursive`, so any directory URI hit a `FailedPreconditionError` from
`VikingFS.rm`. Docs and the REST DELETE endpoint already advertised
directory deletion, leaving MCP clients without an equivalent.

Add an optional `recursive` parameter to the MCP tool (default False to
preserve fail-closed behavior on accidental tree deletes), update the
zh/en MCP integration tables, and cover both directory paths in tests.

Fixes volcengine#1928
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1928 - Partially compliant

Compliant requirements:

  • Add a recursive parameter to MCP forget tool with default False
  • Pass recursive to underlying fs.rm call
  • Add tests for directory deletion (with and without recursive)
  • Update documentation to mention the new parameter

Non-compliant requirements:

Requires further human verification:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 95
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@ZaynJarvis ZaynJarvis merged commit 0f5a569 into volcengine:main May 9, 2026
9 of 11 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project May 9, 2026
@t0saki t0saki review requested due to automatic review settings May 9, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: MCP forget 工具无法删除目录,文档描述与实际行为不一致

2 participants