Skip to main content
Glama

get_articles_by_username

Retrieve articles published by a specific Dev.to author using their username to access their content portfolio.

Instructions

Get articles written by a specific user

Args:
    username: The username of the author

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • server.py:78-87 (handler)
    The handler function decorated with @mcp.tool() that implements the 'get_articles_by_username' tool. It fetches articles by the given username from the Dev.to API using the shared fetch_from_api helper and formats the results with format_articles.
    @mcp.tool()
    async def get_articles_by_username(username: str) -> str:
        """
        Get articles written by a specific user
        
        Args:
            username: The username of the author
        """
        articles = await fetch_from_api("/articles", params={"username": username})
        return format_articles(articles[:10])
  • Shared helper function used by get_articles_by_username to make HTTP requests to the Dev.to API.
    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()
  • Shared helper function used by get_articles_by_username to format the list of articles into a readable markdown string.
    def format_articles(articles: list) -> str:
        """Format a list of articles for display"""
        if not articles:
            return "No articles found."
        
        result = "# Dev.to Articles\n\n"
        for article in articles:
            title = article.get("title", "Untitled")
            author = article.get("user", {}).get("name", "Unknown Author")
            published_date = article.get("readable_publish_date", "Unknown date")
            article_id = article.get("id", "")
            tags = article.get("tags", "")
            
            result += f"## {title}\n"
            result += f"ID: {article_id}\n"
            result += f"Author: {author}\n"
            result += f"Published: {published_date}\n"
            result += f"Tags: {tags}\n"
            result += f"Description: {article.get('description', 'No description available.')}\n\n"
        
        return result

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