# FilesystemClaudeMemoryMiddleware

> **Class** in `langchain_anthropic`

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

Filesystem-based memory tool middleware.

Provides Anthropic's memory tool using local filesystem for storage.
User handles persistence via volumes, git, or other mechanisms.

Enforces `/memories` prefix and injects Anthropic's recommended system
prompt.

## Signature

```python
FilesystemClaudeMemoryMiddleware(
    self,
    *,
    root_path: str,
    allowed_prefixes: list[str] | None = None,
    max_file_size_mb: int = 10,
    system_prompt: str = MEMORY_SYSTEM_PROMPT,
)
```

## Description

**Example:**

```python
from langchain.agents import create_agent
from langchain.agents.middleware import FilesystemMemoryToolMiddleware

agent = create_agent(
    model=model,
    tools=[],
    middleware=[FilesystemMemoryToolMiddleware(root_path="/workspace")],
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `root_path` | `str` | Yes | Root directory for file operations. |
| `allowed_prefixes` | `list[str] \| None` | No | Optional list of allowed virtual path prefixes.  Defaults to `['/memories']`. (default: `None`) |
| `max_file_size_mb` | `int` | No | Maximum file size in MB  Defaults to `10`. (default: `10`) |
| `system_prompt` | `str` | No | System prompt to inject.  Defaults to Anthropic's recommended memory prompt. (default: `MEMORY_SYSTEM_PROMPT`) |

## Extends

- `_FilesystemClaudeFileToolMiddleware`

## Constructors

```python
__init__(
    self,
    *,
    root_path: str,
    allowed_prefixes: list[str] | None = None,
    max_file_size_mb: int = 10,
    system_prompt: str = MEMORY_SYSTEM_PROMPT,
) -> None
```

| Name | Type |
|------|------|
| `root_path` | `str` |
| `allowed_prefixes` | `list[str] \| None` |
| `max_file_size_mb` | `int` |
| `system_prompt` | `str` |


---

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