Skip to main content
Glama

book

Retrieve books from Zenn.dev by specifying author username, topic name, order, page, and count. Simplifies fetching and organizing books from the Zenn platform.

Instructions

Fetch books from Zenn.dev

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of books per page. Default: 48
orderNoOrder of the books. Choose from latest or oldest. Default: latest
pageNoPage number of the books. Default: 1
topicnameNoTopic name of the book
usernameNoUsername of the book author

Implementation Reference

  • Handler function specific to the 'book' tool. It converts arguments to a Book model instance and calls fetch_books to retrieve data from Zenn API.
    async def handle_books(arguments: dict) -> dict: query = Book.from_arguments(arguments) return await fetch_books(query)
  • Pydantic model defining input parameters for the 'book' tool, including schema for Tool registration and methods for argument parsing and query param conversion.
    class Book(BaseModel): """Fetch books from Zenn.dev""" model_config = ConfigDict( validate_assignment=True, frozen=True, extra="forbid", ) username: Optional[str] = Field(default=None, description="Username of the book author") topicname: Optional[str] = Field(default=None, description="Topic name of the book") order: Optional[Order] = Field( default=Order.LATEST, description=f"Order of the books. Choose from {Order.LATEST.value} or {Order.OLDEST.value}. Default: {Order.LATEST.value}", ) page: Optional[int] = Field(default=1, description="Page number of the books. Default: 1") count: Optional[int] = Field(default=48, description="Number of books per page. Default: 48") @staticmethod def from_arguments(arguments: dict) -> "Book": return Book( username=arguments.get("username"), topicname=arguments.get("topicname"), order=Order.from_str(arguments.get("order", Order.LATEST.value)), page=arguments.get("page", 1), count=arguments.get("count", 48), ) def to_query_param(self) -> dict: param = {} if self.username: param["username"] = self.username.lower() if self.topicname: param["topicname"] = self.topicname.lower() if self.order: param["order"] = self.order.value if self.page: param["page"] = self.page if self.count: param["count"] = self.count return param @staticmethod def tool() -> Tool: return Tool( name=ZennTool.BOOK.value, description="Fetch books from Zenn.dev", inputSchema={ "type": "object", "properties": { "username": {"type": "string", "description": Book.model_fields["username"].description}, "topicname": {"type": "string", "description": Book.model_fields["topicname"].description}, "order": { "type": "string", "description": Book.model_fields["order"].description, "enum": [Order.LATEST.value, Order.OLDEST.value], }, "page": {"type": "integer", "description": Book.model_fields["page"].description}, "count": {"type": "integer", "description": Book.model_fields["count"].description}, }, "required": [], }, )
  • Registers the 'book' tool by including it in the list of tools provided to the MCP server.
    @server.list_tools() async def list_tools() -> list[Tool]: return [Article.tool(), Book.tool()]
  • Helper function to fetch books from the Zenn API using the generic request function.
    async def fetch_books(query: Book) -> dict: return await request(URLResource.BOOKS, query.to_query_param())
  • Generic helper to make HTTP GET requests to Zenn.dev API endpoints.
    async def request(resource: URLResource, query: dict) -> dict: url = f"{BASE_URL}{resource.value}" async with httpx.AsyncClient() as client: response = await client.get(url, params=query) response.raise_for_status() return response.json()

Other Tools

Related Tools

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/shibuiwilliam/mcp-server-zenn'

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