Back to Fastmcp

state

docs/python-sdk/fastmcp-cli-deploy-state.mdx

4.0.01.6 KB
Original Source

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>

python
state_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>

python
read_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>

python
write_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>

python
remove_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.