Skip to main content
Glama
7robots

Micro.blog Books MCP Server

by 7robots

get_bookshelf_books

Retrieve books from a specific Micro.blog bookshelf by providing the bookshelf ID to access your organized book collection.

Instructions

Get books in a specific bookshelf.

Args: bookshelf_id: The ID of the bookshelf to get books from

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bookshelf_idYes

Implementation Reference

  • MCP tool handler for get_bookshelf_books: calls the MicroBooksClient method and returns JSON stringified result with docstring defining input schema.
    @mcp.tool()
    async def get_bookshelf_books(bookshelf_id: int) -> str:
        """Get books in a specific bookshelf.
        
        Args:
            bookshelf_id: The ID of the bookshelf to get books from
        """
        try:
            result = await client.get_bookshelf_books(bookshelf_id)
            return json.dumps(result, indent=2)
        except Exception:
            logger.exception("Failed to get bookshelf books")
            raise
  • Helper method in MicroBooksClient that performs HTTP GET request to Micro.blog API to fetch books from a specific bookshelf.
    async def get_bookshelf_books(self, bookshelf_id: int) -> dict:
        """Get books in a specific bookshelf."""
        async with httpx.AsyncClient() as client:
            response = await client.get(
                urljoin(BASE_URL, f"/books/bookshelves/{bookshelf_id}"),
                headers=self.headers,
            )
            response.raise_for_status()
            return response.json()
  • Handler case in CallToolRequestSchema switch for get_bookshelf_books: extracts bookshelf_id, calls client method, returns formatted text content.
    case "get_bookshelf_books": {
      const { bookshelf_id } = args;
      const result = await client.getBookshelfBooks(bookshelf_id);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Tool schema definition including name, description, and inputSchema specifying bookshelf_id as required positive integer.
      name: "get_bookshelf_books",
      description: "Get books in a specific bookshelf",
      inputSchema: {
        type: "object",
        properties: {
          bookshelf_id: {
            type: "integer",
            description: "The ID of the bookshelf to get books from",
            minimum: 1,
          },
        },
        required: ["bookshelf_id"],
      },
    },
  • Helper method in MicroBooksClient that validates bookshelfId and makes HTTP request to fetch books from the bookshelf.
    async getBookshelfBooks(bookshelfId) {
      if (!Number.isInteger(bookshelfId) || bookshelfId <= 0) {
        throw new Error("Bookshelf ID must be a positive integer");
      }
      return await this.makeRequest(`/books/bookshelves/${bookshelfId}`);
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/7robots/micro-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server