diff --git a/README.md b/README.md index c64142e..98a8059 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ # ILIAS MCP -Production-oriented MCP server for ILIAS login, enrolled course listing, dashboard news, repository crawling, and file downloads. +Production-oriented MCP server for ILIAS login, enrolled course listing, dashboard news, repository crawling, file downloads, and exercise submission management. ## Tools +### General + - [login](#login): authenticate against ILIAS - [list_courses](#list_courses): list enrolled courses with title, URL, and ref ID - [server_info](#server_info): show non-sensitive runtime config - [list_calendar_events](#list_calendar_events): list agenda events for a day - [list_dashboard_news](#list_dashboard_news): list personal dashboard news from ilPDNewsGUI + +### Repository + - [list_repository_items](#list_repository_items): list child objects below a ref ID - [get_repository_item_details](#get_repository_item_details): fetch page details and detect download URLs - [get_file_content](#get_file_content): download file content by ref ID; PDFs are parsed to text with pypdf @@ -16,6 +21,20 @@ Production-oriented MCP server for ILIAS login, enrolled course listing, dashboa - [download_file](#download_file): download one file object by ref ID - [download_repository_files](#download_repository_files): recursively download matching files and preserve ILIAS folders +### Exercise Submission + +- [list_exercise_assignments](#list_exercise_assignments): list assignments (Übungsblätter) for an exercise object by ref ID +- [submit_exercise_file](#submit_exercise_file): upload a local file as a submission for an assignment +- [list_submitted_files](#list_submitted_files): list already submitted files with their delivery IDs +- [delete_submitted_files](#delete_submitted_files): delete submitted files by delivery ID + +### Team Management + +- [list_team_members](#list_team_members): list current submission team members +- [add_team_member](#add_team_member): add a user to the submission team by ILIAS login name +- [remove_team_member](#remove_team_member): remove a team member by user ID +- [search_users](#search_users): search ILIAS users by name fragment to find their login name + ## Demo  @@ -48,6 +67,7 @@ ilias-mcp - Server keeps a session in memory while process is running. - On process restart, login is re-established on demand. -- This server is intentionally read-only for safety. - Downloads use the official ILIAS file routes used by the Stuttgart fork, including ilObjFileGUI sendfile and goto.php file download routes. - Start with [list_courses](#list_courses), then call [crawl_repository](#crawl_repository) or [download_repository_files](#download_repository_files) with the course ref ID. +- For exercise submission: use [list_exercise_assignments](#list_exercise_assignments) to get `ass_id` values, then [submit_exercise_file](#submit_exercise_file) with the local file path. +- For team management: use [search_users](#search_users) to find a teammate's login name, then [add_team_member](#add_team_member). diff --git a/src/domain/models.py b/src/domain/models.py index 859238e..17903ac 100644 --- a/src/domain/models.py +++ b/src/domain/models.py @@ -56,3 +56,24 @@ class NewsItem: author: str date_label: str url: str + + +@dataclass(frozen=True) +class ExerciseAssignment: + ass_id: str + title: str + deadline: str + status: str + + +@dataclass(frozen=True) +class SubmittedFile: + filename: str + size: str + date: str + + +@dataclass(frozen=True) +class TeamMember: + user_id: str + name: str diff --git a/src/mcp_app/server.py b/src/mcp_app/server.py index 993f0ef..613fe1d 100644 --- a/src/mcp_app/server.py +++ b/src/mcp_app/server.py @@ -14,6 +14,7 @@ from services.calendar_service import CalendarService, IliasCalendarError from services.course_service import CourseService, IliasCourseError from services.news_service import IliasNewsError, NewsService +from services.exercise_service import ExerciseService, IliasExerciseError from services.repository_service import IliasRepositoryError, RepositoryService logging.basicConfig(level=logging.INFO) @@ -29,6 +30,7 @@ def __init__( calendar_service: CalendarService, news_service: NewsService, repository_service: RepositoryService, + exercise_service: ExerciseService, ) -> None: self.settings = settings self.auth_service = auth_service @@ -36,6 +38,7 @@ def __init__( self.calendar_service = calendar_service self.news_service = news_service self.repository_service = repository_service + self.exercise_service = exercise_service @asynccontextmanager @@ -69,6 +72,9 @@ async def lifespan(_: FastMCP) -> AsyncIterator[AppContext]: repository_service = RepositoryService( settings=settings, session=session, auth_service=auth_service ) + exercise_service = ExerciseService( + settings=settings, session=session, auth_service=auth_service + ) logger.info("ILIAS MCP server initialized and ready.") yield AppContext( settings=settings, @@ -77,6 +83,7 @@ async def lifespan(_: FastMCP) -> AsyncIterator[AppContext]: calendar_service=calendar_service, news_service=news_service, repository_service=repository_service, + exercise_service=exercise_service, ) logger.info("Shutting down ILIAS MCP server.") @@ -390,6 +397,231 @@ async def list_dashboard_news( } +@mcp.tool() +async def list_exercise_assignments( + ctx: Context[ServerSession, AppContext], + ref_id: str, +) -> dict[str, object]: + """List all assignments (Übungsblätter) for an ILIAS exercise object by ref_id.""" + app = _app(ctx) + try: + assignments = app.exercise_service.list_assignments(ref_id=ref_id) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning("Exercise listing failed for ref_id=%s: %s", ref_id, exc) + return { + "status": "error", + "message": str(exc), + "ref_id": ref_id, + "assignments": [], + } + + return { + "status": "ok", + "ref_id": ref_id, + "count": len(assignments), + "assignments": [ + { + "ass_id": a.ass_id, + "title": a.title, + "deadline": a.deadline, + "status": a.status, + } + for a in assignments + ], + } + + +@mcp.tool() +async def submit_exercise_file( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, + local_path: str, +) -> dict[str, object]: + """Upload a local file as a submission for an ILIAS exercise assignment. + + ref_id: ref_id of the exercise object (e.g. Abgabe-Gruppe). + ass_id: assignment ID obtained from list_exercise_assignments. + local_path: absolute or home-relative path to the file to upload. + """ + app = _app(ctx) + try: + result = app.exercise_service.submit_file( + ref_id=ref_id, ass_id=ass_id, local_path=local_path + ) + except (IliasAuthError, IliasExerciseError, OSError) as exc: + logger.warning( + "Exercise submission failed for ref_id=%s ass_id=%s: %s", + ref_id, + ass_id, + exc, + ) + return {"status": "error", "message": str(exc)} + + return {"status": "ok", **result} + + +@mcp.tool() +async def list_submitted_files( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, +) -> dict[str, object]: + """List all files already submitted for an exercise assignment, with their delivery IDs.""" + app = _app(ctx) + try: + files = app.exercise_service.list_submitted_files(ref_id=ref_id, ass_id=ass_id) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning( + "List submitted files failed for ref_id=%s ass_id=%s: %s", + ref_id, + ass_id, + exc, + ) + return {"status": "error", "message": str(exc), "files": []} + return { + "status": "ok", + "ref_id": ref_id, + "ass_id": ass_id, + "count": len(files), + "files": files, + } + + +@mcp.tool() +async def delete_submitted_files( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, + delivery_ids: list[str], +) -> dict[str, object]: + """Delete one or more submitted files by their delivery_id (from list_submitted_files). + + delivery_ids: list of delivery_id strings to delete. + """ + app = _app(ctx) + try: + result = app.exercise_service.delete_submitted_files( + ref_id=ref_id, ass_id=ass_id, delivery_ids=delivery_ids + ) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning( + "Delete submitted files failed for ref_id=%s ass_id=%s: %s", + ref_id, + ass_id, + exc, + ) + return {"status": "error", "message": str(exc)} + return {"status": "ok", **result} + + +@mcp.tool() +async def list_team_members( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, +) -> dict[str, object]: + """List current team members for an exercise assignment submission team.""" + app = _app(ctx) + try: + members = app.exercise_service.list_team_members(ref_id=ref_id, ass_id=ass_id) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning( + "Team listing failed for ref_id=%s ass_id=%s: %s", ref_id, ass_id, exc + ) + return {"status": "error", "message": str(exc), "members": []} + + return { + "status": "ok", + "ref_id": ref_id, + "ass_id": ass_id, + "count": len(members), + "members": [{"user_id": m.user_id, "name": m.name} for m in members], + } + + +@mcp.tool() +async def search_users( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, + term: str, +) -> dict[str, object]: + """Search ILIAS users by name or login fragment. + + Returns login names that can be passed to add_team_member. + """ + app = _app(ctx) + try: + results = app.exercise_service.search_users( + ref_id=ref_id, ass_id=ass_id, term=term + ) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning("User search failed term=%s: %s", term, exc) + return {"status": "error", "message": str(exc), "results": []} + return {"status": "ok", "term": term, "count": len(results), "results": results} + + +@mcp.tool() +async def add_team_member( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, + username: str, +) -> dict[str, object]: + """Add a user to the submission team by their ILIAS login name (e.g. st123456). + + ref_id: ref_id of the exercise object. + ass_id: assignment ID from list_exercise_assignments. + username: ILIAS login name of the person to add. + """ + app = _app(ctx) + try: + result = app.exercise_service.add_team_member( + ref_id=ref_id, ass_id=ass_id, username=username + ) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning( + "Add team member failed for ref_id=%s ass_id=%s user=%s: %s", + ref_id, + ass_id, + username, + exc, + ) + return {"status": "error", "message": str(exc)} + + return {"status": "ok", **result} + + +@mcp.tool() +async def remove_team_member( + ctx: Context[ServerSession, AppContext], + ref_id: str, + ass_id: str, + user_id: str, +) -> dict[str, object]: + """Remove a user from the submission team by their ILIAS user_id. + + user_id can be obtained from list_team_members. + """ + app = _app(ctx) + try: + result = app.exercise_service.remove_team_member( + ref_id=ref_id, ass_id=ass_id, user_id=user_id + ) + except (IliasAuthError, IliasExerciseError) as exc: + logger.warning( + "Remove team member failed for ref_id=%s ass_id=%s user_id=%s: %s", + ref_id, + ass_id, + user_id, + exc, + ) + return {"status": "error", "message": str(exc)} + + return {"status": "ok", **result} + + @mcp.resource("ilias://courses") async def courses_resource(ctx: Context[ServerSession, AppContext]) -> str: """All enrolled ILIAS courses as a context document.""" diff --git a/src/services/exercise_service.py b/src/services/exercise_service.py new file mode 100644 index 0000000..d70ed02 --- /dev/null +++ b/src/services/exercise_service.py @@ -0,0 +1,529 @@ +from __future__ import annotations + +import re +from html import unescape +from pathlib import Path +from urllib.parse import urljoin, urlparse, parse_qs + +import requests +from bs4 import BeautifulSoup + +from core.config import Settings +from domain.models import ExerciseAssignment, TeamMember +from services.auth_service import AuthService + + +class IliasExerciseError(RuntimeError): + pass + + +class ExerciseService: + def __init__( + self, settings: Settings, session: requests.Session, auth_service: AuthService + ) -> None: + self.settings = settings + self.session = session + self.auth_service = auth_service + + # Assignments + + def list_assignments(self, ref_id: str) -> list[ExerciseAssignment]: + self.auth_service.ensure_logged_in() + url = self._overview_url(ref_id) + resp = self._get(url, f"exercise overview {ref_id}") + return self._extract_assignments(resp.text, ref_id) + + def _extract_assignments(self, html: str, ref_id: str) -> list[ExerciseAssignment]: + soup = BeautifulSoup(html, "html.parser") + assignments: list[ExerciseAssignment] = [] + seen: set[str] = set() + + for a in soup.find_all("a", href=True): + href = str(a.get("href", "")) + qs = parse_qs(urlparse(href).query) + ass_id = qs.get("ass_id", [""])[0] + if not ass_id or ass_id in seen: + continue + if "AssignmentPresentationGUI" not in href and "showOverview" not in href: + continue + seen.add(ass_id) + title = " ".join(a.get_text(" ", strip=True).split()) + row = a.find_parent(["tr", "li", "div"]) + deadline = "" + status = "" + if row: + text = row.get_text(" ", strip=True) + m = re.search(r"\d{2}\.\d{2}\.\d{4}(?:\s+\d{2}:\d{2})?", text) + if m: + deadline = m.group(0) + for word in ("abgegeben", "nicht abgegeben", "bewertet", "submitted"): + if word.lower() in text.lower(): + status = word + break + assignments.append( + ExerciseAssignment( + ass_id=ass_id, title=title, deadline=deadline, status=status + ) + ) + return assignments + + # File submission + + def submit_file(self, ref_id: str, ass_id: str, local_path: str) -> dict[str, str]: + """Upload a local file as an exercise submission.""" + self.auth_service.ensure_logged_in() + path = Path(local_path).expanduser().resolve() + if not path.exists(): + raise IliasExerciseError(f"Local file not found: {path}") + + # Step 1: GET upload form to discover cmdNode + rtoken + form_url = self._upload_form_url(ref_id, ass_id) + form_resp = self._get(form_url, "upload form") + upload_handler_url, submit_url, input_name = self._parse_upload_form( + form_resp.text, ref_id, ass_id + ) + + # Step 2: POST file to Dropzone handler → get file identifier + file_id = self._dropzone_upload(upload_handler_url, path) + + # Step 3: POST form with the returned identifier + payload = {input_name: file_id} + post_resp = self.session.post( + urljoin(self.settings.ilias_base_url + "/", submit_url), + data=payload, + timeout=self.settings.timeout_seconds, + allow_redirects=True, + ) + post_resp.raise_for_status() + + return { + "status": "submitted", + "filename": path.name, + "file_id": file_id, + "ref_id": ref_id, + "ass_id": ass_id, + } + + def _parse_upload_form( + self, html: str, ref_id: str, ass_id: str + ) -> tuple[str, str, str]: + """Return (dropzone_upload_url, form_action_url, hidden_input_name).""" + soup = BeautifulSoup(html, "html.parser") + + # Find the multipart form (not the search form) + submit_url = "" + input_name = "form/input_0/input_1[input_0][]" + for form in soup.find_all("form", enctype="multipart/form-data"): + action = str(form.get("action", "")).strip() + if "ExSubmissionFileGUI" in action or "addUpload" in action: + submit_url = action + hidden = form.find("input", type="hidden") + if hidden and hidden.get("name"): + input_name = str(hidden["name"]) + break + + # Dropzone handler URL from JS (capture full URL including ilias.php prefix) + upload_handler_url = "" + m = re.search( + r"['\"]?(ilias\.php\?[^'\"]*ilRepoStandardUploadHandlerGUI&cmd=upload[^'\"]*)['\"]?", + html, + ) + if m: + upload_handler_url = urljoin(self.settings.ilias_base_url + "/", m.group(1)) + + if not upload_handler_url: + raise IliasExerciseError( + f"Could not locate Dropzone upload URL for ref_id={ref_id}, ass_id={ass_id}" + ) + if not submit_url: + raise IliasExerciseError( + f"Could not locate submission form action for ref_id={ref_id}, ass_id={ass_id}" + ) + + return upload_handler_url, submit_url, input_name + + def _dropzone_upload(self, upload_url: str, path: Path) -> str: + """POST file to ILIAS Dropzone handler; return the identifier string.""" + with path.open("rb") as fh: + resp = self.session.post( + upload_url, + files={"file": (path.name, fh)}, + timeout=self.settings.timeout_seconds, + allow_redirects=True, + ) + resp.raise_for_status() + try: + data = resp.json() + except Exception as exc: + raise IliasExerciseError( + f"Dropzone upload did not return JSON: {resp.text[:200]}" + ) from exc + + # ILIAS returns {"identifier": "...", ...} or {"status":1,"":"filename"} + file_id = ( + data.get("identifier") + or data.get("file_id") + or data.get("id") + or data.get("") # ILIAS quirk: identifier stored under empty-string key + or "" + ) + if not file_id or not data.get("status", 1): + raise IliasExerciseError( + f"Dropzone upload failed or missing identifier: {data}" + ) + return str(file_id) + + def list_submitted_files(self, ref_id: str, ass_id: str) -> list[dict[str, str]]: + """Return submitted files with their delivery IDs, names, and dates.""" + self.auth_service.ensure_logged_in() + url = self._submission_screen_url(ref_id, ass_id) + resp = self._get(url, f"submission screen {ref_id}/{ass_id}") + return self._extract_submitted_files(resp.text) + + def delete_submitted_files( + self, ref_id: str, ass_id: str, delivery_ids: list[str] + ) -> dict[str, object]: + """Delete submitted files by their delivery IDs (two-step: confirm then delete).""" + self.auth_service.ensure_logged_in() + url = self._submission_screen_url(ref_id, ass_id) + page_resp = self._get(url, f"submission screen {ref_id}/{ass_id}") + + form_action = self._extract_submission_form_action( + page_resp.text, ref_id, ass_id + ) + + # Step 1: confirmDeleteDelivered → shows confirmation page + payload: list[tuple[str, str]] = [("delivered[]", did) for did in delivery_ids] + payload.append(("cmd[confirmDeleteDelivered]", "Löschen")) + confirm_resp = self.session.post( + urljoin(self.settings.ilias_base_url + "/", form_action), + data=payload, + timeout=self.settings.timeout_seconds, + allow_redirects=True, + ) + confirm_resp.raise_for_status() + + # Step 2: deleteDelivered → actual deletion + confirm_action = self._extract_submission_form_action( + confirm_resp.text, ref_id, ass_id + ) + delete_payload: list[tuple[str, str]] = [ + ("delivered[]", did) for did in delivery_ids + ] + delete_payload.append(("cmd[deleteDelivered]", "Löschen")) + final_resp = self.session.post( + urljoin(self.settings.ilias_base_url + "/", confirm_action), + data=delete_payload, + timeout=self.settings.timeout_seconds, + allow_redirects=True, + ) + final_resp.raise_for_status() + + remaining = self._extract_submitted_files(final_resp.text) + return { + "status": "deleted", + "deleted_ids": delivery_ids, + "remaining_count": len(remaining), + "remaining": remaining, + } + + def _extract_submission_form_action( + self, html: str, ref_id: str, ass_id: str + ) -> str: + soup = BeautifulSoup(html, "html.parser") + for form in soup.find_all("form"): + action = str(form.get("action", "")) + if "ExSubmissionFileGUI" in action and "search" not in action.lower(): + return action + raise IliasExerciseError( + f"Submission form not found for ref_id={ref_id}, ass_id={ass_id}" + ) + + def _extract_submitted_files(self, html: str) -> list[dict[str, str]]: + soup = BeautifulSoup(html, "html.parser") + files: list[dict[str, str]] = [] + for inp in soup.find_all("input", {"name": "delivered[]"}): + delivery_id = str(inp.get("value", "")).strip() + if not delivery_id: + continue + row = inp.find_parent("tr") + name, date, submitter = "", "", "" + if row: + cells = row.find_all("td") + texts = [c.get_text(strip=True) for c in cells] + # typically: [checkbox, filename, submitter, date] + if len(texts) >= 4: + name, submitter, date = texts[1], texts[2], texts[3] + elif len(texts) == 3: + name, submitter, date = texts[0], texts[1], texts[2] + files.append( + { + "delivery_id": delivery_id, + "filename": name, + "submitter": submitter, + "date": date, + } + ) + return files + + def _submission_screen_url(self, ref_id: str, ass_id: str) -> str: + assign_url = ( + f"{self.settings.ilias_base_url}/ilias.php" + f"?baseClass=ilrepositorygui&cmdClass=ilAssignmentPresentationGUI" + f"&cmd=showOverview&ref_id={ref_id}&ass_id={ass_id}&from_overview=1" + ) + resp = self._get(assign_url, f"assignment page {ref_id}/{ass_id}") + screen_raw = self._find_url_with_ass_id( + resp.text, + r"ilias\.php\?[^'\"]*cmdClass=ilExSubmissionFileGUI&cmd=submissionScreen[^'\"]*", + ass_id, + ) + if screen_raw: + return urljoin(self.settings.ilias_base_url + "/", screen_raw) + return ( + f"{self.settings.ilias_base_url}/ilias.php" + f"?baseClass=ilrepositorygui&cmdClass=ilExSubmissionFileGUI" + f"&cmd=submissionScreen&ref_id={ref_id}&ass_id={ass_id}" + ) + + # User search + + def search_users(self, ref_id: str, ass_id: str, term: str) -> list[dict[str, str]]: + """Search ILIAS users by name fragment; returns login name + display label.""" + self.auth_service.ensure_logged_in() + ac_url = self._autocomplete_url(ref_id, ass_id) + resp = self._get(ac_url + f"&term={term}", "user autocomplete") + try: + data = resp.json() + except Exception as exc: + raise IliasExerciseError( + f"Autocomplete response not JSON: {resp.text[:200]}" + ) from exc + results = [] + for item in data.get("items", {}).values(): + results.append( + { + "login": str(item.get("value", "")), + "label": str(item.get("label", "")), + "user_id": str(item.get("id", "")), + } + ) + return results + + def _autocomplete_url(self, ref_id: str, ass_id: str) -> str: + team_url = self._team_url(ref_id, ass_id) + team_resp = self._get(team_url, f"team page {ref_id}/{ass_id}") + m = re.search( + r"ilias\.php\?[^'\"]*cmdClass=ilRepositorySearchGUI&cmd=doUserAutoComplete[^'\"]*", + team_resp.text, + ) + if m: + return urljoin(self.settings.ilias_base_url + "/", m.group(0)) + # Fallback using known pattern + return ( + f"{self.settings.ilias_base_url}/ilias.php" + f"?baseClass=ilrepositorygui&cmdClass=ilRepositorySearchGUI" + f"&cmd=doUserAutoComplete&ref_id={ref_id}&ass_id={ass_id}" + ) + + # Team management + + def list_team_members(self, ref_id: str, ass_id: str) -> list[TeamMember]: + self.auth_service.ensure_logged_in() + url = self._team_url(ref_id, ass_id) + resp = self._get(url, f"team screen {ref_id}/{ass_id}") + return self._extract_team_members(resp.text) + + def add_team_member( + self, ref_id: str, ass_id: str, username: str + ) -> dict[str, str]: + self.auth_service.ensure_logged_in() + team_url = self._team_url(ref_id, ass_id) + page_resp = self._get(team_url, f"team page {ref_id}/{ass_id}") + post_url, rtoken = self._team_post_url_and_rtoken( + page_resp.text, ref_id, ass_id + ) + + payload = { + "user_login": username, + "cmd[addUserFromAutoComplete]": "Hinzufügen", + "rtoken": rtoken, + } + resp = self.session.post( + urljoin(self.settings.ilias_base_url + "/", post_url), + data=payload, + timeout=self.settings.timeout_seconds, + allow_redirects=True, + ) + resp.raise_for_status() + + # Verify the member now appears on the team page + updated_members = self._extract_team_members(resp.text) + names = [m.name for m in updated_members] + return { + "status": "ok", + "username_added": username, + "current_team": ", ".join(names) if names else "(no members listed)", + } + + def remove_team_member( + self, ref_id: str, ass_id: str, user_id: str + ) -> dict[str, str]: + self.auth_service.ensure_logged_in() + team_url = self._team_url(ref_id, ass_id) + page_resp = self._get(team_url, f"team page {ref_id}/{ass_id}") + post_url, rtoken = self._team_post_url_and_rtoken( + page_resp.text, ref_id, ass_id + ) + + payload = { + "id[]": user_id, + "cmd[confirmRemoveTeamMember]": "Entfernen", + "rtoken": rtoken, + } + resp = self.session.post( + urljoin(self.settings.ilias_base_url + "/", post_url), + data=payload, + timeout=self.settings.timeout_seconds, + allow_redirects=True, + ) + resp.raise_for_status() + + updated_members = self._extract_team_members(resp.text) + names = [m.name for m in updated_members] + return { + "status": "ok", + "user_id_removed": user_id, + "current_team": ", ".join(names) if names else "(no members listed)", + } + + def _extract_team_members(self, html: str) -> list[TeamMember]: + soup = BeautifulSoup(html, "html.parser") + members: list[TeamMember] = [] + for inp in soup.find_all("input", {"name": "id[]"}): + user_id = str(inp.get("value", "")).strip() + if not user_id: + continue + name = "" + # Name is in the next