# file_tool

> **Function** in `langchain_anthropic`

📖 [View in docs](https://reference.langchain.com/python/langchain-anthropic/middleware/anthropic_tools/_FilesystemClaudeFileToolMiddleware/__init__/file_tool)

Execute file operations on filesystem.

## Signature

```python
file_tool(
    runtime: ToolRuntime,
    command: str,
    path: str,
    file_text: str | None = None,
    old_str: str | None = None,
    new_str: str | None = None,
    insert_line: int | None = None,
    new_path: str | None = None,
    view_range: list[int] | None = None,
) -> Command | str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `runtime` | `ToolRuntime` | Yes | Tool runtime providing `tool_call_id`. |
| `command` | `str` | Yes | Operation to perform. |
| `path` | `str` | Yes | File path to operate on. |
| `file_text` | `str \| None` | No | Full file content for create command. (default: `None`) |
| `old_str` | `str \| None` | No | String to replace for `str_replace` command. (default: `None`) |
| `new_str` | `str \| None` | No | Replacement string for `str_replace` command. (default: `None`) |
| `insert_line` | `int \| None` | No | Line number for insert command. (default: `None`) |
| `new_path` | `str \| None` | No | New path for rename command. (default: `None`) |
| `view_range` | `list[int] \| None` | No | Line range `[start, end]` for view command. (default: `None`) |

## Returns

`Command | str`

Command for message update or string result.

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/fb6ab993a73180538f6cca876b3c85d46c08845f/libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py#L691)