Install OrgSDK and open a local project
This walkthrough uses OrgSDK 2.7.0 on Linux with Node.js 22.22.0 or newer. Start OrgSDK with its local runner. Open OrgSDK Studio, choose Allow local connections, then create a workspace and select a project.
You’ll connect two tools over MCP. Your AI client connects to the OrgSDK workspace. The project runner connects to a separate Playwright MCP process on the same machine.
Start a dedicated Playwright MCP server
With your OrgSDK project runner on the same machine, set CHROME_BIN to the absolute path of your Chrome or Chromium executable. 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.
# Start a browser that your local OrgSDK project can use.
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.
// Use the test page address supplied to this run.
const target = String(actionParams.url);
// Keep this helper for the next step in the same session.
const inspect = (code: string) =>
playwright.browserRunCodeUnsafe({ code });
// Open the test page and return the title from its browser tab.
return await inspect(`async (page) => {
await page.goto(${JSON.stringify(target)});
return await page.title();
}`);// Read the first heading on the page you just opened.
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.
// Ask for the address of the page you want to check.
const { url } = defineParams(z.object({ url: z.string().url() }));
// Open the page and read its first heading.
const code = `async (page) => {
await page.goto(${JSON.stringify(url)});
return await page.getByRole("heading").first().innerText();
}`;
// Run those steps in the connected browser.
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.
# Look for a 301 response and the new address in Location.
curl -sSI 'https://www.orgsdk.ai/learn/playwright-mcp-orgsdk?ref=check'
# Check which URL the page names as its main address.
curl -fsS 'https://orgsdk.ai/learn/playwright-mcp-orgsdk' | grep -o '<link rel="canonical"[^>]*>'
# Find the same page in the list that search engines read.
curl -fsS 'https://orgsdk.ai/sitemap.xml' | grep '/learn/playwright-mcp-orgsdk<'