Install OrgSDK 0.2.0 and start a project
On Linux with Node.js 22.22.0 or newer, install the OrgSDK CLI and start it in a directory where you want to keep the lab. The CLI starts the application and its local project runner together.
Open http://127.0.0.1:8080, complete workspace setup and select your project. Keep OrgSDK running while you connect Playwright. If your project uses an independently managed runner, install the matching executor archive on its host.
npm install -g https://github.com/OrgSDK/OrgSDK/releases/download/v0.2.0/orgsdk-cli-0.2.0.tgz
orgsdk start --host 127.0.0.1 --port 8080 --data "$PWD/.runtime/browser-lab"Start a dedicated Playwright MCP server
Run Playwright on the same machine as your local project runner. Set CHROME_BIN to the absolute path of your Chrome or Chromium executable, then start the pinned Playwright MCP version in a separate terminal.
The shared browser context keeps the same browser state when OrgSDK opens a new MCP connection. Use one dedicated profile and endpoint per project. Keep the listener on loopback and reserve it for trusted clients and code. The browser code tool can execute with the Playwright server process’s privileges.
npx --yes --package=@playwright/mcp@0.0.86 playwright-mcp \
--host 127.0.0.1 --port 8931 --headless \
--executable-path "$CHROME_BIN" \
--user-data-dir "$PWD/.runtime/playwright-profile" \
--shared-browser-contextConnect the server and review its tools
As a project administrator, open Plugins and find Connect MCP server. Set Connection name to playwright, Server URL to http://127.0.0.1:8931/mcp and Authentication to No authentication for this local process. The endpoint must be reachable from the project runner. Loopback on a different host or inside a container refers to that host or container.
Choose Check connection / refresh tools. Discovery lists the tools. Under Review available tools, examine the input schema for browser_run_code_unsafe, then select it and choose Enable selected tools. Enable only the tools this project needs. With the connection name above, the project SDK exposes the tool as playwright.browserRunCodeUnsafe({ code }).
Connect your external AI client to the OrgSDK workspace endpoint ending in /mcp/ and use a project-scoped bearer token. Grant catalog:read, code:execute and runs:read for discovery and iteration. Add actions:write, actions:test and actions:run for authoring, testing and replay. Ask the client to call list_projects and get_project_sdk to confirm the project ID and approved alias.
Keep one page open across two code cells
Call open_session with the project ID and a fresh idempotency_key. Poll get_run({ id }) with the returned run ID. Read the session ID, generation and sequence from output.result when the run succeeds.
Send the first example as the source for execute_cell. Include project, session_id, generation, expected_sequence, a fresh UUID for cell_id, and an idempotency_key. Pass inputs.url for a test page you control with a visible heading. Poll get_run and check output.result.cell.status before using its result.
Send the second example with a new cell_id and idempotency_key, using the first cell’s returned sequence as expected_sequence. It reuses the helper and the live page from the first cell. After exploring, call close_session with project, session_id and an idempotency_key, then poll its run to completion.
const target = String(actionParams.url);
const inspect = (code: string) => playwright.browserRunCodeUnsafe({ code });
return await inspect(`async (page) => {
await page.goto(${JSON.stringify(target)});
return await page.title();
}`);return await inspect(
'async (page) => await page.getByRole("heading").first().innerText()'
);Save and test a self-contained action
Give the saved action its own navigation step and accept the destination as an input. It can then run on a fresh page after the discovery session has closed. The example reads the first visible heading and returns the Playwright MCP response envelope.
Validate the source with validate_code. Save it with save_action using project, name, source and an input_schema that requires url. Use the returned action ID and version number with save_tests. Mock playwright.browserRunCodeUnsafe with the exact argument object and expected response envelope, then call run_tests with that suite_revision and a fresh idempotency_key.
For each live replay, call run_action with project, action, version, inputs and a new idempotency_key. Check the completed result with get_run. Use two different URLs on test pages you control and verify each expected heading.
const { url } = defineParams(z.object({ url: z.url() }));
const code = `async (page) => {
await page.goto(${JSON.stringify(url)});
return await page.getByRole("heading").first().innerText();
}`;
return await playwright.browserRunCodeUnsafe({ code });Check a canonical redirect with an HTTP client
Use Playwright to inspect the final rendered page and its canonical link. To verify the redirect itself, send a request without following redirects. Check the status and Location on the first response, then fetch the canonical URL and check that it serves the expected content. Confirm that sitemap.xml lists the apex URL.
For this guide, the www request should return HTTP 301 to the apex on the same path, preserving ref. The apex HTML should point to the clean, query-free canonical URL.
curl -sSI 'https://www.orgsdk.ai/learn/playwright-mcp-orgsdk?ref=check'
curl -fsS 'https://orgsdk.ai/learn/playwright-mcp-orgsdk' | grep -o '<link rel="canonical"[^>]*>'
curl -fsS 'https://orgsdk.ai/sitemap.xml' | grep '/learn/playwright-mcp-orgsdk<'