Skip to main content
Glama

get_user_info

Retrieve user profile details from Dev.to by providing a username to access information such as bio, articles, and activity.

Instructions

Get information about a Dev.to user

Args:
    username: The username of the user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • The handler function for the 'get_user_info' tool, registered with @mcp.tool(). It fetches user data from the Dev.to API and formats the profile, handling not-found errors.
    @mcp.tool()
    async def get_user_info(username: str) -> str:
        """
        Get information about a Dev.to user
        
        Args:
            username: The username of the user
        """
        try:
            user = await fetch_from_api(f"/users/{username}")
            return format_user_profile(user)
        except httpx.HTTPStatusError as e:
            if e.response.status_code == 404:
                return f"User {username} not found."
            raise e
  • Helper function used by get_user_info to format the retrieved user profile into a markdown-formatted string.
    def format_user_profile(user: dict) -> str:
        """Format a user profile for display"""
        if not user:
            return "User not found."
        
        username = user.get("username", "Unknown")
        name = user.get("name", "Unknown")
        bio = user.get("summary", "No bio available.")
        twitter = user.get("twitter_username", "")
        github = user.get("github_username", "")
        website = user.get("website_url", "")
        location = user.get("location", "")
        joined = user.get("joined_at", "")
        
        result = f"# {name} (@{username})\n\n"
        result += f"Bio: {bio}\n\n"
        
        result += "## Details\n"
        if location:
            result += f"Location: {location}\n"
        if joined:
            result += f"Member since: {joined}\n"
        
        result += "\n## Links\n"
        if twitter:
            result += f"Twitter: @{twitter}\n"
        if github:
            result += f"GitHub: {github}\n"
        if website:
            result += f"Website: {website}\n"
        
        return result
  • General helper function used by get_user_info (and other tools) 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()

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