Skip to content

filesystem: edit_file's edits[].oldText schema says "must match exactly", contradicting its tool description #5688

Done

Description

@MicroMilo

Which server?

filesystem (@modelcontextprotocol/server-filesystem)

Server version

2.4.1 (npm)

How did you run the server?

npx (npm package)

Transport

stdio

Protocol era

Legacy (2025-11-25 or earlier)

MCP client and version

Custom Python JSON-RPC stdio client (mcpfuse test harness)

Operating system and runtime

macOS 26.3.2, Node v25.9.0

Server configuration

npx -y @modelcontextprotocol/server-filesystem@2.4.1 /tmp/fs-repro

Steps to reproduce

  1. Create /tmp/fs-repro/sample.txt containing indented lines:
    def f():
        x = 1
  2. Start the server with the configuration above and call tools/list.
  3. Inspect the edit_file tool entry:
    • description (src/filesystem/server.ts) states:

      oldText must match the file's text exactly, except that line endings (LF or CRLF) never matter and, when there is no exact match, a run of whole lines matches if each line is equal once leading and trailing whitespace is ignored (newText then takes the file's indentation).

    • inputSchema.properties.edits.items.properties.oldText.description (src/filesystem/server.ts:114) states:

      Text to search for - must match exactly

  4. Call edit_file with unindented oldText:
    {
      "path": "/tmp/fs-repro/sample.txt",
      "edits": [{ "oldText": "x = 1", "newText": "x = 2" }]
    }

Expected behavior

The parameter schema description for edits[].oldText should match the tool's top-level description and actual runtime matching behavior (CRLF-insensitive exact match, with whitespace-tolerant whole-line fallback and indentation preservation), rather than contradicting it with an unconditional "must match exactly".

Actual behavior

edits[].oldText still says "Text to search for - must match exactly" (left over when #5379 updated edit_file's top-level description), whereas runtime execution applies the whitespace-tolerant whole-line fallback and rewrites the indented line in /tmp/fs-repro/sample.txt ( x = 1 → x = 2). Clients or models relying on the parameter schema description receive conflicting instructions within the same tool definition.

Logs or error output

Tool call result (isError: false):
```diff
Index: /tmp/fs-repro/sample.txt
===================================================================
--- /tmp/fs-repro/sample.txt	original
+++ /tmp/fs-repro/sample.txt	modified
@@ -1,2 +1,2 @@
 def f():
-    x = 1
+    x = 2

### Already prototyped a fix?

Per `CONTRIBUTING.md` (issues-only policy), I am not opening a pull request. Related PR that updated the top-level `edit_file` description without updating `EditOperation.oldText`: #5379.

Suggested prompt to align the schema description with the tool description:

> In `src/filesystem/server.ts`, update `EditOperation`'s `oldText` field `.describe(...)` so it no longer contradicts `edit_file`'s top-level description. Replace `"Text to search for - must match exactly"` with wording consistent with `edit_file`'s description (e.g. `"Text to search for. Matches exactly (ignoring LF/CRLF), or falls back to whole-line matching ignoring leading and trailing whitespace; whitespace inside a line must match."`). Verify `tools/list` output and existing `edit_file` tests still pass.

### Before you submit

- [x] I searched existing issues and this is not a duplicate.
- [x] This is not a security vulnerability report (those go through the private advisory form).

Activity

  1. added
    bug
    server-filesystem
    on Nov 30, 2026
  2. cliffhall commented on Nov 30, 2026

    @cliffhall
    Member

    Triage: Priority Low (total 5)

    • Severity 2: the oldText parameter description contradicts the tool description, which can mislead a model; the tool itself behaves as its description says
    • Urgency 2: wanted eventually, nothing blocked on it
    • Bonuses: +1 bug label

    Board: Servers V2 (#43), Status Incoming, awaiting maintainer review (no milestone yet).

  3. added this to the v2.7.0 milestone on Nov 30, 2026
  4. self-assigned this
    on Nov 30, 2026
  5. cliffhall commented on Nov 30, 2026

    @cliffhall
    Member

    Fixed by #5704, merged to v2/main; ships in v2.7.0.

  6. added a commit that references this issue on Dec 5, 2026
    a2cf253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugserver-filesystemv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions