Skip to main content
Glama

file-launcher(Antigravity 交付文件卡片插件)

一款轻量、纯本地运行的 Windows Antigravity MCP App 插件(基于 SEP-1865 / @modelcontextprotocol/ext-apps)。

当 Agent 在对话中向用户汇总或交付多个本地产出文件时,在聊天窗口内联渲染一张交互式文件列表卡片,实现 左键在工作区侧边栏预览、右键或行尾 ⋮ 选择 Windows 本地打开方式。


核心功能

  • 结构化文件卡片:支持卡片标题、副标题、显式/自动分组、扩展名彩色标识、文件大小、缺失状态提示,悬停显示完整 Windows 路径。

  • 原生主题融合:通过 applyDocumentTheme 与 applyHostStyleVariables 自动同步 Antigravity 明暗主题及宿主样式变量。

  • 左键侧边栏预览:调用 com.google.antigravity/toggle-aux-pane(tabType: "fileView"),在当前工作区侧边栏中预览文件;不可预览时弹出友好提示。

  • 右键 / ⋮ 本地操作菜单:

    • 打开方式…:唤起 Windows 原生“选择打开方式”弹窗(rundll32.exe shell32.dll,OpenAs_RunDLL)。

    • 用系统默认程序打开:按 Windows 系统文件关联打开(通过 PowerShell Invoke-Item -LiteralPath + 环境变量传参,零 shell 注入风险)。

    • 在资源管理器中显示:打开所在目录并高亮选中目标文件(explorer.exe /select,"<path>")。

    • 在工作区侧边栏预览:同左键预览。

    • 复制完整路径:前端剪贴板失败时自动回退服务端 PowerShell Set-Clipboard,确保隔离 iframe 与中文路径稳定可用。

    • 常用程序快捷入口(可选):支持通过 ${PLUGIN_DATA}/apps.json 配置本地常用软件(如 VS Code、WPS、Typora、Acrobat 等)。

  • 防裁切与防抖动菜单定位:菜单紧凑贴合卡片内部上下边界浮动(≥2 个文件时零增高,不挤动下方聊天文字;极矮卡片按最小余量自适应展开)。


Related MCP server: Antigravity File Explorer

安全与协议设计

  • 严格工具可见性隔离:

    • 模型仅可见 show_file_card(指向 ui://file-launcher/card.html,MIME text/html;profile=mcp-app)。

    • 5 个本地动作工具(open_with_dialog、open_default、reveal_in_explorer、copy_path、open_with_app)全部设置 _meta.ui.visibility = ["app"],对 AI 模型不可见,仅能由用户在卡片界面手动点击触发;对不支持 MCP Apps 扩展的纯文本宿主不注册动作工具。

  • 可执行文件安全护栏:open_default 自动拦截 .exe、.bat、.cmd、.ps1、.vbs、.msi、.lnk 等可执行/脚本类后缀,防止误点运行。

  • 单文件自包含前端:使用 Vite + vite-plugin-singlefile 打包为单个无外链 HTML,完全满足宿主默认 default-src 'none' CSP。


环境要求

  • Windows 10 / 11

  • Node.js v22+(默认路径 C:\Program Files\nodejs\node.exe,如安装在其他路径请同步调整 mcp_config.json 与 scripts/deploy.ps1)

  • PowerShell 7+(pwsh.exe)

  • Antigravity


快速安装与部署

# 1. 安装依赖并构建
npm ci
npm run build

# 2. 一键构建并部署到 %USERPROFILE%\.gemini\config\plugins\file-launcher\
pwsh -NoProfile -File .\scripts\deploy.ps1

Antigravity 会自动发现 ~/.gemini/config/plugins/file-launcher/ 中的插件,无需手动编辑 config.json。

可选:配置常用程序快捷入口

插件首次启动时,会在 Antigravity 持久化数据目录 ${PLUGIN_DATA}(通常为 %USERPROFILE%\.gemini\antigravity\plugin_data\file-launcher\)自动生成 apps.example.json。将其复制为同目录下的 apps.json 并修改为本机 .exe 路径即可生效:

{
  "apps": [
    {
      "id": "vscode",
      "label": "用 VS Code 打开",
      "exePath": "C:\\Program Files\\Microsoft VS Code\\Code.exe",
      "extensions": [".md", ".json", ".ts", ".txt"],
      "extraArgs": []
    }
  ]
}

extensions 留空数组 [] 时表示适用于所有文件类型。服务端严格按 appId 从白名单读取可执行路径,更新或重装插件不会覆盖 ${PLUGIN_DATA} 中的用户配置。


开发与测试

# 类型检查 + 前端单文件打包 + 服务端单文件打包
npm run build

# 运行 MCP stdio 协议、路径编码、安全拦截与 Windows 剪贴板自动化测试
npm test

# 运行离线 Chrome 模拟宿主 UI 冒烟测试(需要本机已安装 Chrome,可用 FILE_LAUNCHER_CHROME 指定路径)
npm run test:ui

调试 UI 时,可通过环境变量 FILE_LAUNCHER_HTML 指定本地 HTML 文件路径,重新打开卡片即可生效。


目录结构

.
├── plugin.json           # Antigravity 插件元信息
├── mcp_config.json       # 本地 stdio MCP Server 启动配置
├── card.html             # 前端入口 HTML
├── assets/logo.svg       # 插件方形图标
├── rules/AGENTS.md       # 交付文件时调用卡片工具的常驻规则
├── src/
│   ├── server.ts         # MCP Server 入口与工具/资源注册
│   ├── windows.ts        # Windows 路径规范化、安全拦截与本地文件动作
│   ├── apps.ts           # ${PLUGIN_DATA}/apps.json 常用程序配置加载与执行
│   ├── card-data.ts      # 前后端共享数据 Schema
│   ├── card.ts           # 卡片交互、宿主通信与菜单贴边定位
│   └── card.css          # 主题变量适配与紧凑布局样式
├── scripts/deploy.ps1    # 一键构建与原子部署脚本(PowerShell 7)
└── tests/
    ├── stdio.test.ts     # MCP stdio 协议与工具集成测试
    ├── windows.test.ts   # Windows 路径与 Explorer 参数单元测试
    └── ui-smoke.mjs      # 离线 Chrome 模拟宿主 UI 测试

许可证

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables offline browsing, previewing, searching, and citing local PDFs, Word, Excel/CSV, Markdown, HTML, images, and code directly in Antigravity's sidebar, with agent integration for opening documents and sending selected text to conversations.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables browsing, editing, and previewing workspace files — Markdown, images, PDFs, and Git diffs — directly inside Google Antigravity's sidebars. Provides a file tree with quick search, CodeMirror-based editing with syntax highlighting, and one-click chat context attachment, all without consuming model tokens.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables previewing local Word, Excel, PowerPoint, PDF, HTML, ZIP, Jupyter Notebook, media, images/SVG, and Markdown files directly in Google Antigravity's sidebar or full-page view, with automatic agent-driven opening and file navigation.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables users to open generated HTML pages, PDFs, Office documents, and images straight from chat cards or a side-pane file list using their OS default application, or to choose another installed app via an Open With dropdown. Also reveals files in Finder or File Explorer, tracks recent outputs across conversations, and blocks risky executable launches.
      MIT