Skip to main content
Glama
GodisinHisHeaven

USCardForum MCP Server

get_current_session

Verify authentication status and retrieve current user information for USCardForum interactions. Check login status and access user details when authenticated.

Instructions

Get information about the current session.

Returns a Session object with:
- is_authenticated: Whether logged in
- current_user: CurrentUser object with user info (if authenticated)

Use to verify authentication status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler function for 'get_current_session'. It uses the shared client instance to retrieve the current authentication session.
    @mcp.tool()
    def get_current_session() -> Session:
        """
        Get information about the current session.
    
        Returns a Session object with:
        - is_authenticated: Whether logged in
        - current_user: CurrentUser object with user info (if authenticated)
    
        Use to verify authentication status.
        """
        return get_client().get_current_session()
  • Pydantic model defining the structure of the Session object returned by the tool, including current_user and is_authenticated fields.
    class Session(BaseModel):
        """Current session information."""
    
        current_user: CurrentUser | None = Field(None, description="Logged-in user")
        is_authenticated: bool = Field(False, description="Whether authenticated")
    
        class Config:
            extra = "ignore"
    
        @classmethod
        def from_api_response(cls, data: dict[str, Any]) -> "Session":
            """Parse from raw API response."""
            user_data = data.get("current_user") or data.get("user")
            current_user = CurrentUser(**user_data) if user_data else None
            return cls(
                current_user=current_user,
                is_authenticated=current_user is not None,
            )
  • Core implementation in AuthAPI class that performs the HTTP request to fetch session data from the forum API.
    def get_current_session(self) -> Session:
        """Get current session info.
    
        Returns:
            Session data including user info (unauthenticated if no session)
        """
        try:
            payload = self._get("/session/current.json")
            return Session.from_api_response(payload)
        except requests.exceptions.HTTPError as e:
            # 404 means no session - return unauthenticated session
            if e.response is not None and e.response.status_code == 404:
                return Session(is_authenticated=False, current_user=None)
            raise
  • Wrapper method on the main DiscourseClient that delegates the get_current_session call to its internal AuthAPI instance.
    def get_current_session(self) -> Session:
        """Get current session info.
    
        Returns:
            Session data including user info
        """
        return self._auth.get_current_session()
  • Import of the get_current_session tool in server_tools __init__.py, making it available for re-export and server registration.
    from .auth import (
        login,
        get_current_session,
        get_notifications,
        bookmark_post,
        subscribe_topic,
    )

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