get_current_session
Retrieve current user session details including authentication status and user information from the USCardForum MCP Server.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The MCP tool handler implementation for 'get_current_session'. It is decorated with @mcp.tool() and delegates to the shared client's get_current_session method 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()
- src/uscardforum/models/auth.py:46-64 (schema)Pydantic BaseModel defining the output schema for the get_current_session tool. Includes fields for current_user (optional) and is_authenticated boolean, with a classmethod for parsing from API responses.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, )
- src/uscardforum/client.py:482-488 (helper)Helper method in DiscourseClient that implements the core session retrieval logic by delegating to the AuthAPI submodule.def get_current_session(self) -> Session: """Get current session info. Returns: Session data including user info """ return self._auth.get_current_session()
- src/uscardforum/server_tools/__init__.py:52-58 (registration)Re-export of the get_current_session tool from the auth module, making it available at the server_tools package level for the MCP server entrypoint.from .auth import ( login, get_current_session, get_notifications, bookmark_post, subscribe_topic, )
- src/uscardforum/server.py:15-25 (registration)Import of get_current_session into the MCP server entrypoint module, where it is exposed in __all__ for automatic tool registration in 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,