move_book
Relocate a book to a different bookshelf in your Micro.blog collection by specifying the book ID and target bookshelf ID.
Instructions
Move a book to a different bookshelf.
Args: book_id: The ID of the book to move bookshelf_id: The ID of the target bookshelf
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes | ||
| bookshelf_id | Yes |
Implementation Reference
- micro_mcp_server/server.py:247-260 (handler)Handler function for the 'move_book' MCP tool. Registers the tool via @mcp.tool() decorator and implements the logic by calling the MicroBooksClient.move_book method and returning JSON result.@mcp.tool() async def move_book(book_id: int, bookshelf_id: int) -> str: """Move a book to a different bookshelf. Args: book_id: The ID of the book to move bookshelf_id: The ID of the target bookshelf """ try: result = await client.move_book(book_id, bookshelf_id) return json.dumps(result, indent=2) except Exception: logger.exception("Failed to move book") raise
- micro_mcp_server/server.py:97-106 (helper)Helper method in MicroBooksClient that performs the actual HTTP POST request to Micro.blog API to assign/move a book to a bookshelf.async def move_book(self, book_id: int, bookshelf_id: int) -> dict: """Move a book to a different bookshelf.""" async with httpx.AsyncClient() as client: response = await client.post( urljoin(BASE_URL, f"/books/bookshelves/{bookshelf_id}/assign"), headers=self.headers, data={"book_id": str(book_id)}, ) response.raise_for_status() return {"success": True, "message": f"Book moved to bookshelf {bookshelf_id} successfully"}
- modal/modal_http_server.py:250-260 (handler)Handler function for the 'move_book' MCP tool in Modal deployment (identical logic).async def move_book(book_id: int, bookshelf_id: int) -> str: """Move a book to a different bookshelf. Args: book_id: The ID of the book to move bookshelf_id: The ID of the target bookshelf """ try: result = await client.move_book(book_id, bookshelf_id) return json.dumps(result, indent=2) except Exception:
- Handler function for the 'move_book' MCP tool in Python DXT extension version (identical logic).async def move_book(book_id: int, bookshelf_id: int) -> str: """Move a book to a different bookshelf. Args: book_id: The ID of the book to move bookshelf_id: The ID of the target bookshelf """ try: result = await client.move_book(book_id, bookshelf_id) return json.dumps(result, indent=2) except Exception: logger.exception("Failed to move book") raise
- Helper method in MicroBooksClient (identical across implementations) that executes the core API call to move the book.async def move_book(self, book_id: int, bookshelf_id: int) -> dict: """Move a book to a different bookshelf.""" async with httpx.AsyncClient() as client: response = await client.post( urljoin(BASE_URL, f"/books/bookshelves/{bookshelf_id}/assign"), headers=self.headers, data={"book_id": str(book_id)}, ) response.raise_for_status() return {"success": True, "message": f"Book moved to bookshelf {bookshelf_id} successfully"}