app_open
Open a web application in the default browser using the specified app name. Automatically serves the app if not already active, supporting single-app management.
Instructions
Open an app in the default web browser. If the app is not currently being served,
it will be served first.
Can only open one app at a time.
Args:
app_name: Name of the application to open
Returns:
A dictionary containing the result of the operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_name | Yes |
Implementation Reference
- main.py:514-582 (handler)The handler function for the 'app_open' tool. It serves the app if necessary and opens it in the default browser (preferring Chrome app mode on macOS).@mcp.tool() def app_open(app_name: str) -> Dict[str, Any]: """ Open an app in the default web browser. If the app is not currently being served, it will be served first. Can only open one app at a time. Args: app_name: Name of the application to open Returns: A dictionary containing the result of the operation """ global http_server try: # Find the app directory app_path = os.path.join(APP_DIR, app_name) if not os.path.exists(app_path): return { "success": False, "error": f"App '{app_name}' not found at {app_path}" } # If the server is not running, start it if not http_server: serve_result = app_serve(app_name) if not serve_result["success"]: return serve_result # Get the URL from the serve result url = serve_result["url"] else: # Use the current server port url = f"http://localhost:{server_port}" # Check if we're on macOS if os.uname().sysname == "Darwin": # macOS # Use Chrome in app mode chrome_path = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" if os.path.exists(chrome_path): logger.info(f"Opening app in Chrome app mode: {url}") # Use Popen instead of run to avoid blocking subprocess.Popen([chrome_path, f"--app={url}"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) else: # Fallback to default browser if Chrome is not installed logger.info(f"Chrome not found, opening in default browser: {url}") # Use Popen instead of run to avoid blocking subprocess.Popen(["open", url], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) else: # For non-macOS systems, use the default browser # Use Popen instead of run to avoid blocking subprocess.Popen(["open", url], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) return { "success": True, "app_name": app_name, "url": url, "message": f"App '{app_name}' opened in browser at {url}" } except Exception as e: logger.error(f"Error opening app: {e}") return {"success": False, "error": f"Failed to open app: {str(e)}"}
- main.py:514-514 (registration)Registration of the app_open tool using the @mcp.tool() decorator.@mcp.tool()
- main.py:102-102 (schema)Description of the app_open tool in the system instructions for the MCP server.app_open - open an app in a browser (macos)