create_article
Generate and publish articles on Dev.to by specifying a title, markdown content, tags, and publication status. Ideal for automating content creation and managing drafts or live posts.
Instructions
Create and publish a new article on Dev.to
Args:
title: The title of the article
body_markdown: The content of the article in markdown format
tags: Comma-separated list of tags (e.g., "python,tutorial,webdev")
published: Whether to publish immediately (True) or save as draft (False)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body_markdown | Yes | ||
| published | No | ||
| tags | No | ||
| title | Yes |
Implementation Reference
- server.py:105-130 (handler)The main handler function for the 'create_article' tool, decorated with @mcp.tool() for registration. It creates a new article on Dev.to using the provided title, body_markdown, tags, and published status by posting to the Dev.to API.@mcp.tool() async def create_article(title: str, body_markdown: str, tags: str = "", published: bool = False) -> str: """ Create and publish a new article on Dev.to Args: title: The title of the article body_markdown: The content of the article in markdown format tags: Comma-separated list of tags (e.g., "python,tutorial,webdev") published: Whether to publish immediately (True) or save as draft (False) """ article_data = { "article": { "title": title, "body_markdown": body_markdown, "published": published, "tags": tags } } async with httpx.AsyncClient() as client: response = await client.post(f"{BASE_URL}/articles", json=article_data, headers={"Content-Type": "application/json", "api-key": os.getenv("DEV_TO_API_KEY")}, timeout=10.0) response.raise_for_status() article = response.json() return f"Article created successfully with ID: {article.get('id')}\nURL: {article.get('url')}"