Rules, Skills, and Hooks handle how an agent reasons locally, follows runbooks, and intercepts actions before execution. Bring Antigravity into your daily engineering workflow, however, and you quickly hit a different set of requirements: querying internal Jira tickets, fetching up-to-date library docs, driving a local browser to debug a page, or rendering diagnostic output as an interactive board you can actually click and edit.

MCP (Model Context Protocol) wires all of these external capabilities in. Yet getting MCP to run smoothly in practice usually trips over three friction points:

  1. Remote servers refuse to connect: You copy a /sse endpoint from an older guide into your config, and the handshake fails every time.
  2. Context costs spike overnight: You attach three or four everyday servers—chrome-devtools, memory, context7—and burn 10,000–20,000 tokens before writing a single line of code.
  3. Plain-text output makes poor UI: Ticket lists, task boards, and database schemas get dumped as hundreds of lines of Markdown; updating a single status requires typing another prompt and waiting for the model to re-run.

Based on hands-on verification with agy v1.5.19, the official mcp_servers.md docs, and the mcp-app-development spec, this guide breaks down Antigravity’s MCP transports, CLI management, schema Lazy Loading, and **MCP Apps (ui:// embedded interactive interfaces)**—one of the most underused features in the platform.

MCP transport architecture and MCP Apps ui:// isolated iframe communication model


1. MCP Config Locations, Two Transports, and the /sse Pitfall

Antigravity configures MCP servers in mcp_config.json across two scopes:

Config Path Scope Naming & Variable Support Best For
~/.gemini/config/mcp_config.json Global; loaded automatically in every session Uses the configured server name as-is Everyday personal tools (docs lookup, memory graph, browser debugging)
plugins/<name>/mcp_config.json Enabled/disabled with its parent plugin Auto-prefixed as <plugin>_<server>; supports ${PLUGIN_ROOT} and ${PLUGIN_DATA} Team-shared tools and MCP Apps with dedicated frontends

1. Only Two Supported Transports: Stdio and Streamable HTTP

A standard mcp_config.json looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"mcpServers": {
"sqlite-helper": {
"command": "sqlite-mcp-server",
"args": ["/path/to/database.db"],
"env": {
"DB_READONLY": "true"
}
},
"remote-service": {
"url": "https://mcp.mycompany.com/mcp"
}
}
}

The schema for both transports is minimal:

  • Stdio (local process): The Language Server spawns a local binary or script and communicates over stdin/stdout. Requires command, with optional args (string array) and env (key-value map injected into the process environment).
  • Streamable HTTP (remote service): Implements the MCP 2025-03-26 specification. You only need url (the legacy key serverUrl is still accepted for backward compatibility).

Common Pitfall: Legacy HTTP+SSE (MCP spec 2024-11-05) Is Not Supported
Many older open-source MCP servers expose a /sse endpoint by default. Antigravity does not support legacy HTTP+SSE transport—pointing url at /sse fails immediately. Always use the server’s Streamable HTTP endpoint (typically /mcp). If an upstream server only speaks legacy SSE and cannot be upgraded right away, wrap it with a Stdio bridge such as mcp-remote in mcp_config.json:

1
2
3
4
5
6
7
8
{
"mcpServers": {
"legacy-sse-bridge": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://legacy.example.com/sse"]
}
}
}

2. Managing Servers with agy mcp: Watch the Flag Order

If you prefer not to edit JSON by hand, agy mcp provides five subcommands: add, remove, list, enable, and disable.

Running agy mcp add --help surfaces one strict rule worth memorizing: all flags (-e/--env, -H/--header, -t/--type) must come before <name>. Placing -e or -H after the server name causes the command to reject the invocation outright.

Two more conveniences save keystrokes:

  • When the target starts with http:// or https://, the CLI automatically infers the http transport—no need to pass -t http.
  • When a Stdio command or its arguments start with -, insert -- between <name> and the command so the CLI does not parse them as its own flags.

Three real-world examples you will use most often:

1
2
3
4
5
6
7
8
# 1. Local Stdio: launch the filesystem MCP server via npx
agy mcp add fs npx -y @modelcontextprotocol/server-filesystem /work

# 2. Remote Streamable HTTP: -H must precede <name>; https auto-detects http type
agy mcp add -H "Authorization: Bearer YOUR_TOKEN" api https://example.com/mcp

# 3. Containerized Stdio with env vars: -e comes first; use -- before flags like -i
agy mcp add -e GITHUB_TOKEN=ghp_xxx gh -- docker run -i ghcr.io/github/mcp

After adding servers, inspect their status with agy mcp list, or temporarily turn one off with agy mcp disable <name> instead of deleting and re-pasting config blocks. In the GUI, you can also view connected servers and their tool catalogs under Additional Options (…) > MCP Servers in the top-right menu.


2. Lazy Loading: Stop Tool Schemas from Burning Your Context Budget

In Part 3 on context budgets, we touched on a common failure mode: the more MCP servers you attach, the faster your system prompt balloons.

Measuring the four everyday MCP servers configured on my machine makes this concrete—here is the total size of the tool schema files cached under <appDataDir>/mcp/:

MCP Server Cached Files Total Schema Bytes Representative Tools
chrome-devtools 38 JSON files 38,281 B new_page, take_snapshot, list_network_requests, evaluate_script, etc.
context7 3 files (incl. instructions.md) 10,047 B resolve-library-id, query-docs
memory 9 JSON files 8,237 B create_entities, search_nodes, read_graph, etc.
jira-internal 2 JSON files 8,209 B jira_get_issue, jira_search

Just four common servers add up to 64,774 bytes of tool definitions—roughly 16,000 to 20,000 tokens. If every session eagerly stuffed those full JSON schemas into the system prompt, even asking the agent to fix a one-line shell script would carry nearly 20k tokens of unused tool documentation on the very first turn. Scale that to a dozen servers and tool definitions eat a sizable chunk of your context window.

Antigravity avoids this with Lazy Loading by default:

  1. Expose only the directory on turn one: The system prompt lists only connected server names and tool names—a few hundred tokens total, with zero parameter schemas inline.
  2. Cache full schemas on disk: Each tool’s full JSON schema (plus an optional instructions.md best-practices guide) is written to <appDataDir>/mcp/<serverName>/<toolName>.json.
  3. Read on demand, route centrally: Only when the model decides a step actually needs a specific MCP tool does it call read_file on <toolName>.json to inspect the exact input schema, then invoke the built-in call_mcp_tool (or list_resources / read_resource for MCP resources) through the Language Server.

Pairing Lazy Loading with one simple organizational habit pays off even more: keep high-frequency core tools global, and package low-frequency or project-specific MCP servers inside plugins. Plugin servers automatically receive a <plugin>_<server> namespace to prevent collisions, and disabling a plugin removes even its tool directory from the prompt—far cleaner than piling a dozen servers into ~/.gemini/config/mcp_config.json.

Important Distinction: Schema Lazy Loading ≠ Process/Container Lazy Loading
Built-in Lazy Loading solves context token bloat by deferring tool JSON schemas, but local processes and Docker containers in mcp_config.json still start with the session by default. If you attach heavy servers like Chrome DevTools or a Dockerized Jira MCP and want the browser or container to spin up only on an actual tools/call, see the Engineering in Practice guide: Lazy MCP Proxies and Chrome Session Tab Groups.

agy mcp CLI verification and plugin MCP hot-reload troubleshooting cheat sheet


3. MCP Apps (SEP-1865): Adding ui:// Interactive UIs to MCP Tools

Standard MCP tools only return text or JSON, leaving the model to summarize results back into chat. For boards, visual diffs, log filters, or parameter forms—workflows where you want to glance and click—pure conversational interaction is painfully slow.

Antigravity implements MCP Apps (SEP-1865, @modelcontextprotocol/ext-apps) along with several host extensions, allowing an MCP server to ship both data and an interactive frontend.

1. How the Architecture Works

An MCP App connects two halves:

  • Server side: Registers a ui:// resource on the same MCP server with the exact MIME type text/html;profile=mcp-app.
  • Tool declaration: Points _meta.ui.resourceUri at that ui:// URI (the legacy flat key _meta["ui/resourceUri"] is still accepted, but any URI that does not start with ui:// causes the host to drop all UI metadata).
  • Host rendering: Whenever the tool runs—or the user launches it from an entrypoint—Antigravity fetches the ui:// HTML document live (up to 10 MiB, never persisted in the conversation transcript), mounts it inside an isolated iframe with its own origin, and communicates bidirectionally via JSON-RPC over postMessage.

Here is the full end-to-end lifecycle:

2. Server Setup and the Three Host Entrypoints

Using a Python FastMCP-style server makes the contrast between inline cards, auxiliary side panes, global full-page views, and app-only callbacks immediately clear:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
APP_URI = "ui://tasks/app.html"

# 1. Render inline inside the chat stream only
INLINE = {"ui": {"resourceUri": APP_URI}}

# 2. Register in both the sidebar "+" menu and left global navigation
PANE = {
"ui": {"resourceUri": APP_URI},
"com.google.antigravity/ui": {
"entrypoints": [
{"type": "aux_pane", "title": "Tasks"},
{"type": "global", "title": "Tasks"},
]
},
}

# 3. Callable only from the frontend UI; completely hidden from the model
APP_ONLY = {"ui": {"visibility": ["app"]}}

mcp.tool(title="Create a task board", meta=INLINE)(create_board)
mcp.tool(name="open_tasks", title="Tasks", meta=PANE)(open_tasks)
mcp.tool(meta=APP_ONLY)(app_save_board)

mcp.resource(
APP_URI,
name="Tasks app",
mime_type="text/html;profile=mcp-app",
meta={"ui": {"prefersBorder": False}},
)(app_html)

Understanding the differences between the three host entrypoints directly shapes how you write defensive frontend code:

Entrypoint Type Configuration Sizing & Behavior Common Gotchas
Inline (inline) _meta.ui.resourceUri only Auto-resizes by default, starting at 150px and expanding up to 800px Great for single-turn result cards; poor fit for complex multi-column workspaces
Auxiliary Side Pane (aux_pane) com.google.antigravity/ui.entrypoints with aux_pane Opens from the sidebar + menu and fills the pane; subsequent model calls to the same tool refresh the open pane in place Ideal for agent-driven UIs; the entrypoint must live on a tool with resourceUri, otherwise it is discarded
Global Full Page (global) com.google.antigravity/ui.entrypoints with global Opens a standalone full-page view from the left sidebar No active conversation context—the host omits message and updateModelContext, so hide those controls based on capabilities

Hidden Rule for Entrypoint Launches: When a user opens an MCP App from the + menu or left sidebar, the host invokes the backing tool with an empty object {}. Make every parameter on entrypoint tools optional and return a valid default view for {} instead of throwing a schema validation error on launch.

3. visibility, the 1 MiB Transcript Cap, and Splitting Payloads

Design around three data boundaries before writing your first MCP App tool:

  1. Tool visibility: Accepts ["model"], ["app"], or both (omitted or empty defaults to both). Mark pure UI actions—saving state, paginating tables, fetching full record details—as ["app"] so they neither clutter the model’s tool list nor get invoked by accident. Conversely, if a tool’s visibility excludes "app", the host blocks frontend calls to it.
  2. Split content vs. structuredContent: Return a concise text summary in content (for the model) alongside structured data in structuredContent (for the UI). Respect the security boundary: the model reads content while the app receives the full CallToolResult, so never place secrets or internal raw fields you do not want exposed into the result payload.
  3. 1 MiB transcript result cap: Antigravity caps each persisted CallToolResult in the conversation transcript at 1 MiB. Exceed it, and the frontend receives ontoolinput (the arguments) without any result payload. For large tables, long logs, or heavy image metadata, have the primary tool return a lightweight summary plus a query ID, then let the frontend fetch the full dataset asynchronously through a visibility: ["app"] tool after mount.

4. Frontend SDK, Host Capabilities, and AGY Extensions

Do not hand-roll window.postMessage plumbing. Use the official SDK @modelcontextprotocol/ext-apps (App for vanilla JS/TS, or useApp and useHostStyles from @modelcontextprotocol/ext-apps/react), which handles the handshake, version negotiation, ping, auto-resizing, and message validation out of the box.

Because the default CSP blocks all external scripts and stylesheets, bundle the frontend into a single self-contained HTML file (Vite + vite-plugin-singlefile, or esbuild --bundle inlined into HTML). Follow one non-negotiable initialization rule: register all event handlers before calling connect():

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import {
App,
applyDocumentTheme,
applyHostStyleVariables,
} from '@modelcontextprotocol/ext-apps';

const app = new App({ name: 'Tasks', version: '1.0.0' }, {});

// Register handlers BEFORE connect(), or initial args/results pushed right after handshake will be missed
app.ontoolinput = ({ arguments: args }) => renderLoading(args);
app.ontoolresult = (result) => render(result.structuredContent);
app.onhostcontextchanged = (ctx) => {
if (ctx.theme) applyDocumentTheme(ctx.theme);
if (ctx.styles?.variables) applyHostStyleVariables(ctx.styles.variables);
};

await app.connect();
const ctx = app.getHostContext();
if (ctx?.theme) applyDocumentTheme(ctx.theme);
if (ctx?.styles?.variables) applyHostStyleVariables(ctx.styles.variables);

For theming, the host injects standard CSS variables via hostContext.styles.variables (--color-background-*, --color-text-*, --color-border-*, --color-ring-*, --font-sans). Always include fallbacks in var(...) because missing tokens are omitted, and re-run applyHostStyleVariables inside onhostcontextchanged so light/dark theme switches stay clean.

Once connected, inspect app.getHostCapabilities() before rendering interactive controls. Here is what Antigravity supports:

SDK / Extension Method Capability Key Antigravity Behavior & Limits
app.callServerTool() serverTools Can only call enabled tools on the same server with "app" visibility; max 4 concurrent in-flight requests per app, auto-aborted on close or reload
app.sendMessage() message Text only; targets the current conversation by default; passing _meta: {"com.google.antigravity/message": {"target": "new"}} spawns a background conversation in the same project and returns conversationId
app.updateModelContext() updateModelContext Replaces pending context with text / resource_link (empty content clears it), shown as a context pill on the user’s next message; trigger only on explicit user actions
app.openLink() openLinks Allows http / https only; opens externally
com.google.antigravity/toggle-aux-pane Unadvertised (AGY extension) Invoked via app.request() with {"tabType": "fileView", "uri": "file:///..."} to open a workspace file tab in the sidebar; returns {"isError": true} if no sidebar exists or the URI is invalid, and -32601 on non-AGY hosts

Because the SDK strips unknown capability keys, call toggle-aux-pane directly through app.request() and handle -32601 as a graceful fallback:

1
2
3
4
5
6
7
const result = await app.request(
{
method: 'com.google.antigravity/toggle-aux-pane',
params: { tabType: 'fileView', uri: 'file:///path/to/file.ts' },
},
z.object({ isError: z.boolean().optional() }).passthrough(),
);

5. Isolation Boundaries, Missing Teardown Events, and Tight CSP

Developers coming from browser extensions or WebViews consistently hit three security and lifecycle gotchas with MCP Apps:

  1. Do not rely on browser storage: Every view runs inside an isolated iframe with a freshly allocated origin. localStorage, IndexedDB, and cookies are either unavailable or wiped on close/reload, and never shared across views.

  2. AGY does not emit ui/resource-teardown: Closing, switching away from, or reloading an iframe gives zero advance warning, and in-flight tools/call requests are aborted immediately. Never defer writes until “on close”—persist every user mutation right away via app.callServerTool() to an app-only tool on your server.

  3. The default CSP is default-src 'none': Only inline <script>/<style> plus data:/blob: images, fonts, and media are allowed. Direct fetch, WebSockets, nested iframes, and form submissions are blocked by default. If you genuinely need external resources, declare bare origins by category under _meta.ui.csp on the ui:// resource (*. wildcard subdomains and ports are allowed; adding paths, quotes, or CSP keywords silently drops the entire entry):

    • resourceDomains: external scripts, stylesheets, images, fonts, and media
    • connectDomains: fetch, XHR, and WebSockets
    • frameDomains: nested iframes
    • baseUriDomains: <base href>

    Even then, if a request can go through app.callServerTool() to your own MCP server, do not open connectDomains—your server already holds the auth credentials, and every call stays auditable inside the MCP trace.


4. Plugin Packaging, Single-Server Hot Reload, and Troubleshooting

Packaging a custom MCP server or MCP App as a plugin is the cleanest way to iterate locally and share with a team. Drop the directory into ~/.gemini/config/plugins/<name>/ and Antigravity discovers it automatically—no separate install or registration command required:

1
2
3
4
5
~/.gemini/config/plugins/tasks/
├── plugin.json # Required: {"name": "tasks", "description": "..."}
├── mcp_config.json # MCP server config bundled with this plugin
├── bin/tasks-server # Server binary or launcher script
└── assets/logo.svg # Optional icon

Inside mcp_config.json, use the built-in placeholders ${PLUGIN_ROOT} (expands to the plugin directory) and ${PLUGIN_DATA} (expands to the plugin’s dedicated persistent data directory) to eliminate hardcoded absolute paths:

1
2
3
4
5
6
7
8
{
"mcpServers": {
"tasks": {
"command": "bash",
"args": ["${PLUGIN_ROOT}/bin/tasks-server", "--data_dir=${PLUGIN_DATA}"]
}
}
}

Watch the namespace rule: when the plugin is named tasks and the server key inside it is also tasks, its runtime server name is tasks_tasks (<plugin>_<server>). Use that full name when checking logs or calling RPCs.

1. Iterate Without Restarting the Client: Single-Server Hot Reload + Instant UI Refresh

Newly added plugins are discovered automatically, but an already-running server process still executes old code. Instead of clicking restart in the MCP Servers UI every time, call the local Language Server’s RefreshMcpServers RPC from an Antigravity terminal to bounce just that one server:

1
2
3
4
curl -sf -H "Content-Type: application/json" \
-H "x-codeium-csrf-token: ${ANTIGRAVITY_CSRF_TOKEN}" \
-d '{"serverName": "tasks_tasks"}' \
"http://${ANTIGRAVITY_LS_ADDRESS:-localhost:5387}/exa.language_server_pb.LanguageServerService/RefreshMcpServers"

Frontend iteration is even faster. Because the host fetches ui:// HTML live on every open, configure your server to read the bundled HTML path from an environment variable (such as TASKS_APP_HTML). Rebuild the single-file bundle, close and reopen the view, and your changes appear immediately—without restarting the MCP server process at all.

2. MCP Apps Troubleshooting Matrix

When something goes wrong in an MCP App, match the symptom row by row:

Symptom Likely Root Cause What to Check Fix
Immediate error on open; no UI rendered Wrong MIME type, size limit exceeded, or missing server capability Verify the resource returns text/html;profile=mcp-app, non-empty text under 10 MiB, and the server advertises resources Fix the MIME type and capability declaration; trim inlined asset size
Blank white screen app.connect() never ran / threw an error, or CSP blocked scripts Check DevTools console for CSP violations or unbundled external JS/CSS Bundle into a single HTML file with vite-plugin-singlefile, or declare bare origins in resourceDomains
Args show up, but no result data renders Payload exceeded 1 MiB, or handlers were registered after connect() Check CallToolResult byte size; verify ontoolresult registration order Register all on* handlers before await app.connect(); fetch large payloads asynchronously via an ["app"] tool
Frontend tools/call fails or buttons do nothing Missing "app" visibility, cross-server call, >4 concurrent calls, or global page Check visibility, server ownership, in-flight request count, and app.getHostCapabilities() Add "app" visibility, cap concurrency at ≤ 4, and hide message/updateModelContext controls on global views
Colors break after switching light/dark theme Theme variables applied only on mount, not on change Verify onhostcontextchanged listener and CSS variable fallbacks Re-run applyHostStyleVariables inside onhostcontextchanged (or use useHostStyles in React)

Next, we will cover how to bundle MCP servers, Rules, Skills, and Hooks into a standard plugin.json package for teams, along with multi-repo Marketplaces and configuration inheritance.


Series Navigation