antigravity-with-chatgpt
Provides a bridge to ChatGPT Web, enabling delegation of reasoning, planning, review, derivation, and diagnostic tasks from a local agent to OpenAI's models (GPT-4o, o1, o3) via a Chrome DevTools Protocol.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@antigravity-with-chatgptreview my latest git diff and flag any issues"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ antigravity-with-chatgpt
Zero-Dependency Dual-Brain Reasoning & Verification Architecture for Google Antigravity 2.0 & Gemini
Harness the full reasoning and deep-thinking capabilities available in your authenticated ChatGPT Web account as an independent cloud brain for your local Antigravity 2.0 IDE.
โก One-Sentence AI Installation (ไธๅฅ่ฏ่ฎฉ AI ๅธฎๅฟๅฎ่ฃ )
You don't even need to open a terminal or run shell commands manually. Simply copy and paste this single sentence into your Google Antigravity 2.0 / Gemini / Claude Code chat box:
Set up antigravity-with-chatgpt for me: clone https://github.com/dreamfarer-space/antigravity-with-chatgpt.git and run node scripts/setup.mjs to configure the environment and verify.
Your AI Agent will handle the entire installation automatically:
๐ ๏ธ Clone & Inspect: Clones the repository and verifies the Node.js (>= 22) and Chrome environment;
๐ Register Native MCP Server: Automatically updates
~/.gemini/config/mcp_config.json;๐ Mount Global Antigravity Skill: Creates the skill junction in
~/.gemini/config/skills/antigravity-with-chatgpt;๐ฅ๏ธ Generate Dedicated Chrome Shortcut: Creates a desktop launcher with isolated profile and port
9222;โ Run Full Self-Checks: Runs the 117-case adversarial test suite plus the 37-point environment self-check to ensure 100% readiness.
After setup, double-click the "ChatGPT (Antigravityๆบ่)" desktop shortcut to log in to your ChatGPT Web account once, and you can immediately delegate deep reasoning and adversarial code reviews to ChatGPT from within Antigravity 2.0!
(Manual terminal alternative: git clone https://github.com/dreamfarer-space/antigravity-with-chatgpt.git && cd antigravity-with-chatgpt && node scripts/setup.mjs)
Related MCP server: cdp-tools-mcp
๐ Background & Design Philosophy
When developing with modern agentic coding assistants, local agents like Google Antigravity 2.0 IDE, Gemini CLI, and Claude Code have deep local authority (file I/O, terminal execution, running tests, Git version control). However, when tackling complex architectural refactoring, algorithmic derivation, subtle root-cause debugging, or rigorous code reviews, a single model within a shared context often suffers from confirmation bias and self-rationalizing hallucinations.
Inspired by the notable community project XiaoDuoYa/codex-with-chatgpt ("ChatGPT thinks. Codex works.") and shaped by ChatGPT's rigorous 38-point architectural code review, antigravity-with-chatgpt establishes a robust Proxy-Pull Context Broker pattern:
Local Agent Owns Execution: File edits, shell terminal commands, build pipelines, and unit tests strictly belong to Antigravity.
ChatGPT Owns Reasoning & Review: High-level task planning, mathematical derivations, and adversarial code reviews are delegated to ChatGPT Web.
Local Session Reuse: Connects directly to your authenticated browser session (Free, Plus, or Pro) running in an isolated local Chrome profileโno separate API key required, operating strictly within standard personal web session parameters.
Zero npm Dependencies: Written entirely in native Node.js 22+ standard library (native WebSocket, fetch, crypto, child_process)โlightning fast startup, zero third-party npm runtime dependency surface.
๐ Key Features
โก Millisecond-Scale DOM Injection: Utilizes
execCommand('insertText')combined with Base64 encoding to bypass ProseMirror per-character event overhead, injecting 10,000+ characters in under 5ms.๐ก๏ธ Defense-in-Depth Local Security Boundary:
path_guard.mjs: Platform-aware relative path containment, strictly preventing../traversal, NUL byte injection, and symlink breakout.sensitive.mjs: Blocks.env*, SSH keys, and certificates; automatically redacts OpenAI API keys, GitHub tokens, AWS credentials, and Bearer tokens.Egress Sanitization: Ensures every character crossing the browser boundaryโincluding Git diffs and execution test outputโpasses through an ultimate redaction filter.
๐ Closed-Loop Independent Verification:
Automatically captures budgeted
git diffoutputs and persistent test execution records.Anti-flattery enforcement: Without empirical execution evidence, ChatGPT will actively refuse blind approval and issue an actionable
[CHANGES REQUESTED]report.
๐ Single-Flight Concurrency Mutex:
Built-in
AsyncMutexserializes concurrent MCP requests targeting the same Chrome tab, preventing prompt interleaving and signal crossing.
๐ฏ Five Specialized Operational Modes:
ask: Everyday technical questions and conversational reasoning.plan: Structured planning with RATIONALE, ACTIONS, RISKS, and CRITERIA.review: Closed-loop verification of real Git diffs and execution evidence.derive: Pure mathematical and algorithmic derivation (code files isolated to eliminate noise).diagnose: Root-cause failure analysis with minimal reproduction steps.
โณ Long-Reply Polling & Host-Timeout Guard:
MCP calls clamp the wait window to 150s by default, hard-capped at 165sโsafely inside Antigravity's 180s host watchdog, so a long reasoning turn is never hard-killed mid-flight.
When ChatGPT is still streaming, the bridge returns
[STATUS: IN_PROGRESS]along with resumption credentials (expectedTurn+conversationUrl) instead of failing. Resume withfetch_chatgpt_responseโno prompt re-injection, no overwriting the in-flight answer.One absolute deadline, threaded end-to-end: the deadline is anchored at the MCP boundary and passed down through the orchestrator into every transport wait (Chrome readiness, CDP connect, probes, quiet window, text reads). Downstream layers never re-anchor a fresh relative timeout and never
Math.max()extra timeโonce the budget is exhausted, zero further CDP calls are issued.
๐ Single Authorized Workspace Root:
The MCP server / CLI pins the authorized workspace root at startup (
CHATGPT_BRAIN_WORKSPACEor the process cwd, realpath-normalized).Every tool call's
workspacemust equal that root or live strictly inside it; anything else fails closed without ever reaching the orchestration layer.Policy root โ workspace root: a subdirectory workspace (monorepo/subproject) is allowed, but
.brainignoreand sensitive-file rules are always anchored to the authorized root and accumulated parent โ child (restrictions can only be added, never weakened)โso pointingworkspaceatproject/secretscan no longer disable a parentsecrets/**rule. Filesystem roots (/,D://), the user home, system and temp roots are rejected outrightโeven in library mode.Rationale: a path sandbox only protects the root the caller hands in. Letting a (possibly prompt-injected) agent pick
C://orHOMEreduces every containment check to theatre.
๐งฑ One File-Authorization Choke Point:
All content that may cross the browser boundary goes through
authorizeCanonicalFile(): workspace authorization + lexical containment + symlink-escape check + dual (lexical and realpath) sensitive-name and.brainignorepolicy.Closes three bypasses: untracked
alias.txt -> .envsymlinks, tracked Git diffs (now filtered per file viagit diff --name-status -z, renames validated on both ends), andsearchWorkspace(ripgrep via--json,git grepvia-z, so Windows drive letters and C-quoted/escaped non-ASCII filenames can no longer mis-parse the path).Excluded files never produce diff headers or contentโonly an auditable
[DIFF FILTERED: โฆ]notice.
๐ Two-Level Concurrency Control:
In-process
AsyncMutexserializes every operation and gives up waiting once the deadline passesโand only reports lock contention when there really is contention.A cross-process file lock (
<chrome-profile>/.chatgpt-bridge.lock) covers what the in-process mutex cannot: the Antigravity MCP server and a terminal CLI are separate processes, and injecting into the same tab from both interleaves prompts. Acquisition is atomic (O_EXCL), release is ownership-checked (pid + startedAt), stale locks are reclaimed (dead holder or >10 min), and waiting honours the deadline.
๐งญ Conversation Identity Guard (State Machine):
Conversation URLs are canonicalized (scheme + host + path, query/hash stripped) and tracked as
UNBOUND_ROOT โ PINNED(/c/<id>). The first concrete/c/<id>observed is pinned permanently; from then on comparison is strict.This closes the dangerous
/ โ /c/A โ /c/Bhole: a root URL can never act as a permanent wildcard, and any mid-generation cross-conversation navigation fails closed instead of returning another chat's content.Resumption credentials are upgraded to the pinned identityโa request that started at
/returns/c/A, never/.Temporary identities are not identities: right after submitting a brand-new chat, ChatGPT briefly sits on the client-side
/c/WEB:<uuid>address before swapping in the server-assigned/c/<uuid>. That form is never pinned and never used as a credential, so the normalWEB:<uuid> โ <uuid>transition is not mis-flagged as a hijack.Multi-tab fetch selects the tab by exact canonical conversation identity rather than "first ChatGPT tab, then hope the URL guard passes".
๐๏ธ Four-Layer Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Antigravity 2.0 / Gemini โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ JSON-RPC 2.0 stdio / CLI
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. Access Layer (scripts/) โ
โ - ask_chatgpt.mjs: Thin, expressive CLI entrypoint โ
โ - mcp_server.mjs: Antigravity 2.0 Native MCP Server โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 2. Orchestration & Protocol (src/brain/) โ
โ - orchestrator.mjs: Proxy-Pull Context Broker โ
โ - prompts.mjs: [ANTIGRAVITY-BRIDGE/1] 5 Mode Envelopesโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 3. Security & Evidence Layer (src/security/, workspace/)โ
โ - path_guard.mjs: Canonical Realpath Traversal Guard โ
โ - sensitive.mjs: Secret Redaction & .env Blocking โ
โ - ignore.mjs: .brainignore Rule Parser โ
โ - context_provider.mjs: Safe Read-Only Slicing โ
โ - git_helper.mjs: Read-Only Budgeted Git Diff โ
โ - recorder.mjs: Execution Evidence Recorder โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 4. Transport Layer (src/transport/) โ
โ - cdp_transport.mjs: Native CDP Driver (Port 9222) โ
โ * AsyncMutex single-flight serialization โ
โ * Base64 fast ProseMirror text injection โ
โ * Double-hash multi-sampling + MutationObserver โ
โ * Absolute deadline + in-progress (IN_PROGRESS) โ
โ resumption via fetch_chatgpt_response โ
โ * Conversation identity re-validation (fail-closed)โ
โ * Stale-socket decoupling on reconnect (guarded) โ
โ * Cross-process lock + deadline-aware mutex โ
โ * Event-driven WebSocket lifecycle & cleanup โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Chrome DevTools Protocol
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Dedicated Chrome Profile (127.0.0.1:9222) โ
โ โโโ ChatGPT Web UI (https://chatgpt.com/) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐ ๏ธ Configuring MCP in Antigravity 2.0
Google Antigravity 2.0 natively integrates external tools via the standard Model Context Protocol (MCP).
Step 1: Prerequisites
Node.js:
>= 22.0.0(uses global nativeWebSocketandfetchโno npm install needed).Google Chrome: Standard desktop installation.
Step 2: Start the Dedicated Chrome Session
To keep your daily browser data separate, launch Chrome with an isolated user profile (~/.antigravity-with-chatgpt/chrome-profile or custom directory) and local CDP remote debugging on port 9222:
Windows PowerShell:
& "C:\Program Files\Google\Chrome\Application\chrome.exe" `
--remote-debugging-port=9222 `
--remote-debugging-address=127.0.0.1 `
--remote-allow-origins=* `
--user-data-dir="$HOME\.antigravity-with-chatgpt\chrome-profile" `
https://chatgpt.commacOS Terminal:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--remote-debugging-address=127.0.0.1 \
--remote-allow-origins=* \
--user-data-dir="$HOME/.antigravity-with-chatgpt/chrome-profile" \
https://chatgpt.comLinux Bash:
google-chrome \
--remote-debugging-port=9222 \
--remote-debugging-address=127.0.0.1 \
--remote-allow-origins=* \
--user-data-dir="$HOME/.antigravity-with-chatgpt/chrome-profile" \
https://chatgpt.comTip: On first launch, log in to your ChatGPT account once. Your session cookies will be stored in your dedicated local Chrome profile, minimizing repeated logins across restarts (subject to normal OpenAI session lifetimes).
[!NOTE] Why
--remote-allow-origins=*is required: Starting in Chrome 111, Chromium enforces strict WebSocket Origin validation on DevTools endpoints (/devtools/...). Non-browser processes (such as Node.js WebSocket clients) do not send standard browser origins, causing Chrome to reject the connection with HTTP 403 Forbidden without this flag.Security Boundary: The debug socket binds strictly to
--remote-debugging-address=127.0.0.1(loopback only). Because it is not exposed on any external network interface, remote connections from the local network or internet are blocked at the OS socket level.
Step 3: Configure Antigravity 2.0 Global MCP Config
Edit your global MCP configuration file:
Windows:
C:\Users\<YourUsername>\.gemini\config\mcp_config.jsonLinux/macOS:
~/.gemini/config/mcp_config.json
Add antigravity-with-chatgpt under mcpServers:
{
"mcpServers": {
"antigravity-with-chatgpt": {
"command": "node",
"args": [
"D:\\ChatGPT-Brain-Bridge\\gemini-skill\\antigravity-with-chatgpt\\scripts\\mcp_server.mjs"
]
}
}
}Note: Update the path to match where you cloned the repository. Remember to use double backslashes
\\on Windows.
Step 4: Verification in Antigravity 2.0
Restart Antigravity 2.0. The agent will discover the tools automatically. You can instruct the agent naturally:
"Please ask ChatGPT in plan mode to design a high-throughput message queue architecture for this service."Antigravity will dispatch the MCP tool call:
{
"name": "ask_chatgpt",
"arguments": {
"mode": "plan",
"prompt": "Design a high-throughput message queue architecture"
}
}๐ป CLI Usage
You can also interact with the bridge directly from your terminal:
# 1. Ask a question (reuses active web session)
node scripts/ask_chatgpt.mjs "Explain the differences between Linux epoll LT and ET modes"
# 2. Start a fresh conversation (--new)
node scripts/ask_chatgpt.mjs --new "Evaluate Raft vs Paxos for distributed consensus"
# 3. Architectural Planning Mode (--plan)
node scripts/ask_chatgpt.mjs --plan "Refactor the authentication module to stateless JWT"
# 4. Closed-Loop Review Mode (--review, auto-injects real Git Diff & test evidence)
node scripts/ask_chatgpt.mjs --review "Review recent changes for security regressions"
# 5. Algorithmic Derivation Mode (--derive, noise-free math reasoning)
node scripts/ask_chatgpt.mjs --derive "Derive the variance formula for consistent hashing virtual nodes"
# 6. Root-Cause Diagnostics (--diagnose)
node scripts/ask_chatgpt.mjs --diagnose "Analyze ECONNRESET errors during test execution"
# 7. Attach Local Source Files (--attach, with automatic path guard & secret redaction)
node scripts/ask_chatgpt.mjs --attach src/auth.ts src/server.ts "Analyze thread-safety"
# 8. Run Environment Doctor (--doctor)
node scripts/ask_chatgpt.mjs --doctor
# 9. Poll a long-running reply (--fetch / --poll, no prompt re-injection)
node scripts/ask_chatgpt.mjs --fetch
node scripts/ask_chatgpt.mjs --fetch --jsonโณ Long-Reply Polling & Host-Timeout Guard
Deep reasoning turns can easily run past an MCP host's per-call watchdog (Antigravity aborts a tool call after 3 minutes). Instead of being hard-killed mid-generation, the bridge degrades gracefully:
ask_chatgpt(prompt, timeout: 150)
โ
โโโ reply finished in time โโโโโโโโโโโบ final answer text
โ
โโโ still streaming at the deadline โโบ [STATUS: IN_PROGRESS]
+ expectedTurn
+ conversationUrl
โ
fetch_chatgpt_response โโโโ
(repeat until the answer is stable)Wait window clamping:
timeoutdefaults to 150s and is hard-clamped to 165s for bothask_chatgptandfetch_chatgpt_response, staying inside the host watchdog.Never resubmit: on
IN_PROGRESSthe prompt is already injected and generating. Callfetch_chatgpt_responsewith the returned credentialsโresubmitting the full prompt can overwrite or interleave the in-flight answer.Resumption credentials:
targetId(opaque Chrome target identity, always available and preferred),expectedTurn(minimum assistant turn index, prevents turn crossover) andconversationUrl(canonicalized conversation identity, only returned once a durable/c/<id>existsโit isnullon root/ephemeral identities rather than a fake value). All optional, but strongly recommended when more than one ChatGPT tab is open.Partial text:
IN_PROGRESSresponses include the last ~400 characters already captured, so agents can stream progress to the user while waiting.safeTimeoutsemantics: the defaultsafeTimeout: truereturnsIN_PROGRESS(exit code0) rather than throwing on timeout. SetsafeTimeout: falseto get a hard failure instead.
๐งฐ MCP Tool Reference
Tool | Description | Key Parameters |
| Delegates complex reasoning, planning, or review to ChatGPT Web |
|
| Resumes / polls the latest reply in the bound conversationโno prompt re-injection |
|
| Fetches paginated real Git diff slices with strict byte budgets |
|
| Safely reads local code files under path sandbox and budget limits |
|
| Probes Chrome CDP 9222 connectivity and workspace readiness |
|
| Stores command execution and test results for closed-loop review |
|
๐งช Testing & Verification
The project includes both an automated cross-platform test suite for continuous integration and an environment verification suite for local setup:
1. Automated CI Test Suite (npm test)
Executed automatically in GitHub Actions on every push and pull request across Ubuntu, Windows, and macOS (Node 22 & 24). 117 adversarial cases cover path traversal & symlink breakout, secret redaction, egress sanitization, git porcelain parsing, evidence budget ceilings, absolute-deadline exhaustion (zero-borrow across connect/inject/submit/verify), authorized-workspace enforcement, untracked symlink aliases, per-file Git diff policy, conversation identity pinning (/ โ /c/A โ /c/B), durable resume credentials, multi-tab precise selection, and MCP parameter pass-through on the real handler chain:
npm test
# Equivalent to: node tests/security_adversarial.test.mjs2. Local Environment Verification & Live Integration (npm run verify)
Runs local sanity checks and optional live end-to-end integration tests with an active Chrome session:
# Verify local module structure, configuration, and CDP connectivity (37 checks)
npm run verify
# Optional: Run live end-to-end multi-mode execution against an active Chrome session
node scripts/verify_install.mjs --run-testโ๏ธ Terms of Service & Responsible Use Notice
Legal & Compliance Notice:
Personal Research & Workflow Tool:
antigravity-with-chatgptis an open-source experimental developer tool designed for personal workflow augmentation, dual-brain reasoning research, and local verification pairing Antigravity with web-based LLMs.OpenAI Terms of Use & Automated Extraction Restrictions: OpenAI's Terms of Use explicitly restrict automated or programmatic extraction of data or Output; additional Service Terms and policies may also apply. Personal, local, interactive, or non-commercial use should not be assumed to create an exemption from those Terms. This project connects locally via Chrome DevTools Protocol (CDP) on
127.0.0.1:9222to an existing authenticated user session purely as a developer convenience bridge for personal, interactive pair-programming. It is not an official OpenAI API client, an automated scraping pipeline, or a commercial extraction tool.User Responsibility: Users are solely responsible for ensuring that their use complies with all applicable OpenAI terms, policies, and fair-use guidelines. Interacting programmatically with web interfaces carries inherent risks (including session invalidation, CAPTCHA challenges, or account restrictions). For production, high-throughput, or SLA-backed programmatic access, please use official OpenAI Platform APIs.
No Warranties or Guarantees: This project does not circumvent paywalls, rate limits, or account restrictions. The maintainers do not assume any liability for account restrictions, session termination, or any other impacts resulting from the use of this software.
๐ License
Open-sourced under the MIT License. Contributions, feedback, and pull requests are warmly welcome!
This server cannot be deployed
Maintenance
Related MCP Connectors
Browser-backed QA with evidence and fix-ready reports for coding agents.
A paid remote MCP for AI agent browser DevTools MCP, built to return verdicts, receipts, usage logs,
- openhelmOAuthai.openhelm
Autonomous cloud agent tasks: real browser + your tools, structured evidence-backed results.
Machine-verifiable authorization checks for autonomous AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI coding assistants to control and inspect a live Chrome browser for automation, debugging, performance analysis, network monitoring, and DOM interaction through Chrome DevTools Protocol.3,204,746 npmApache 2.0
- AlicenseBqualityAmaintenanceEnables AI agents to debug code and automate browsers using Chrome DevTools Protocol, supporting breakpoints, variable inspection, and replayable interaction recording.35389 npm16MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI coding assistants to control and inspect a live Chrome browser through Chrome DevTools for automation, debugging, and performance analysis.3,204,746 npmApache 2.0
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to declaratively control web pages using real mouse and keyboard events via Chrome DevTools Protocol, without executing page JavaScript.12 npm1-