"""Authentication tools for MCP.""" from core.mcp.auth import ( MCPContext, set_active_profile as _set_active_profile, ) from core.mcp.base import mcp, json_response, error_response @mcp.tool() async def set_active_profile(profile_id: str) -> str: """ Set the active profile for this MCP session. Must be called before using other tools. Args: profile_id: UUID of the team profile Returns: JSON object with profile info and role """ try: profile = await _set_active_profile(profile_id) return json_response({ "success": True, "profile": { "id": str(profile.id), "name": f"{profile.first_name} {profile.last_name}".strip(), "email": profile.email, "role": profile.role }, "message": f"Active profile set to {profile.first_name} ({profile.role})" }) except PermissionError as e: return error_response(str(e)) @mcp.tool() async def get_my_profile() -> str: """ Get the current active profile's information. Returns: JSON object with profile details including role and contact info """ profile = MCPContext.get_profile() if not profile: return error_response("No active profile. Call set_active_profile first.") return json_response({ "id": str(profile.id), "first_name": profile.first_name, "last_name": profile.last_name, "email": profile.email, "phone": profile.phone, "role": profile.role, "status": profile.status })