article
Fetch Zenn.dev articles by author, topic, or date order to access technical content and documentation.
Instructions
Fetch articles from Zenn.dev
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "article"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | No | Username of the article author | |
| topicname | No | Topic name of the article | |
| order | No | Order of the articles. Choose from latest or oldest | |
| page | No | Page number of the articles. Default: 1 | |
| count | No | Number of articles per page. Default: 48 |
Implementation Reference
- src/mcp_server_zenn/server.py:223-226 (handler)Specific handler function for the 'article' tool. It converts the input arguments dictionary into an Article model instance and calls fetch_articles to retrieve data from Zenn.dev API.
async def handle_articles(arguments: dict) -> dict: query = Article.from_arguments(arguments) return await fetch_articles(query) - Defines the input schema for the 'article' tool using Pydantic model fields, returned as a Tool object for MCP registration.
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 its Tool schema in the list_tools response.
@server.list_tools() async def list_tools() -> list[Tool]: return [Article.tool(), Book.tool()] - src/mcp_server_zenn/server.py:248-268 (handler)Main MCP tool call handler decorated with @server.call_tool(). Dispatches 'article' tool calls to the specific handle_articles function and formats the JSON response 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)}") - Helper function that performs the HTTP request to fetch articles from Zenn.dev API using the query parameters derived from the Article model.
async def fetch_articles(query: Article) -> dict: return await request(URLResource.ARTICLES, query.to_query_param())