load_last_book_project
Load the last book project by reading the stored file, allowing writers to resume their work exactly where they left off.
Instructions
Load the last successfully opened project from ~/.storywright/last_project.json if valid.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/storywright_mcp/app.py:48-53 (handler)The MCP tool handler for 'load_last_book_project'. It loads the last project path from session persistence, then delegates to workflow.load_book_project().
async def load_last_book_project() -> str: """Load the last successfully opened project from ~/.storywright/last_project.json if valid.""" p = load_last_project_path() if not p: return "No saved last project. Use load_book_project with a path." return workflow.load_book_project(str(p)) - src/storywright_mcp/app.py:47-53 (registration)The tool is registered using the @mcp.tool() decorator on the handler function in the FastMCP application.
@mcp.tool() async def load_last_book_project() -> str: """Load the last successfully opened project from ~/.storywright/last_project.json if valid.""" p = load_last_project_path() if not p: return "No saved last project. Use load_book_project with a path." return workflow.load_book_project(str(p)) - src/storywright_mcp/session.py:31-42 (helper)Helper function load_last_project_path() reads the last project path from ~/.storywright/last_project.json and validates it exists with a book_config.json.
def load_last_project_path() -> Path | None: p = state_file() if not p.exists(): return None try: data = json.loads(p.read_text(encoding="utf-8")) path = Path(data["path"]) if path.is_dir() and (path / "book_config.json").exists(): return path except (json.JSONDecodeError, KeyError, OSError): pass return None - The workflow function that actually loads a book project by calling bind_project() which sets the session and saves the last-project path.
def load_book_project(project_path: str) -> str: bind_project(Path(project_path)) proj, _ = require_project() return ( f"Loaded **{proj.name}** (`{proj.base_path}`) — " f"{len(proj.chapters)} chapters, {len(proj.characters)} characters." ) - src/storywright_mcp/session.py:60-66 (helper)The bind_project() helper that actually resolves the path, loads the project config, creates the session, and calls save_last_project().
def bind_project(path: Path) -> tuple[ProjectConfig, ContinuityLog]: """Resolve path, load config + continuity, attach to session.""" path = path.resolve() session.project = ProjectConfig.load(path) session.continuity = ContinuityLog.load(path) save_last_project(path) return session.project, session.continuity