Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem - edit_file function missing despite being in the codebase #294

Open
yannisTr opened this issue Dec 10, 2024 · 14 comments
Open
Labels
bug Something isn't working

Comments

@yannisTr
Copy link

I've noticed a discrepancy between the documented features and actual implementation of the MCP filesystem server.

What's happening:

  • The source code on GitHub clearly shows edit_file function implementation
  • The feature is documented in the README

But:

  • The function is not available when trying to use it through Claude Desktop (MacOs)
  • Other basic functions (read_file, write_file, etc.) work perfectly
  • No error messages indicating why it's not available

Current config

{
    "mcpServers": {
      "filesystem": {
        "command": "npx",
        "args": [
          "-y",
          "@modelcontextprotocol/server-filesystem",  
          "/path/to/folder"
        ]
      },

Solutions tried

  • restart, empty cache, reinstall desktop app...
  • Global installation with npm: npm install -g @modelcontextprotocol/server-filesystem
  • Using package name directly: mcp-server-filesystem
  • Explicit latest version: @modelcontextprotocol/server-filesystem@latest
@yannisTr yannisTr added the bug Something isn't working label Dec 10, 2024
@heuperman
Copy link

This might be a bug in the MCP implementation of Claude Desktop. It appears to be an issue with the type of the edits argument, which is an array of objects.

  1. The inspector recognises the edit_file tool as expected.
  2. If you replace edits and use oldText and newText directly, the tool is recognised and works (but can only make a single edit at a time of course).

As far as I can tell an array of objects is a valid type for an argument in the protocol schema.

@yannisTr
Copy link
Author

yannisTr commented Dec 11, 2024 via email

@Aschent89
Copy link
Contributor

Aschent89 commented Dec 11, 2024

The issue is that the option isn't being listed as the app is considering that command to be invalid since you're using an array vs something like .string(). If you review all of the Schema definitions in index.ts, none of them except EditFileArgsSchema use an array.

@yannisTr
Copy link
Author

yannisTr commented Dec 11, 2024 via email

@heuperman
Copy link

@yannisTr what I meant was that although the edit_file tool does indeed not show up in Claude Desktop, it does show up when connecting the filesystem server to the inspector, so the issue is not with the server but with Claude Desktop.

Note that the read_multiple_files requires an array of strings as an arguments. This tool is working, so Claude Desktop can handle arrays, but not arrays containing objects it seems.

We can either wait for the Claude Desktop team to find out about this issue and fix it, or apply some workarounds. I can think of a few, but they're all quite hacky:

  1. Send a stringified JSON object: use an array of objects, but stringify it before calling the tool, then parse it back to JSON in the server
  2. If Claude Desktop can handle nested arrays, use those - [ [ 'old text 1', 'new text 1' ], [ 'old text 2', 'new text 2' ] ]
  3. Use a flat array of strings, with every second string being the replacement for the string before it. Horrible to read for humans but should be fine for a computer

@boorich
Copy link

boorich commented Dec 19, 2024

This function would be very useful indeed. The hacky ways described above would not really work in my case. I hope the Anthropic folks see this and provide a fix.

@alexmhoward3
Copy link

Ditto here - would love for a fix for this! Using write_file to make edits is risky and a waste of tokens!

@cbusillo
Copy link

Installing the version directly from GitHub does work. The npm version does not contain the edit_files function.

Screenshot 2024-12-24 at 11 55 12 AM
Screenshot 2024-12-24 at 11 56 49 AM

@alexmhoward3
Copy link

@cbusillo you absolute dreamboat! thank you!

@xRoyBatty
Copy link

@cbusillo you are the godsend, thank you!

@cbusillo
Copy link

@xRoyBatty funny story. I saw filesystem only had write_file so I made my own filesystem MCP. Then I saw in the readme it does have an edit_file, so I deleted mine and reinstalled. I spent time trying to figure out why the LLM REFUSED to use edit_file. Turns out, as you found out, the npm version didn't have edit_file. Lol. I felt dumb.

@xRoyBatty
Copy link

@cbusillo I think another problem has occured now. Whenever I tell claude to use edit_file the app crashes "Claude will eturn soon". It is listed in tools and all the other tools work fine.

@cbusillo
Copy link

That's odd. Just to confirm, it does work for me. Can you test it with something other than Claude, since I don't believe Claude has a per MCP log? I know LibreChat does. That may be helpful for troubleshooting.

@crimsonshot
Copy link

For anyone trying to get this working until implementation is streamlined, here are the below steps:
git clone https://github.com/modelcontextprotocol/servers.git
cd servers/src/filesystem (or whatever directory you have the filesystem source located)
npm install
npm run build
node dist/index.js /Users/crims/Desktop (or whatever directory you want to allow access to)
Then change your claude_desktop_config to use node as the command instead of npx and under args just have the directory to the index.js in the mcp filesystem folder and the folder you want it to have access to, ex:
"args": [
"/Users/crims/servers/src/filesystem/dist/index.js",
"/Users/crims/Desktop"
Restart Claude Desktop and you'll have access to the edit_file tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants