# Snapvisor in Codex

> Connect Codex to the Snapvisor MCP server with OAuth or a personal access token, add the Snapvisor SDK, and verify the connection with getMe.

Source: https://snapvisor.io/agent-setup/codex

Agent setup

Let Codex do visual testing end-to-end: create builds, upload screenshots, run diffs, approve or reject changes and comment, all over the Snapvisor MCP server.

## Connect Codex by hand

1. Add the Snapvisor MCP server to Codex.
  bash
  ```
  codex mcp add snapvisor --url https://mcp.snapvisor.io
  ```
2. Start the OAuth sign-in. It opens the Snapvisor consent screen in the browser, which the user approves.
  bash
  ```
  codex mcp login snapvisor
  ```

## With a personal access token instead

1. Instead of the two commands above, add this table to `~/.codex/config.toml`. Codex reads the token from `SNAPVISOR_ACCESS_TOKEN` on every start.
  toml
  ```
  [mcp_servers.snapvisor]
  url = "https://mcp.snapvisor.io"
  bearer_token_env_var = "SNAPVISOR_ACCESS_TOKEN"
  ```

Create the token with the create_api_key tool, or from Settings → Personal access tokens, keep it in your shell profile, and never commit it.

## Add the SDK

1. Only do this step inside a project that has a UI test suite; otherwise skip it and say so in the completion message. Without a test suite the project can still be tested over MCP, with no CI: for public pages, `captureScreenshotsForProject` has Snapvisor open and screenshot them itself; for anything else, screenshot the running app and push the images. Walkthrough: [https://snapvisor.io/docs/agents/visual-testing-without-ci](https://snapvisor.io/docs/agents/visual-testing-without-ci). Use the package manager the project already uses (the lockfile tells you): the commands below are written for npm.
2. Playwright (`@playwright/test` in `package.json`): install the SDK, register its reporter in `playwright.config.ts`, and capture screenshots with `argosScreenshot` in the tests that render UI.
  bash
  ```
  npm install --save-dev @snapvisor/playwright
  ```
3. The reporter uploads from CI only, so local runs stay offline:
  ts
  ```
  // playwright.config.ts
  import { defineConfig } from "@playwright/test";
  import { createArgosReporterOptions } from "@snapvisor/playwright/reporter";
  export default defineConfig({
    reporter: [
      process.env.CI ? ["dot"] : ["list"],
      [
        "@snapvisor/playwright/reporter",
        createArgosReporterOptions({ uploadToArgos: !!process.env.CI }),
      ],
    ],
  });
  ```
4. Storybook: install `@snapvisor/storybook`. Vitest browser mode: install `@snapvisor/vitest`. Then wire them as the SDK page describes.
  bash
  ```
  npm install --save-dev @snapvisor/storybook
  ```
5. Any other runner that writes screenshots to a folder: install the CLI and upload that folder after the tests run.
  bash
  ```
  npm install --save-dev @snapvisor/cli
  npx @snapvisor/cli upload ./screenshots
  ```
6. Python projects: follow the Python SDK section of [https://snapvisor.io/docs/sdks](https://snapvisor.io/docs/sdks).
7. Uploads authenticate with the project's `ARGOS_TOKEN`, found in the project's settings at [https://app.snapvisor.io](https://app.snapvisor.io). It belongs in CI secrets, never in the repository. On GitHub Actions no token is needed: [https://snapvisor.io/docs/learn/integrations/github-tokenless-authentication](https://snapvisor.io/docs/learn/integrations/github-tokenless-authentication).
8. Optional: the CLI can also inspect builds, submit reviews and post comments from the terminal. `login` opens the browser for the user to approve; `whoami` confirms it.
  bash
  ```
  npx @snapvisor/cli login
  npx @snapvisor/cli whoami
  ```

## Verify the connection

1. The `snapvisor` MCP server normally shows only two tools, `search_tools` and `execute_typescript`, and every operation is reached through them. Call `search_tools` with the query `getMe`; it answers with the declaration of `external_getMe`. Then call `execute_typescript` with this program:
  ts
  ```
  return await external_getMe({});
  ```
2. If the server instead lists `getMe` as a tool of its own, call that tool directly. Either way, success is a response naming the signed-in user and the accounts the connection can reach; each account `slug` is the `owner` argument of every other operation.
3. Most agents load MCP servers when a session starts. If no `snapvisor` tool is available to you yet, do not report failure: the completion message tells the user to restart the session and ask you to verify the connection.
4. A `401` means the browser sign-in has not been completed yet. Inside `execute_typescript` a refused call throws an error carrying the same message; wrap the call in `try`/`catch` to read it. A `QUOTA_EXCEEDED` answer means the connection works and a plan limit was reached; its `next` points at `upgrade_plan`.

## Other agents

[**Claude Code**Set up Snapvisor in Claude Code](https://snapvisor.io/agent-setup/claude-code) [**Cursor**Set up Snapvisor in Cursor](https://snapvisor.io/agent-setup/cursor) [**OpenCode**Set up Snapvisor in OpenCode](https://snapvisor.io/agent-setup/opencode) [**All agents**Credentials, other MCP clients, and the full overview](https://snapvisor.io/agent-setup)

## Related pages

Guides [How visual regression testing works](https://snapvisor.io/visual-regression-testing) [Self-hosted visual regression testing](https://snapvisor.io/self-hosted-visual-regression-testing) [Visual regression testing in GitHub pull requests](https://snapvisor.io/visual-regression-testing-github) [Snapvisor MCP server](https://snapvisor.io/mcp)

Test runner and CI setup [Playwright visual testing setup](https://snapvisor.io/playwright) [Storybook visual testing setup](https://snapvisor.io/storybook) [Cypress visual testing setup](https://snapvisor.io/cypress) [Puppeteer visual testing setup](https://snapvisor.io/puppeteer) [Visual regression testing in GitLab CI](https://snapvisor.io/gitlab-ci)

Compare Snapvisor [Snapvisor vs Percy](https://snapvisor.io/compare/percy) [Snapvisor vs Chromatic](https://snapvisor.io/compare/chromatic) [Snapvisor vs Applitools](https://snapvisor.io/compare/applitools) [Snapvisor vs Argos](https://snapvisor.io/compare/argos) [Snapvisor vs Lost Pixel](https://snapvisor.io/compare/lost-pixel) [Snapvisor vs Happo](https://snapvisor.io/compare/happo) [Snapvisor vs Playwright snapshots](https://snapvisor.io/compare/playwright) [Visual regression testing pricing compared](https://snapvisor.io/visual-regression-testing-pricing) [Alternatives to other visual testing tools](https://snapvisor.io/alternatives)

Free tools [Image diff checker](https://snapvisor.io/tools/image-diff) [Screenshot calculator](https://snapvisor.io/tools/screenshot-calculator)

Agent setup [Onboard your agent](https://snapvisor.io/agent-setup) [Set up Snapvisor in Claude Code](https://snapvisor.io/agent-setup/claude-code) [Set up Snapvisor in Cursor](https://snapvisor.io/agent-setup/cursor) [Set up Snapvisor in OpenCode](https://snapvisor.io/agent-setup/opencode)
