open_URL_with_authorization
Open Moodle-protected URLs in a browser by handling authentication automatically, allowing access to course materials and resources without manual login.
Instructions
Open a URL in a new authorized browser window after Moodle login (show to user).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Target URL to open after Moodle login |
Implementation Reference
- main.py:161-182 (handler)The primary handler function for the 'open_URL_with_authorization' tool. It instantiates MUSTerClientWithHead, calls openUrl on the input URL, retrieves the current URL and page title from the Selenium driver, and returns a structured success response or error dictionary.def tool_open_URL_with_authorization(url: str) -> Dict[str, Any]: try: muster_client_with_head = MUSTerClientWithHead() driver = muster_client_with_head.openUrl(url) if driver: current_url = driver.current_url page_title = driver.title return { "success": True, "message": "URL opened successfully with Moodle authorization", "opened_url": url, "current_url": current_url, "page_title": page_title, "note": "A new browser window is now open and logged in. It will remain open until manually closed.", } else: return {"error": "Failed to open URL - driver not initialized"} except Exception as e: return {"error": f"Failed to open URL with authorization: {str(e)}"}
- main.py:68-81 (registration)Tool registration within the list_muster_tools() function, returned by the @server.list_tools() handler. Defines the tool name, description, and JSON input schema for MCP protocol compliance.Tool( name="open_URL_with_authorization", description="Open a URL in a new authorized browser window after Moodle login (show to user).", inputSchema={ "type": "object", "properties": { "url": { "type": "string", "description": "Target URL to open after Moodle login", } }, "required": ["url"], }, ),
- main.py:215-216 (registration)Dispatch routing in the @server.call_tool() handler that matches the tool name and invokes the corresponding tool handler function with parsed arguments.if name == "open_URL_with_authorization": return _wrap_json(tool_open_URL_with_authorization(args["url"]))
- MUSTerClient.py:112-117 (helper)Supporting utility method in the MUSTerClientWithHead class. Ensures the user is logged into Moodle via Selenium WebDriver (headed browser), navigates to the provided URL, and returns the driver instance for further inspection.def openUrl(self, url: str): if not self.logged_in: if not self.login(): raise Exception("Failed to login to Moodle") self.driver.get(url) return self.driver