Skip to main content
Glama
GodisinHisHeaven

USCardForum MCP Server

get_user_badges

Retrieve user badges to evaluate participation, community recognition, and special achievements for trust assessment.

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 via Annotated[Field] and delegates execution to the DiscourseClient.get_user_badges() method.
    @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 get_user_badges (line 30) along with other MCP tools into the FastMCP server entrypoint, ensuring auto-registration via @mcp.tool() decorators.
    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,
    )
  • Re-exports get_user_badges from users.py module, making it available for import in server.py for MCP tool registration.
    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,
    )
  • Core helper implementation in UsersAPI class that performs the HTTP GET request to Discourse API endpoint /user-badges/{username}.json, parses the response, constructs Badge objects, and returns UserBadges instance. Called by client.get_user_badges().
    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)
  • Input schema defined via Pydantic Annotated[str, Field(...)] for username and grouped parameters, with return type UserBadges for output validation.
    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)
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that this is a read operation ('Fetch'), describes the return structure, and explains the significance of badges. However, it lacks details on error conditions, rate limits, authentication needs, or pagination behavior.

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 clear sections (purpose, args, returns, badge significance, usage), but includes some redundancy (repeating parameter descriptions already in schema) and could be more front-loaded by moving the usage guidance earlier.

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 the tool's moderate complexity, 100% schema coverage, and the presence of an output schema (implied by 'Returns a UserBadges object'), the description is mostly complete. It explains the purpose, parameters, return structure, and usage context, though it could benefit from more behavioral details like error handling.

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 without adding additional meaning, syntax, or format details beyond what the schema provides, meeting the baseline for high coverage.

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 specific action ('Fetch badges earned by a user') and resource ('badges'), distinguishing it from sibling tools like 'get_user_summary' or 'list_users_with_badge' by focusing specifically on badge retrieval for a given user.

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 when to use this tool ('Use to assess user experience and trustworthiness'), but does not explicitly mention when not to use it or name specific alternatives among the sibling tools (e.g., 'get_user_summary' might overlap).

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

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