Skip to content

feat(filesystem): add append_file#2093

Closed
altrao wants to merge 2 commits intomodelcontextprotocol:mainfrom
altrao:append-file
Closed

feat(filesystem): add append_file#2093
altrao wants to merge 2 commits intomodelcontextprotocol:mainfrom
altrao:append-file

Conversation

@altrao
Copy link

@altrao altrao commented Jun 12, 2025

Description

Added append_file capability to filesystem server:

  • Appends content to existing files or creates new files

Server Details

  • Server: filesystem
  • Changes to: tools

Motivation and Context

Need to provide log-style file operations for LLM clients:

  • append_file enables incremental writes without full file rewrites

How Has This Been Tested?

Testing performed for append_file:

  1. Basic functionality:
    • Append to existing files
    • Append to new files (creates file)
  2. Security boundaries:
    • Works in allowed dir
    • Fails in not specified dir
  3. Edge cases:
    • Empty files
    • Large content appends
    • Empty append to new file (creates empty file)
    • Empty append to existing file (maintains empty state)
  4. Error handling:
    • Invalid paths
    • Permission issues

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

@olaservo olaservo added server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem enhancement New feature or request labels Jun 13, 2025
Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: original review below didn't account for conflicts.


Review: APPROVE

Clean implementation that follows existing codebase patterns.

Strengths

  • Proper Zod schema validation (AppendFileArgsSchema)
  • Uses validatePath() for security boundary enforcement
  • Correct use of fs.appendFile() with UTF-8 encoding
  • Documentation updated in README

Note for Maintainers

This PR is nearly identical to #1233 (by gloridea), which also adds append_file with the same implementation approach. Please choose one to merge and close the other to avoid duplication.

Both PRs are solid - the main difference is that #1233 includes a prompt enhancement for edit_file to clarify when to use append vs edit.


Reviewed with Claude Opus 4.5

@olaservo
Copy link
Member

Closing this PR — it has merge conflicts due to the major architecture refactoring (Nov 2025) and would need a full rewrite to use the current registerTool() API with outputSchema, structuredContent, and annotations.

The append_file feature is still wanted (tracked in issue #1208). PR #2816 covers the same functionality and is currently mergeable against main, so we'll focus review efforts there.

Thank you for the clean implementation — it validated the approach that #2816 builds on.

This comment was posted by Claude Code on behalf of @olaservo.

@olaservo olaservo closed this Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants