MCP & MCP Apps: External Tool Integration & ui:// Embedded Interfaces
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:
- Remote servers refuse to connect: You copy a
/sseendpoint from an older guide into your config, and the handshake fails every time. - 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. - 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.

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 | { |
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 optionalargs(string array) andenv(key-value map injected into the process environment). - Streamable HTTP (remote service): Implements the MCP
2025-03-26specification. You only needurl(the legacy keyserverUrlis 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. 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://orhttps://, the CLI automatically infers thehttptransport—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 | # 1. Local Stdio: launch the filesystem MCP server via npx |
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:
- 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.
- Cache full schemas on disk: Each tool’s full JSON schema (plus an optional
instructions.mdbest-practices guide) is written to<appDataDir>/mcp/<serverName>/<toolName>.json. - Read on demand, route centrally: Only when the model decides a step actually needs a specific MCP tool does it call
read_fileon<toolName>.jsonto inspect the exact input schema, then invoke the built-incall_mcp_tool(orlist_resources/read_resourcefor 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.

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 typetext/html;profile=mcp-app. - Tool declaration: Points
_meta.ui.resourceUriat thatui://URI (the legacy flat key_meta["ui/resourceUri"]is still accepted, but any URI that does not start withui://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 isolatediframewith its own origin, and communicates bidirectionally via JSON-RPC overpostMessage.
Here is the full end-to-end lifecycle:
sequenceDiagram
autonumber
participant M as Model / User Entrypoint
participant H as Antigravity Host (LS + UI)
participant S as MCP Server
participant F as Isolated iframe (ui:// App)
M->>H: Invoke tool with _meta.ui.resourceUri (or click entrypoint with {})
H->>S: tools/call (execute tool)
H->>S: resources/read (fetch ui:// HTML live, <= 10 MiB, excluded from transcript)
S-->>H: Return content + structuredContent and HTML document
H->>F: Render iframe under an isolated origin
F->>H: app.connect() (ui/initialize + initialized)
H-->>F: Return hostCapabilities and hostContext (theme / CSS vars)
H-->>F: Push ontoolinput (args) and ontoolresult (result <= 1 MiB)
Note over F: User edits state / queries large dataset in UI
F->>H: app.callServerTool() (<= 4 concurrent, calls app-only tool)
H->>S: Forward tools/call to the same server
S-->>F: Return updated data or persistence confirmation
F->>H: app.updateModelContext() / sendMessage()
H-->>M: Attach context pill to next message / prompt model to continue
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 | APP_URI = "ui://tasks/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:
- 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’svisibilityexcludes"app", the host blocks frontend calls to it. - Split
contentvs.structuredContent: Return a concise text summary incontent(for the model) alongside structured data instructuredContent(for the UI). Respect the security boundary: the model readscontentwhile the app receives the fullCallToolResult, so never place secrets or internal raw fields you do not want exposed into the result payload. - 1 MiB transcript result cap: Antigravity caps each persisted
CallToolResultin the conversation transcript at 1 MiB. Exceed it, and the frontend receivesontoolinput(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 avisibility: ["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 | import { |
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 | const result = await app.request( |
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:
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.AGY does not emit
ui/resource-teardown: Closing, switching away from, or reloading an iframe gives zero advance warning, and in-flighttools/callrequests are aborted immediately. Never defer writes until “on close”—persist every user mutation right away viaapp.callServerTool()to an app-only tool on your server.The default CSP is
default-src 'none': Only inline<script>/<style>plusdata:/blob:images, fonts, and media are allowed. Directfetch, WebSockets, nested iframes, and form submissions are blocked by default. If you genuinely need external resources, declare bare origins by category under_meta.ui.cspon theui://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 mediaconnectDomains:fetch, XHR, and WebSocketsframeDomains: nested iframesbaseUriDomains:<base href>
Even then, if a request can go through
app.callServerTool()to your own MCP server, do not openconnectDomains—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 | ~/.gemini/config/plugins/tasks/ |
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 | { |
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 | curl -sf -H "Content-Type: application/json" \ |
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.


















