Bootcamp / Session 4 / 4.2

Session 4.2 · Hands-on

The agent prepares the run. You launch it.

You drive Foundry from an AI agent in VS Code: it sets up an RNA-seq run in the browser, and you check it and press Run yourself.

Go to the hands-on VS Code · Claude Code or Codex · Foundry Connect

Recording

Alper sets up an RNA-seq run on Foundry from VS Code, with Claude and Playwright driving the browser.

Alper Kucukural · 31 minutes · Download (90 MB)

Foundry in five minutes

Foundry Connect runs pipelines on the UMass HPC cluster from a web page. You pick a pipeline, point it at your files, and it runs the jobs on the cluster under your own account. If you finished the Session 1 pre-work, this is already done; check the last step and move on. That page has screenshots for each step.

Log in once

Open viafoundry.umassmed.edu and sign in.

Make an SSH key

Open the Credentials tab, choose Create Credential, pick SSH, then Generate Keys for Me.

Give the cluster the public key

Copy the public key and paste it at hpcportal.umassmed.edu/PublicKeys/Create.

Set your run environment

Open the Run Environments tab, select that SSH key, press Test Connection, then Save Changes.

Checkpoint Test Connection is green. Without it, Foundry cannot run jobs on the cluster for you.

Today’s tool: an agent in a folder

Today you work in VS Code, with Claude Code or with Codex. Either one sees the files in one folder, writes and runs scripts there, and saves what it makes next to them. That is what lets it handle files too big to paste into a chat.

It asks before it acts only in the right mode. Set it before you start:

Connect claude.ai to Foundry

Add the connector

In claude.ai, open Settings, then Connectors, then Add custom connector. Use this URL and sign in to Foundry when asked:

https://viafoundry.umassmed.edu/mcp

Check it in a chat

List my 5 most recent Foundry runs.

Claude Code signed in with the same claude.ai account usually sees this connector too. If it does not, add Foundry to Claude Code from the terminal.

VS Code

Install VS Code

Follow the steps in 2.0 if you do not have it yet.

Add the extensions

Open Extensions in the left bar and install Claude Code for VS Code (Anthropic) or Codex (OpenAI), or both.

Make the RNA-Seq folder and open it

Today’s work goes in Documents/bootcamp/session4/RNA-Seq, next to the notebooks from 4.0. Make it in Terminal (macOS) or PowerShell (Windows):

macOS:

mkdir -p ~/Documents/bootcamp/session4/RNA-Seq

Windows PowerShell:

New-Item -ItemType Directory -Force (Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'bootcamp\session4\RNA-Seq') | Out-Null

Then in VS Code choose File, Open Folder, go to Documents, bootcamp, session4, select RNA-Seq, and open it. From now on the VS Code terminal starts in this folder, and the agent works and saves its files here.

Trust the folder

Accept the trust prompt. If you missed it, open Manage (the gear), then Workspace Trust.

A five-minute tour

The Explorer lists the files in the folder. The editor opens them. Terminal, New Terminal opens a terminal already inside the folder: PowerShell on Windows, the usual Terminal shell on macOS. The Claude or Codex panel is where you type prompts. When the agent proposes an edit you see the change and accept or reject it; when it wants to run a command or call Foundry it asks first.

Check uv and Python

The agent runs its Python scripts with uv, which you set up in 4.0. In the VS Code terminal, on macOS or Windows:

uv run python --version

Checkpoint It prints a Python version, such as Python 3.13.7. If it says uv is not found or not recognized, quit VS Code completely and open it again. Still not found? Do the Install uv and Python step in 4.0, then come back.

If an install fails, fix it with the agent

Errors during installs are normal, and the agent is good at reading them. Select the whole error in the terminal, copy it, and paste it into the agent panel inside this prompt, replacing the two lines in angle brackets:

I ran this command in a terminal on my computer: <paste the command> It failed with this error: <paste the full error> Tell me which operating system and terminal you think I am using, explain in plain words what went wrong, and suggest the smallest fix. Do not run anything until I say yes.
  • Paste the whole error, not just the last line. The cause is often near the top.
  • Before you paste, delete anything that looks like a password or access token.
  • Read the fix before you allow it. If it needs admin rights (sudo on macOS, Run as administrator on Windows), stop and ask an instructor.
  • Still stuck after two tries? Raise your hand. Then try the next step: most of today still works while one install is broken.

Claude Code only: add Foundry if it is missing

Claude Code signed in with your claude.ai account usually sees Foundry already. In the Claude panel, type /mcp. If Foundry is not in the list, or it is not connected, add it from the terminal.

This needs the claude command. If you set it up in 3.0, skip ahead. Otherwise install it first:

macOS:

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Then, in a new VS Code terminal, on either system:

claude mcp add --transport http --scope user foundry https://viafoundry.umassmed.edu/mcp

--scope user makes Foundry available in every folder, not only this one. Now sign in: in the Claude panel, type /mcp, choose foundry, then Authenticate, and sign in to Foundry in the browser window that opens. Not in the list yet? Start a new conversation in the Claude panel, or reload VS Code, and type /mcp again.

Codex only: add Foundry to Codex

This needs the codex command. If you set it up in 3.0, skip ahead. Otherwise install it first:

macOS:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Windows PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

Or ask the agent in the Codex panel:

Check whether the codex command works in a terminal. If it does not, install the Codex CLI with OpenAI's official installer for my operating system (install.sh on macOS, install.ps1 in PowerShell on Windows, both from chatgpt.com/codex), then run codex --version.

Codex keeps its own list of servers. In a new VS Code terminal, add Foundry, then sign in to it in the browser window that opens:

codex mcp add foundry --url https://viafoundry.umassmed.edu/mcp
codex mcp login foundry

Check Foundry from VS Code

In the Claude panel, type /mcp. In Codex, open its MCP server list.

Checkpoint Foundry Connect shows as connected. This is where the next section runs, so check it here, not only in claude.ai.

Add Playwright

Playwright lets the agent open web pages in a browser window you can watch, click and type in them, and take screenshots. The next section uses it to set up a Foundry run.

The easy way: ask the agent. In the Claude or Codex panel in VS Code:

Help me add the Playwright MCP server (@playwright/mcp from Microsoft) to this agent on my computer. First tell me which operating system and which agent you think I am using. Check whether Node.js is installed; if it is not, tell me how to install the LTS version and stop there. Then show me the exact command to add Playwright and run it only after I say yes. Finally, tell me how to check that it is connected.

Using the Claude desktop app instead of VS Code? Ask the same in a chat there, and say “the Claude desktop app”. It cannot run the commands for you, so it walks you through them.

Or do it by hand. Playwright needs Node.js. Check whether you have it, in a terminal:

node --version

No version number? Download the LTS installer from nodejs.org and run it, then quit VS Code (or the Claude app) completely and open it again. The installer may ask for your computer’s password; if you do not have admin rights, ask an instructor.

Then add Playwright to your agent. Claude Code in VS Code, on macOS:

claude mcp add playwright -- npx @playwright/mcp@latest

Claude Code in VS Code, on Windows PowerShell:

claude mcp add playwright -- cmd /c npx @playwright/mcp@latest

Codex, on either system:

codex mcp add playwright -- npx @playwright/mcp@latest

Claude desktop app: open Settings, then Developer, then Edit Config. Put this in the file that opens, save it, and quit and reopen the app:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

If the file already has an mcpServers section, add only the playwright entry inside it. In VS Code, close and reopen the agent panel, then check its server list as in the step above.

Checkpoint playwright shows as connected next to Foundry Connect. It opens Google Chrome; if you have no Chrome, ask the agent to install the browser Playwright needs.

Hands-on: set up a run in the browser

The agent works in Foundry’s own web page, in the Playwright browser, clicking through the same forms you would. You sign in, it builds the dataset and fills in the run, and you check it and press Run. The data is six small paired-end mouse samples, three control and three experimental, so the run finishes in minutes.

Watch it first: the agent running the prompt below, without the groups, comparison and DESeq2 parts; sped up, no sound · 1 minute · Download (2 MB)

Set it up by prompt

Using the Playwright browser, open https://viafoundry.umassmed.edu and stop there so I can sign in myself. When I say I am signed in, do the following in that browser. 1. Create a dataset named bootcamp_mousetest from the paired-end files in /share/data/umw_biocore/genome_data/mousetest/mm10/gz/ on the cluster. There are six samples (control_rep1, control_rep2, control_rep3, exper_rep1, exper_rep2, exper_rep3), each with two files, <sample>.1.gz and <sample>.2.gz. 2. Work out the experimental groups from the six sample names yourself, and tell me how you decided. Then make two files in this folder: metadata.tsv with columns sample_name and group, one row per sample; and comparisons.tsv with columns controls, treats, names and one row that compares the treated group against the control group, named <treated>_vs_<control>. Show me both files. 3. Create a new RNA-seq run in a project named bootcamp_test. Create the project if it does not exist. 4. Fill in the run form: choose my own run environment, use the new dataset as the reads, set mate to pair, set the genome build to mousetest_mm10, run RSEM and Salmon, turn on FastQC, turn on sequential mapping with rRNA added as a sequence to map, and turn on DESeq2 after RSEM. 5. Stop and ask me which Execution Directory to use. Do not choose one yourself. Enter exactly the folder I give you. 6. Only after the Execution Directory is entered, attach metadata.tsv as the groups_file and comparisons.tsv as the compare_file. They cannot be attached before it. 7. Save the run, but do not press Run. Give me a clickable link to the run, save a screenshot of the run page as run_setup.png in this folder, and show me a table of everything you set.

A browser window opens on the Foundry sign-in page. Sign in there by hand, then tell the agent you are signed in. The agent never types your password, and if it asks for one, say no.

When the agent asks for the Execution Directory, give it a folder on the cluster that you can write to, such as /home/<your cluster username>/bootcamp/RNA-Seq. The run writes all its files there.

What did you observe?
  • Did the agent stop for you to sign in, stop to ask for the Execution Directory, and stop again before Run?
  • How did it decide the groups from the sample names? Open metadata.tsv and comparisons.tsv: are they right?
  • Where did it hesitate or retry? Those are the places a person would get stuck too.
  • Open run_setup.png. Does it agree with the agent’s table?

You check, you launch

Open the link and check: 6 paired-end samples, the genome build mousetest_mm10, RSEM and Salmon on, FastQC on, sequential mapping on with rRNA, the groups file and comparison file attached, DESeq2 after RSEM on, your own run environment, and the Execution Directory you gave the agent. Then press Run.

The rule The agent prepared the run. You launch it.

Advanced: get the files straight from Foundry

Optional. Once your run from the hands-on finishes, the agent can fetch its result tables with the foundry command from the Foundry SDK, which writes straight to disk at any size. Result tables are often too big for the Foundry connector, which drops the connection above a few MB. This is the route that works on your own runs after the course. It works the same on macOS and on Windows (PowerShell).

Install the SDK

In the VS Code terminal:

uv tool install https://github.com/UMMS-Biocore/foundry-sdk/archive/refs/heads/main.zip
uv tool update-shell

Close and reopen the terminal, then check:

foundry --version

No Git needed. uv, which you set up in 4.0, keeps the SDK in its own environment and puts foundry on your PATH. On Windows, if a new terminal still says foundry is not recognized, quit VS Code completely and open it again.

Or ask the agent to install it. Only the install: the login in the next step is yours to do.

Install the Foundry SDK with: uv tool install https://github.com/UMMS-Biocore/foundry-sdk/archive/refs/heads/main.zip. Then run uv tool update-shell, and check it with foundry --version. Do not run foundry configure; I will log in myself.

If a step here fails, use the troubleshooting prompt from the VS Code section.

Log the SDK in, yourself

Do this in the terminal, not through the agent:

foundry configure --hostname https://viafoundry.umassmed.edu

When it asks for a method, type 2 (Username and Password) and sign in with your Foundry username, which is your email address, and your password. The password prompt shows nothing as you type. The SDK saves your login in a file named .viaenv in your home folder.

UMass Foundry does not use a second sign-in factor yet. If it is turned on later, the SDK also asks for the 6-digit code from your authenticator app.

Check it works

foundry reports list-processes <your run ID>

The run ID is the number at the end of the run’s link, viafoundry.umassmed.edu/runs/<run ID>.

Hand it to the agent

Use the foundry command line tool to list the result files of Foundry run <your run ID>. Download rsem_summary/genes_expression_expected_count.tsv into data/rsem in this folder. Do not open or print it. Write a Python script that reads it, run it with uv, and tell me how many genes and samples it has and the total count in each sample.
Rules
  • Never paste a password or access token into a chat. If an agent asks for one, say no.
  • The SDK reads its own saved login. The agent has no reason to open .viaenv.
  • On a shared computer, delete .viaenv when you are done.

After the session

Two minutes of feedback, so the next session is pitched better. It also records your attendance, so fill it in whether you were in the room, on Zoom, or catching up on the recording.

Session 4 feedback