# edit_file

Make line-based edits to a text file. Each edit replaces exact line sequences with new content. Returns a git-style diff showing the changes made. Only works within allowed directories.

Agent View of the PolicyLayer registry record for `edit_file`. HTML page: https://policylayer.com/tools/filesystem/edit-file

## Facts

- Tool: `edit_file`
- Server: Filesystem (`@modelcontextprotocol/server-filesystem`) — https://policylayer.com/tools/filesystem.md
- Install: `npx -y @modelcontextprotocol/server-filesystem`
- Homepage: https://github.com/modelcontextprotocol/server-filesystem
- Risk category: Write (Medium risk)
- Registry record: grade D, identity verified
- Server rate-limited: no
- Parameters: 3 (2 required)
- Recommended policy verdict: Rate-limited

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `path` | string | yes |  |
| `edits` | array | yes |  |
| `dryRun` | boolean | no | Preview changes using git-style diff format |

Parameters from the server's own tool schema.

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "edit_file",
    "arguments": {
      "path": "<path>",
      "edits": []
    }
  }
}
```

## Why edit_file is rated Medium

The tool creates or modifies file content reversibly through line-based edits, fitting the Write category. Severity is high because uncontrolled file editing could corrupt critical application configs, source code, or system files, though the constraint to 'allowed directories' mitigates blast radius compared to unrestricted filesystem access.

From the tool's own definition: "Tool description states it 'Make[s] line-based edits to a text file' and 'replaces exact line sequences with new content,' indicating data modification capabilities."

Risk signals: Accepts file system path (path)

## Use case

AI agents use edit_file to create or update resources in Filesystem, usually the action step of a workflow, after the agent has gathered context. Every call changes real data in your Filesystem environment.

## Recommended policy (PolicyLayer)

Verdict: **Rate-limited**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Filesystem:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "edit_file": {
      "limits": [
        {
          "counter": "edit_file_rate",
          "window": "minute",
          "max": 30,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## Other tools on Filesystem (13)

- `directory_tree` — Read — https://policylayer.com/tools/filesystem/directory-tree.md
- `get_file_info` — Read — https://policylayer.com/tools/filesystem/get-file-info.md
- `list_allowed_directories` — Read — https://policylayer.com/tools/filesystem/list-allowed-directories.md
- `list_directory` — Read — https://policylayer.com/tools/filesystem/list-directory.md
- `list_directory_with_sizes` — Read — https://policylayer.com/tools/filesystem/list-directory-with-sizes.md
- `read_file` — Read — https://policylayer.com/tools/filesystem/read-file.md
- `read_media_file` — Read — https://policylayer.com/tools/filesystem/read-media-file.md
- `read_multiple_files` — Read — https://policylayer.com/tools/filesystem/read-multiple-files.md
- `read_text_file` — Read — https://policylayer.com/tools/filesystem/read-text-file.md
- `search_files` — Read — https://policylayer.com/tools/filesystem/search-files.md
- `create_directory` — Write — https://policylayer.com/tools/filesystem/create-directory.md
- `move_file` — Write — https://policylayer.com/tools/filesystem/move-file.md
- `write_file` — Write — https://policylayer.com/tools/filesystem/write-file.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=filesystem · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/filesystem
