Start with a test profile#
CDP lets a tool connect to a running Chromium instance. Its existing context contains the profile’s storage: creating another context in your script is not the same as using the session you prepared. Start on your own test page or an example page, without purchases or production changes.
In Mantis, API and CDP require Pro or Max. Keep the app open and signed in on the script’s PC. Use GET /v1/perfiles to obtain the ID and POST /v1/perfiles/:id/start to start the profile; use automation.wsEndpoint from the response instead of rebuilding it from a port.
Example using Playwright and the Mantis API#
Install requests and playwright in your Python environment. Replace the example ID with a test profile’s ID. The script opens an example.com tab, prints its title and requests profile shutdown afterward, even if navigation fails.
import requests
from playwright.sync_api import sync_playwright
API = "http://127.0.0.1:3848/v1"
PROFILE_ID = "REPLACE_WITH_PROFILE_ID"
def request(method, path):
result = requests.request(method, API + path, timeout=120)
result.raise_for_status()
return result
started = request("POST", f"/perfiles/{PROFILE_ID}/start").json()
try:
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(started["automation"]["wsEndpoint"])
context = browser.contexts[0]
page = context.new_page()
page.goto("https://example.com")
print(page.title())
page.close()
finally:
request("POST", f"/perfiles/{PROFILE_ID}/stop")Puppeteer: disconnecting does not stop the profile#
import puppeteer from "puppeteer-core";
// Set WS_ENDPOINT to automation.wsEndpoint from the start response.
const endpoint = process.env.WS_ENDPOINT;
if (!endpoint) throw new Error("WS_ENDPOINT is required");
const browser = await puppeteer.connect({ browserWSEndpoint: endpoint });
try {
const page = await browser.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await page.close();
} finally {
browser.disconnect();
}Install puppeteer-core. This second example only disconnects Puppeteer; call /stop afterward if you want to close the profile. The Puppeteer reference documents connect. Playwright notes CDP limitations compared with its own protocol.
Three errors to isolate#
- Connection refused: confirm the profile is still open and you are using that launch’s endpoint.
- Missing session: check the reused context and whether the site revoked authentication.
- Interfering tasks: avoid two scripts modifying the same profile simultaneously; limit concurrency for your PC.
These examples describe the integration, not compatibility with every website or version. The automation manual covers the full workflow. Do not publish token-bearing endpoints or expose the local API to the Internet.