get_article_by_id
Retrieve a specific Dev.to article using its unique ID to access content details and information.
Instructions
Get a specific article by ID from Dev.to
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- server.py:40-45 (handler)Handler function for the 'get_article_by_id' tool. It fetches the article details from the Dev.to API using the provided ID and formats the output using format_article_details.@mcp.tool() async def get_article_by_id(id: str) -> str: """Get a specific article by ID from Dev.to""" article = await fetch_from_api(f"/articles/{id}") return format_article_details(article)
- server.py:12-18 (helper)Helper function used by get_article_by_id to make API requests to Dev.to.async def fetch_from_api(path: str, params: dict = None) -> dict: """Helper function to fetch data from Dev.to API""" async with httpx.AsyncClient() as client: url = f"{BASE_URL}{path}" response = await client.get(url, params=params, timeout=10.0) response.raise_for_status() return response.json()
- server.py:190-208 (helper)Helper function used by get_article_by_id to format the article details for output.def format_article_details(article: dict) -> str: """Format a single article with full details""" if not article: return "Article not found." title = article.get("title", "Untitled") author = article.get("user", {}).get("name", "Unknown Author") published_date = article.get("readable_publish_date", "Unknown date") body = article.get("body_markdown", "No content available.") tags = article.get("tags", "") result = f"# {title}\n\n" result += f"Author: {author}\n" result += f"Published: {published_date}\n" result += f"Tags: {tags}\n\n" result += "## Content\n\n" result += body return result