Skip to main content
Glama
rhettlong

USCardForum MCP Server

by rhettlong

get_user_badges

Retrieve user badges to assess participation milestones, community recognition, and special achievements for evaluating experience and trustworthiness on the forum.

Instructions

Fetch badges earned by a user.

Args:
    username: The user's handle
    grouped: Group badges by type (default: True)

Returns a UserBadges object with:
- badges: List of Badge objects with name, description, granted_at
- badge_types: Badge type information

Badges indicate:
- Participation milestones (first post, anniversaries)
- Community recognition (editor, leader)
- Special achievements

Use to assess user experience and trustworthiness.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe user's handle
groupedNoGroup badges by type (default: True)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
badgesNoEarned badges
badge_typesNoBadge type info

Implementation Reference

  • MCP tool handler for 'get_user_badges'. Decorated with @mcp.tool(), defines input schema using Annotated and Field, includes detailed docstring, and delegates execution to the client library.
    @mcp.tool()
    def get_user_badges(
        username: Annotated[
            str,
            Field(description="The user's handle"),
        ],
        grouped: Annotated[
            bool,
            Field(default=True, description="Group badges by type (default: True)"),
        ] = True,
    ) -> UserBadges:
        """
        Fetch badges earned by a user.
    
        Args:
            username: The user's handle
            grouped: Group badges by type (default: True)
    
        Returns a UserBadges object with:
        - badges: List of Badge objects with name, description, granted_at
        - badge_types: Badge type information
    
        Badges indicate:
        - Participation milestones (first post, anniversaries)
        - Community recognition (editor, leader)
        - Special achievements
    
        Use to assess user experience and trustworthiness.
        """
        return get_client().get_user_badges(username, grouped=grouped)
  • Imports and exposes the get_user_badges tool in the main server entrypoint, making it available for MCP server registration via main().
    from uscardforum.server_tools import (
        analyze_user,
        bookmark_post,
        compare_cards,
        find_data_points,
        get_all_topic_posts,
        get_categories,
        get_current_session,
        get_hot_topics,
        get_new_topics,
        get_notifications,
        get_top_topics,
        get_topic_info,
        get_topic_posts,
        get_user_actions,
        get_user_badges,
        get_user_followers,
        get_user_following,
        get_user_reactions,
        get_user_replies,
        get_user_summary,
        get_user_topics,
        list_users_with_badge,
        login,
        research_topic,
        resource_categories,
        resource_hot_topics,
        resource_new_topics,
        search_forum,
        subscribe_topic,
    )
    
    __all__ = [
        "MCP_HOST",
        "MCP_PORT",
        "MCP_TRANSPORT",
        "NITAN_TOKEN",
        "SERVER_INSTRUCTIONS",
        "get_client",
        "main",
        "mcp",
        "analyze_user",
        "bookmark_post",
        "compare_cards",
        "find_data_points",
        "get_all_topic_posts",
        "get_categories",
        "get_current_session",
        "get_hot_topics",
        "get_new_topics",
        "get_notifications",
        "get_top_topics",
        "get_topic_info",
        "get_topic_posts",
        "get_user_actions",
        "get_user_badges",
        "get_user_followers",
        "get_user_following",
        "get_user_reactions",
        "get_user_replies",
        "get_user_summary",
        "get_user_topics",
        "list_users_with_badge",
        "login",
        "resource_categories",
        "resource_hot_topics",
        "resource_new_topics",
        "search_forum",
        "subscribe_topic",
        "research_topic",
    ]
  • Client library wrapper method that delegates to the users API client.
    def get_user_badges(
        self,
        username: str,
        grouped: bool = True,
    ) -> UserBadges:
        """Fetch user's badges.
    
        Args:
            username: User handle
            grouped: Group badges (default: True)
    
        Returns:
            User badges data
        """
        return self._users.get_user_badges(username, grouped=grouped)
  • Core API implementation that performs HTTP GET request to the forum API endpoint /user-badges/{username}.json, parses the response, and constructs UserBadges object.
    def get_user_badges(
        self,
        username: str,
        grouped: bool = True,
    ) -> UserBadges:
        """Fetch user's badges.
    
        Args:
            username: User handle
            grouped: Group badges (default: True)
    
        Returns:
            User badges data
        """
        params_list: list[tuple[str, Any]] = [
            ("grouped", str(bool(grouped)).lower())
        ]
        payload = self._get(f"/user-badges/{username}.json", params=params_list)
    
        badges = []
        for b in payload.get("user_badges", []):
            badges.append(Badge(
                id=b.get("id", 0),
                badge_id=b.get("badge_id", 0),
                name=b.get("name", ""),
                description=b.get("description"),
                granted_at=b.get("granted_at"),
            ))
    
        return UserBadges(badges=badges)
  • Re-exports the tool from users.py module for convenient import in server.py.
    from .users import (
        get_user_summary,
        get_user_topics,
        get_user_replies,
        get_user_actions,
        get_user_badges,
        get_user_following,
        get_user_followers,
        get_user_reactions,
        list_users_with_badge,
    )
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool fetches data (implied read-only) and explains the significance of badges (e.g., milestones, recognition), adding useful context. However, it lacks details on behavioral traits like error handling, rate limits, or authentication needs, which are important for a tool with user data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for purpose, args, returns, and usage, making it easy to scan. It is appropriately sized, but the parameter descriptions are redundant with the schema, slightly reducing efficiency. Most sentences earn their place by adding value beyond the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (implied by 'Returns a UserBadges object'), the description does not need to detail return values, and it adequately explains the tool's purpose and usage. With no annotations and 100% schema coverage, it provides sufficient context for a read operation, though it could benefit from more behavioral details like error cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description repeats the parameter descriptions verbatim ('username: The user's handle', 'grouped: Group badges by type') without adding extra meaning, such as format constraints or examples. Baseline 3 is appropriate as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Fetch' and resource 'badges earned by a user', making the purpose specific and unambiguous. It distinguishes from siblings like 'get_user_summary' or 'list_users_with_badge' by focusing on individual user badges rather than summaries or badge-wide listings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for usage ('Use to assess user experience and trustworthiness') and implies when to use it (for badge-related user assessment). However, it does not explicitly state when not to use it or name alternatives among siblings, such as 'get_user_summary' for broader user data.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/rhettlong/uscardforum-mcp'

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