Skip to main content
Glama
Secret Vault for Google Antigravity

Secret Vault for Google Antigravity

by g8d3
README.md
# Secret Vault for Google Antigravity

A **zero-exposure secret manager plugin and MCP App** (`SEP-1865`) for **Google Antigravity** (App, CLI, and IDE).

Instead of asking users to paste API keys into chat transcripts or context-switch to hand-edit `.env` files, agents call `request_secret(...)` to render a native, theme-aware **masked password card directly inline in the conversation** — plus a full **Secret Vault** manager in the side pane and left sidebar.

---

## Why This Exists

Secret handling is a foundational primitive for real-world agentic workflows.

Antigravity already supports OAuth sign-in and static `mcpServers.<server>.variables` during plugin setup, **but three common workflows still lack a built-in zero-exposure secret prompt:**

1. **CLI & skill-based workflows** (such as running scripts with `GEMINI_API_KEY`, `STRIPE_API_KEY`, `OPENAI_API_KEY`, `YOUTUBE_REFRESH_TOKEN`, or custom APIs) that aren't tied to a single plugin's MCP `variables`.
2. **Dynamic, mid-conversation secret requests** when an agent discovers halfway through a task that a new credential or paid-tier key is needed.
3. **Subprocess secret injection with output redaction** so raw values never enter the chat transcript, model context, or accidental `stdout`/`stderr` logs.

**Secret Vault** fills that gap natively using Antigravity's own **MCP Apps** (`SEP-1865` + `_meta.ui.visibility: ["app"]`):

```text
Agent calls request_secret("GEMINI_API_KEY")
        │
        ▼
Antigravity renders isolated MCP App card (type="password") inline in chat
        │
        ▼  app.callServerTool("vault_save_secret")  [visibility: ["app"] — hidden from model]
Local MCP server writes ${PLUGIN_DATA}/vault.json (atomic write, 0700 dir / 0600 file)
        │
        ▼  app.sendMessage("I securely saved GEMINI_API_KEY (AIza••••1234)...")
Agent runs commands via `node .../scripts/secret-vault-run.mjs --secret GEMINI_API_KEY -- <cmd>`
(injects env var directly into child process + redacts accidental stdout/stderr leaks)
```

---

## Key Features

- **Inline Masked Secret Card (`request_secret`):** Agent-triggered password prompt right inside the conversation, with Show/Hide toggle and a single primary **Save & Continue** action.
- **Side Pane & Sidebar Vault Manager (`open_secret_vault`):** Registered as both `aux_pane` (`+` menu) and `global` (left sidebar) entrypoints so users can add, rotate, or delete secrets anytime.
- **True Zero-Exposure to the Model:**
  - `vault_save_secret`, `vault_delete_secret`, and `vault_list_secrets` declare `_meta.ui.visibility = ["app"]` — only the isolated MCP App iframe can invoke them.
  - Model-visible tools (`list_secrets`, `has_secret`) return only secret names, descriptions, timestamps, and masked previews (`AIza••••1234`).
  - Bundled security rule (`rules/AGENTS.md`) instructs the agent never to ask for raw keys in chat or read `vault.json`.
- **Cross-Platform Safe Runner (`scripts/secret-vault-run.mjs`):** Pure Node.js (`>= 20`) wrapper that works on macOS, Linux, and Windows. Supports `--secret NAME`, `--map SRC=DEST`, `--unset VAR` (to override conflicting ambient env vars), `--all`, and live redaction of injected secret values from child `stdout`/`stderr` (`[REDACTED_SECRET]`).
- **Zero Runtime Dependencies:** Both the MCP server (`dist/server.mjs`) and the single-file MCP App UI (`dist/app.html`) are pre-bundled via `esbuild` and ready to run immediately after install.

---

## Quick Install

### Option 1: Install directly with the Antigravity CLI (Recommended)

```bash
agy plugin install https://github.com/g8d3/antigravity-secret-vault
```

### Option 2: Install from a Release Tarball

Download `antigravity-secret-vault-0.2.0.tar.gz` from [Releases](https://github.com/g8d3/antigravity-secret-vault/releases) and extract it into Antigravity's global plugins folder:

```bash
mkdir -p ~/.gemini/config/plugins
tar -xzf antigravity-secret-vault-0.2.0.tar.gz -C ~/.gemini/config/plugins
```

Antigravity discovers `~/.gemini/config/plugins/secret-vault/` automatically — no restart required.

---

## MCP Tools Included

| Tool | Visibility | Purpose |
| --- | --- | --- |
| `request_secret` | Model + UI | Opens an inline masked password input card in the conversation for a specific secret name. |
| `open_secret_vault` | Model + UI (`aux_pane`, `global`) | Opens the full Secret Vault manager UI to view, add, rotate, or delete secrets. |
| `list_secrets` | Model | Lists stored secret names, descriptions, timestamps, and masked previews (never raw values). |
| `has_secret` | Model | Checks whether a named secret exists and returns its masked preview. |
| `vault_save_secret` | **App-only** (`["app"]`) | Saves/updates a secret directly from the isolated MCP App iframe to disk (`0600`). |
| `vault_delete_secret` | **App-only** (`["app"]`) | Deletes a secret directly from the isolated MCP App iframe. |
| `vault_list_secrets` | **App-only** (`["app"]`) | Refreshes masked secret metadata inside the UI. |

---

## Usage Example

Ask Antigravity:

> *"Ask me securely for my `GEMINI_API_KEY` using Secret Vault, then run my script."*

1. The agent calls `has_secret("GEMINI_API_KEY")`.
2. If missing, the agent calls `request_secret(...)`, rendering the masked password card inline.
3. You paste the key into the card and click **Save & Continue**.
4. The agent receives only `GEMINI_API_KEY (AIza••••1234)` and runs:

```bash
node ~/.gemini/config/plugins/secret-vault/scripts/secret-vault-run.mjs \
  --secret GEMINI_API_KEY \
  --unset GOOGLE_API_KEY \
  -- python3 generate.py
```

---

## Security Model & Future Direction

- **What this plugin guarantees today:**
  - Secrets are never typed into chat history or passed into LLM context windows.
  - Only the sandboxed MCP App iframe can call write/delete tools (`visibility: ["app"]`).
  - Secrets are persisted atomically on disk with POSIX `0600` file permissions inside a `0700` directory.
  - Subprocess output streams (`stdout` / `stderr`) are scanned and redacted if a child process echoes an injected secret.
- **Why we'd love to see native support in Antigravity:**
  - A first-party Antigravity secret vault backed by the OS keychain (macOS Keychain, Linux Secret Service / libsecret, Windows Credential Manager) and enforced at the host/sandbox boundary would give every Antigravity user and skill zero-exposure secret management out of the box. This plugin serves both as a ready-to-use solution today and as a working reference design built on Antigravity's MCP Apps spec.

---

## Development & Validation

```bash
npm install
npm run build
agy plugin validate . --strict
./scripts/package.sh
```

---

## License

[MIT](LICENSE)