get_user_info
Retrieve detailed user information from Dev.to by providing a specific username using the MCP server to access and interact with Dev.to content.
Instructions
Get information about a Dev.to user
Args:
username: The username of the user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes |
Implementation Reference
- server.py:90-104 (handler)The main handler function for the 'get_user_info' tool. It fetches user information from the Dev.to API endpoint `/users/{username}` using the `fetch_from_api` helper, formats the response using `format_user_profile`, and handles 404 errors by returning a user not found message.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
- server.py:89-89 (registration)The @mcp.tool() decorator registers the `get_user_info` function as an MCP tool.@mcp.tool()
- server.py:90-96 (schema)The function signature defines the input schema (username: str) and the docstring provides the tool description and parameter details for MCP schema generation.async def get_user_info(username: str) -> str: """ Get information about a Dev.to user Args: username: The username of the user """
- server.py:210-241 (helper)Helper function to format the user profile data retrieved from the API into a human-readable markdown string, used by the get_user_info handler.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
- server.py:12-18 (helper)Shared helper function to make authenticated GET requests to the Dev.to API, used by get_user_info and other tools.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()