Activity 2: Web Automation — Connect AI to Chrome

한국어 버전

Today, read just one public page

Open teacher-web-assistant from the previous lesson. Today's goal is to check that AI can read the public page you see, then disconnect afterward. Do not sign in with a school account.

Once preparation is complete, you will have a Chrome window separate from your everyday browser. It should show a page headed Example Domain. Ask AI to read that heading and compare its report with the screen.

Connecting a browser gives AI a tool that can see and interact with pages. Asking it to “only read” does not remove its ability to make changes. For this exercise, keep only the public page open and do not approve unfamiliar tool actions. Do not bypass institutional restrictions on software installation or automation.

Use Next to open a separate sample page, compare its heading, and disconnect. Check whether the heading on the left matches the reply. Unlike Example Domain in the real setup instructions, this fictional page is called “Teacher practice page”.

This is a fictional teaching simulation, not a real service screen or query. The controls do not connect to websites, create local files, send system notifications, or schedule checks.

From a separate page to disconnectionSimulated Chrome browser · Learning simulation
Fictional teacher practiceLearning simulation
https://example.invalid/public

Fictional school workspace · not a real school system

Browser status Simulated: disconnected

Separate practice window

Separate practice window
CheckValue
Open pageNone yet
OpenCode conversation
opencodeFrom a separate page to disconnectionBuild
Build · Model selection depends on your environmenttab agents
0:00 / 0:20
1 / 6

Simulated browser and OpenCode conversation. No websites, school systems, files or AI are connected. All records and notifications are fictional.

1. Ask for a practice browser

Send the following request in OpenCode. Replace Windows with macOS if appropriate, and provide the expandable setup notes below as a reference.

Read AGENTS.md first. I am a teacher, not an IT specialist.
I use Windows. Use this article's setup notes for facilitators and AI
to prepare a practice Chrome browser and its OpenCode connection.

Leave my everyday Chrome and worksheet folder alone.
Open only https://example.com/ in separate Chrome.
Do not open school websites or sign in.
Preserve my existing OpenCode settings and add only the required connection entry.
Before installing software or changing settings, briefly explain the change
and wait for my confirmation.
If you cannot perform a step, guide me through the clicks or commands one at a time.
Do not change the firewall or security policies.
When ready, tell me what to check on screen.

If AI proposes installing software, first check that your institution permits it. Do not approve a proposal to replace your entire configuration or close everyday Chrome. If your device cannot install approved tools, use an authorized practice device for the same procedure.

When the dedicated window appears, check three things: your usual tabs have not followed you, you are not signed into a school account, and the address is https://example.com/. Skip Chrome account sign-in and synchronization prompts for this exercise. Preparation must also confirm a separate profile, not merely another window with a different name.

Setup notes for facilitators and AI

Teachers do not need to memorize this section. It supplies execution steps and sources for whoever prepares the connection.

Prerequisites and profile separation

Use an approved installation of OpenCode, stable Chrome, and Node.js LTS with npm matching the official requirements. Check availability with opencode --version, node --version, npm --version, and npx --version. If commands are missing after installation, check PATH in a new terminal. If Windows script policy blocks npm launchers, use approved npm.cmd and npx.cmd without weakening the policy.

Since Chrome 136, debugging switches do not apply to the default user data directory. Use a non-default --user-data-dir as shown below. Do not copy an existing profile. If teacher-browser-profile already serves another purpose or is synchronized, choose a different approved local path. Close any earlier practice instance using this dedicated profile first. Everyday Chrome does not need to close.

Windows PowerShell

This finds common installation locations and opens dedicated Chrome. Administrator privileges are not required.

$candidates = @(
  "$env:ProgramFiles\Google\Chrome\Application\chrome.exe",
  "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe",
  "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe"
)
$chrome = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $chrome) { throw "Chrome path not found. Check the approved installation path." }
$profile = Join-Path $env:USERPROFILE "teacher-browser-profile"
Start-Process -FilePath $chrome -ArgumentList @(
  '--remote-debugging-address=127.0.0.1',
  '--remote-debugging-port=9222',
  "--user-data-dir=`"$profile`"",
  'https://example.com/'
)

For a custom installation, inspect the executable path in Chrome's shortcut properties, assign the actual path to $chrome, and use the launch portion. Quotes around the profile path preserve spaces in account names.

macOS Terminal

For the usual system-wide installation, run the following without sudo.

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --remote-debugging-address=127.0.0.1 \
  --remote-debugging-port=9222 \
  --user-data-dir="$HOME/teacher-browser-profile" \
  https://example.com/

For an installation under ~/Applications, replace the first line with "$HOME/Applications/Google Chrome.app/Contents/MacOS/Google Chrome". Check other installation locations in Finder. Leave the terminal running Chrome open and use a new tab for the next checks.

Verify the local connection

In dedicated Chrome, open chrome://version, confirm that the profile path is under teacher-browser-profile, then close that tab. Leave only the public practice page. On Windows, run:

Get-NetTCPConnection -LocalPort 9222 -State Listen |
  Select-Object LocalAddress, LocalPort, OwningProcess
Invoke-RestMethod http://127.0.0.1:9222/json/version |
  Select-Object Browser, webSocketDebuggerUrl

On macOS, run:

lsof -nP -iTCP:9222 -sTCP:LISTEN
curl --fail --silent --show-error http://127.0.0.1:9222/json/version

The listener must use loopback, such as 127.0.0.1 or ::1, and the JSON should contain Browser and webSocketDebuggerUrl. This confirms Chrome's response, not the AI connection yet. Stop and investigate if the listener uses all interfaces (0.0.0.0, *, or ::) or another process owns the port. Do not kill unrelated processes. Do not open firewalls or configure port forwarding. Do not paste debugging connection details into chat or shared documents. Loopback does not fully isolate the browser from other programs on the same computer.

Configure OpenCode

If teacher-web-assistant/opencode.json exists, keep a safe local copy and preserve existing settings. Merge only the following chrome-devtools entry under mcp. Edit an existing entry with that name rather than creating a duplicate key. Use this complete example unchanged only for a new configuration file.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "chrome-devtools": {
      "type": "local",
      "command": [
        "npx",
        "-y",
        "chrome-devtools-mcp@latest",
        "--browser-url=http://127.0.0.1:9222",
        "--no-usage-statistics",
        "--no-performance-crux"
      ],
      "enabled": true
    }
  }
}

The OpenCode format places the executable and arguments together in command. The type is local; do not configure Chrome's HTTP address as a remote MCP server. If Windows cannot resolve npx, check installation and PATH, then use npx.cmd or an approved executable path as the first entry if needed.

-y automatically accepts package installation and @latest retrieves the latest package, so establish installation permission first. A slow first download may exceed the connection timeout. Inspect installation progress and errors rather than retrying blindly.

According to the official options, the last two flags disable MCP usage statistics and sending performance-trace URLs to CrUX. They do not block page text or screenshots from reaching the model, or disable all Chrome browser metrics. They do not enforce read-only access either. Apply tool permissions separately according to institutional policy.

Save the configuration, end the OpenCode session, and restart it in this workspace. Check the MCP status for chrome-devtools. If it fails, investigate Chrome's port response, package execution, then OpenCode configuration. Do not bypass security warnings or institutional restrictions.

2. Ask AI to read the page heading

If setup asks you to restart OpenCode, end the current conversation and start again in the same teacher-web-assistant folder. Leave dedicated Chrome open. Then send this request.

Read AGENTS.md first. This task is limited to the public practice page.
Use the connected browser tool to check the tabs.
If example.com is absent or an unexpected tab is present, stop without reading its content.
Actually inspect the title, address, and first heading of https://example.com/.
Do not click, type, sign in, download, or navigate elsewhere.
Write the observation time and results in outputs/browser-check.md.
If the tool connection fails, report failure instead of answering with a title you already know.

If AI reports Example Domain, compare it with the dedicated browser. OpenCode must also show an actual browser tool call and response. AI may already know this page's title, so a correct answer alone does not prove a connection.

Open outputs/browser-check.md and inspect the observation time and results. “Unable to check” is the right outcome if the connection failed. If unfamiliar tabs appear, stop further reading and return to preparation.

3. Practice disconnecting too

Once the heading is read, today's browsing task is finished. Request shutdown guidance.

I am ending today's practice. Disable only this workspace's browser connection.
Leave everyday Chrome and other settings unchanged.
After I exit OpenCode and close dedicated Chrome, guide me through checking
that browser control is no longer available.
Do not claim the running connection is closed just because a setting was saved.

Exit the OpenCode session and close all dedicated Chrome windows only. Leave your everyday browser alone. Ask the person helping with setup, or use the following commands, to confirm shutdown.

Shutdown checks for facilitators and AI

Save "enabled": false for this MCP entry and exit the running OpenCode session. End any other sessions connected to the same browser. Editing the file alone does not necessarily disconnect a running session.

After closing dedicated Chrome, repeat the port-check commands above. There should be no listener on 9222, and the /json/version request should fail to connect. At this stage, connection failure is evidence of shutdown. If the directly launched macOS Chrome process remains in its terminal, terminate that instance with Control-C. If the port remains open, inspect the owning process and path and terminate only the dedicated Chrome you started. Do not indiscriminately terminate all Chrome processes.

For the next exercise, start dedicated Chrome again and re-enable MCP. Keep its profile outside the project folder; never share it or commit it to a repository. Closing a window is not deleting the profile or signing out of websites.

Even when the browser connection stays on your computer, page content may reach your external AI service. Today's page was public. Real work sites require institutional permission for both automation and AI data processing. Before signing in, disable the browser connection and exit OpenCode; the teacher then authenticates manually. Reconnect only after closing authentication screens and confirming that only the permitted work page remains. Never put authentication information in chat.

Once you have confirmed both the public-page observation and disconnection, this exercise is complete. In Find and Summarize Requested Official Documents, the teacher will define a search scope and inspect the results.

References

💬 댓글

이 글에 대한 의견을 남겨주세요