Skip to main content
Glama

create_article

Publish articles to Dev.to by providing title, markdown content, tags, and publication status.

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
NameRequiredDescriptionDefault
titleYes
body_markdownYes
tagsNo
publishedNo

Implementation Reference

  • The main handler function for the 'create_article' MCP tool. It is decorated with @mcp.tool() which registers it. The function signature and docstring define the input schema. It sends a POST request to Dev.to API to create an article with the given parameters and returns the article ID and URL.
    @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')}"

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/Arindam200/devto-mcp'

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