Skip to main content
Glama

update_article

Modify existing Dev.to articles by updating titles, content, tags, or publish status using article ID.

Instructions

Update an existing article on Dev.to

Args:
    article_id: The ID of the article to update
    title: New title for the article (optional)
    body_markdown: New content in markdown format (optional)
    tags: New comma-separated list of tags (optional)
    published: Change publish status (optional)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
article_idYes
titleNo
body_markdownNo
tagsNo
publishedNo

Implementation Reference

  • The core handler function for the 'update_article' MCP tool. It is registered via the @mcp.tool() decorator. The function fetches the existing article, updates only the provided fields, sends a PUT request to the Dev.to API, and returns a success message with the updated URL.
    @mcp.tool()
    async def update_article(article_id: int, title: str = None, body_markdown: str = None, 
                            tags: str = None, published: bool = None) -> str:
        """
        Update an existing article on Dev.to
        
        Args:
            article_id: The ID of the article to update
            title: New title for the article (optional)
            body_markdown: New content in markdown format (optional)
            tags: New comma-separated list of tags (optional)
            published: Change publish status (optional)
        """
        # First get the current article data
        article = await fetch_from_api(f"/articles/{article_id}")
        
        # Prepare update data with only the fields that are provided
        update_data = {"article": {}}
        if title is not None:
            update_data["article"]["title"] = title
        if body_markdown is not None:
            update_data["article"]["body_markdown"] = body_markdown
        if tags is not None:
            update_data["article"]["tags"] = tags
        if published is not None:
            update_data["article"]["published"] = published
        
        async with httpx.AsyncClient() as client:
            response = await client.put(f"{BASE_URL}/articles/{article_id}", json=update_data, timeout=10.0)
            response.raise_for_status()
            updated_article = response.json()
        
        return f"Article updated successfully\nURL: {updated_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