article
Retrieve articles from Zenn.dev by specifying author, topic, order, page, or count using Zenn MCP Server’s API for streamlined content fetching.
Instructions
Fetch articles from Zenn.dev
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of articles per page. Default: 48 | |
| order | No | Order of the articles. Choose from latest or oldest | |
| page | No | Page number of the articles. Default: 1 | |
| topicname | No | Topic name of the article | |
| username | No | Username of the article author |
Implementation Reference
- src/mcp_server_zenn/server.py:223-226 (handler)Handler that processes the arguments for the 'article' tool, parses them into an Article object, and fetches the articles.async def handle_articles(arguments: dict) -> dict: query = Article.from_arguments(arguments) return await fetch_articles(query)
- src/mcp_server_zenn/server.py:215-217 (handler)Executes the core logic for the 'article' tool by making an HTTP request to the Zenn API with the provided query parameters.async def fetch_articles(query: Article) -> dict: return await request(URLResource.ARTICLES, query.to_query_param())
- src/mcp_server_zenn/server.py:77-140 (schema)Pydantic model for 'article' tool input schema, including field definitions, argument parsing (from_arguments), query param building (to_query_param), and Tool schema definition (tool()).class Article(BaseModel): """Fetch articles from Zenn.dev""" model_config = ConfigDict( validate_assignment=True, frozen=True, extra="forbid", ) username: Optional[str] = Field(default=None, description="Username of the article author") topicname: Optional[str] = Field(default=None, description="Topic name of the article") order: Optional[Order] = Field( default=Order.LATEST, description=f"Order of the articles. Choose from {Order.LATEST.value} or {Order.OLDEST.value}", ) page: Optional[int] = Field(default=1, description="Page number of the articles. Default: 1") count: Optional[int] = Field(default=48, description="Number of articles per page. Default: 48") @staticmethod def from_arguments(arguments: dict) -> "Article": return Article( 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.ARTICLE.value, description="Fetch articles from Zenn.dev", inputSchema={ "type": "object", "properties": { "username": {"type": "string", "description": Article.model_fields["username"].description}, "topicname": {"type": "string", "description": Article.model_fields["topicname"].description}, "order": { "type": "string", "description": Article.model_fields["order"].description, "enum": [Order.LATEST.value, Order.OLDEST.value], }, "page": {"type": "integer", "description": Article.model_fields["page"].description}, "count": {"type": "integer", "description": Article.model_fields["count"].description}, }, "required": [], }, )
- src/mcp_server_zenn/server.py:243-246 (registration)Registers the 'article' tool with the MCP server by including it in the list of available tools.@server.list_tools() async def list_tools() -> list[Tool]: return [Article.tool(), Book.tool()]
- src/mcp_server_zenn/server.py:248-268 (handler)MCP server call_tool handler that dispatches calls to the 'article' tool (when name == 'article') to the specific handle_articles function and returns the JSON result as TextContent.@server.call_tool() async def call_tool( name: str, arguments: dict, ) -> Sequence[TextContent | ImageContent | EmbeddedResource]: try: logger.debug(f"Calling tool: {name} with arguments: {arguments}") match name: case ZennTool.ARTICLE.value: result = await handle_articles(arguments) case ZennTool.BOOK.value: result = await handle_books(arguments) case _: raise ValueError(f"Unknown tool: {name}") return [TextContent(type="text", text=json.dumps(result, indent=2, ensure_ascii=False))] except Exception as e: logger.error(f"Error processing {APP_NAME} query: {str(e)}") raise ValueError(f"Error processing {APP_NAME} query: {str(e)}")