Skip to content

feat: add append_file tool to prevent errors caused by too long content#1233

Closed
gloridea wants to merge 1 commit intomodelcontextprotocol:mainfrom
gloridea:main
Closed

feat: add append_file tool to prevent errors caused by too long content#1233
gloridea wants to merge 1 commit intomodelcontextprotocol:mainfrom
gloridea:main

Conversation

@gloridea
Copy link

@gloridea gloridea commented Apr 3, 2025

Sometimes LLM generates long file contents that need to be generated in multiple consecutive responses.
However, the write_file tool supports write-at-once only. So the write_file call with long response not applied to file content, because it is not properly closed, and it makes repeating file write failure.

So I made the following changes:

  • added append_file tool, and its prompt
  • updated the edit_file prompt to help LLM understand when to use it better

Description

Server Details

  • Server: filesystem
  • Changes to: tools, prompts

Motivation and Context

I asked Calude Desktop to write a markdown file that contains a wide business research (total output was almost 24kB). While Claude Desktop trying to write the file, it failed repeatedly because Clauded encountered the output limit, so the write_file request is not closed successfuly.

How Has This Been Tested?

After I add this append_file, I ran filesystem mcp server locally again, restarted Claude Desktop, and asked to do the same operation, and Claude did it well by using new tools.

Breaking Changes

Not at all.

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 - no test code exists, so created temporal test codes but not committed the test codes.
  • 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 Apr 18, 2025
@olaservo olaservo mentioned this pull request Feb 3, 2026
12 tasks
@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.

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 contribution and the good motivation writeup — the use case of incremental writes for large content is exactly why we want this feature.

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