add_bookshelf
Create a new bookshelf in your Micro.blog book collection to organize books by categories, genres, or reading goals.
Instructions
Add a new bookshelf.
Args: name: The name of the new bookshelf
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- dxt-extension/server/index.js:67-77 (handler)Core handler in MicroBooksClient that validates the bookshelf name and makes a POST request to the Micro.blog API to create a new bookshelf.async addBookshelf(name) { if (!name || typeof name !== 'string' || name.trim().length === 0) { throw new Error("Bookshelf name is required and must be a non-empty string"); } await this.makeRequest("/books/bookshelves", { method: "POST", body: new URLSearchParams({ name: name.trim() }), }); return { success: true, message: `Bookshelf '${name.trim()}' created successfully` };
- Input schema for the add_bookshelf tool, defining the required 'name' parameter as a non-empty string.name: "add_bookshelf", description: "Create a new bookshelf", inputSchema: { type: "object", properties: { name: { type: "string", description: "The name of the new bookshelf", minLength: 1, }, }, required: ["name"], },
- dxt-extension/server/index.js:492-502 (registration)Tool call dispatcher case that handles 'add_bookshelf' requests by calling the client handler and formatting the response.case "add_bookshelf": { const { name } = args; const result = await client.addBookshelf(name); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], };
- micro_mcp_server/server.py:47-56 (handler)Helper method in MicroBooksClient that performs the API POST to create a bookshelf (used by tool handler).async def add_bookshelf(self, name: str) -> dict: """Add a new bookshelf.""" async with httpx.AsyncClient() as client: response = await client.post( urljoin(BASE_URL, "/books/bookshelves"), headers=self.headers, data={"name": name}, ) response.raise_for_status() return {"success": True, "message": f"Bookshelf '{name}' created successfully"}
- micro_mcp_server/server.py:195-206 (handler)MCP tool handler and registration via @mcp.tool() decorator; calls client method and returns JSON response.async def add_bookshelf(name: str) -> str: """Add a new bookshelf. Args: name: The name of the new bookshelf """ try: result = await client.add_bookshelf(name) return json.dumps(result, indent=2) except Exception: logger.exception("Failed to add bookshelf") raise