Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960---title: statesidebarTitle: state---
# `fastmcp.cli.deploy.state`
Versioned JSON state helpers for the FastMCP CLI.
## Functions
### `state_lock` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/deploy/state.py#L96" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonstate_lock(directory: Path) -> Iterator[None]```
Lock related CLI state changes across processes.
### `read_state` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/deploy/state.py#L145" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonread_state(path: Path, model: type[ModelT]) -> ModelT | None```
Read and validate a versioned JSON state file.
### `write_state` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/deploy/state.py#L169" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonwrite_state(path: Path, data: dict[str, Any]) -> None```
Write JSON through a restricted temporary file and atomic replacement.
### `remove_state` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/deploy/state.py#L221" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonremove_state(path: Path) -> None```
Remove a state file when it exists.
## Classes
### `StateFileError` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/deploy/state.py#L20" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
A CLI state file could not be read or written safely.