Antigravity Office & PDF Preview
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 Office & PDF Preview preview the Word report you just generated in the right panel"
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 Office & PDF Preview (antigravity-office-preview)
Google Antigravity 桌面端原生文档预览插件(MCP App) —— 在 Antigravity 对话右侧面板内直接原样预览 Word (
.docx)、Excel (.xlsx/.xls/.csv)、PowerPoint (.pptx)、PDF (
为什么做这个插件?
在 Google Antigravity 2.0 桌面端 对话时,点击 AI 生成的 .docx / .xlsx / .pptx 等文档链接,内置文件查看器会提示 「此文件类型不支持预览」,每次都要手动下载或切到外部软件打开,体验很割裂。
本插件基于 Antigravity 官方 MCP Apps (ext-apps) 协议构建,把纯前端开源渲染引擎封装成一个零云端上传的本地插件,直接嵌入 Antigravity 右侧 + 面板与左侧边栏:
AI 生成即预览:插件自带 Agent 规则,AI 生成或修改 Word / Excel / PPT / PDF 后,可直接调用工具在右侧面板自动原样弹出预览。
零下载、纯本地离线:所有渲染均在本地沙箱内完成,文档不会上传到任何第三方服务器。
开箱即用:仓库已内置打包好的单文件前端
dist/viewer.html,克隆安装依赖即可直接启用。
Related MCP server: doc-viewer
支持格式与核心功能
文件类型 | 支持扩展名 | 内置开源渲染引擎 | 支持特性 |
Word 文档 |
|
| 还原原始表格、底纹、字号、页眉页脚与 A4 分页;支持自适应宽度与手动缩放 |
Excel / 表格 |
| 多工作表(Sheet)标签切换、大表横纵向滚动浏览 | |
PowerPoint 幻灯片 |
| 支持 瀑布流滚动 与 单页翻页 两种浏览模式 | |
PDF 文档 |
| 高清 Retina Canvas 逐页懒加载渲染、自适应宽度与缩放控制 |
通用交互功能:
拖拽直览:把电脑里任意
.docx/.xlsx/.pptx/.pdf直接拖进预览面板即可打开。路径直达:顶部输入框粘贴本机绝对路径(支持
~与file://),按回车即预览。近期文档自动发现:自动记住最近打开过的文档,并快速列出桌面 / 下载 / Antigravity Scratch 目录中的近期文档,一键点开。
实时刷新 & 主题跟随:AI 修改文档后点「刷新」即可重载;自动跟随 Antigravity 深色 / 浅色主题。
快速安装(macOS / Linux)
前置条件
已安装 Google Antigravity 桌面端
本机已安装 Node.js >= 18(终端运行
node -v可查看)
方式一:一键脚本安装(推荐)
打开终端执行:
curl -fsSL https://raw.githubusercontent.com/1058772968-dotcom/antigravity-office-preview/main/install.sh | bash方式二:Git 手动安装
mkdir -p ~/.gemini/config/plugins
git clone https://github.com/1058772968-dotcom/antigravity-office-preview.git ~/.gemini/config/plugins/office-preview
cd ~/.gemini/config/plugins/office-preview
chmod +x bin/office-preview-server
npm install --omit=dev生效方式:Antigravity 会自动扫描
~/.gemini/config/plugins/目录下的插件,通常无需重启客户端。如果你正在当前对话中,下一轮对话起 AI 即可直接调用该工具;也可以在 Antigravity 左侧「Skills & Customizations / 插件管理」中查看或开关 Office & PDF 文档预览器。
使用方法(3 种打开方式)
1. 让 AI 直接帮你打开预览(最常用)
安装完成后,插件内置的 rules/AGENTS.md 会自动生效。以后你在对话里直接说:
帮我生成一份 Word 报告并在右侧预览帮我预览刚才生成的 docx / pptx / pdf打开桌面上的 ~/Desktop/季度汇报.pptx 预览一下
AI 会自动调用 preview_office_file 工具,在右侧面板原样渲染该文档。
2. 从 Antigravity 右侧「+」号或左侧边栏手动打开
点击 Antigravity 右侧辅助面板顶部标签栏的
+按钮(或点击左侧边栏入口)。选择 「Office 预览」。
面板会自动列出你本机近期找到的 Office / PDF 文档,点一下即可打开。
3. 拖入本地文件或粘贴路径
在打开的 「Office 预览」 面板中:
直接从 Finder / 文件管理器把
.docx/.xlsx/.pptx/.pdf拖进面板;或点击右上角 「打开文件」 按钮选择文件;
或在顶部路径栏粘贴文件路径并回车。
仓库目录结构
antigravity-office-preview/
├── plugin.json # Antigravity 插件元数据声明
├── mcp_config.json # MCP Server 启动配置(使用 ${PLUGIN_ROOT} / ${PLUGIN_DATA})
├── install.sh # macOS / Linux 一键安装与更新脚本
├── assets/
│ └── logo.svg # 插件图标
├── bin/
│ └── office-preview-server # 跨环境 Node.js 启动包装脚本(兼容 Homebrew / nvm / fnm / volta)
├── rules/
│ └── AGENTS.md # 内置 Agent 规则:生成或预览文档时自动调用本插件
├── server/
│ └── index.mjs # 本地 Stdio MCP Server(暴露 preview_office_file 与应用私有工具)
├── src/
│ ├── app.js # 前端 MCP App 交互与 4 类文档渲染入口
│ └── build-ui.mjs # 单文件 HTML 离线打包脚本
└── dist/
└── viewer.html # 预构建单文件离线预览界面(零外部 CDN,兼容严苛 CSP)架构说明(给想二次开发的开发者)
单文件离线打包:Antigravity MCP App 沙箱默认开启
default-src 'none'CSP,因此src/build-ui.mjs将@modelcontextprotocol/ext-apps、docx-preview、xlsx、pptx-preview及pdfjs-dist(含内联主线程 Worker)全部打包为单个离线dist/viewer.html。绕开 1 MiB 轨迹限制:模型调用
preview_office_file(path)时仅返回轻量级元信息(文件名、大小、路径);前端界面收到后再通过应用私有工具app_load_file(visibility: ["app"])按需读取二进制数据,最大支持 25 MB 本地文件。安全边界:服务端仅允许读取白名单后缀(
.docx/.xlsx/.xls/.csv/.pptx/.pdf),拒绝读取其他任意敏感文件。
本地修改与重新打包
npm install
npm run build修改 src/app.js 或 src/build-ui.mjs 后执行 npm run build 即可重新生成 dist/viewer.html(优先使用 bun,未安装时自动回退到 npx esbuild)。
常见问题(FAQ)
Q:为什么点击聊天气泡里的 .docx 链接还是提示「此文件类型不支持预览」?
A:点击普通 file:// 链接走的是 Antigravity 客户端内置文件查看器,第三方插件无法接管它。请直接让 AI 调用预览(或从右侧 + 号打开「Office 预览」面板查看)。
Q:插件启动失败怎么办?
A:请确认本机已安装 Node.js >= 18,并在插件目录执行过 npm install --omit=dev 以及 chmod +x bin/office-preview-server。
Q:如何卸载?
A:在 Antigravity 的插件管理页卸载,或直接删除 ~/.gemini/config/plugins/office-preview 目录即可。
致谢与协议
本项目基于以下优秀开源项目构建,采用 MIT License 开源,欢迎 Star、Issue 与 PR:
Available Tools
3 toolsapp_list_recent获取近期文档列表A
供 Office 预览界面列出近期打开或本地常见目录中的 .docx / .xlsx / .pptx / .pdf 文档。
Inputs: no named parameters.
app_load_file读取本地文档数据A
供 Office 预览界面按路径读取本机 .docx / .xlsx / .xls / .csv / .pptx / .pdf 二进制数据。
Inputs: path (required).
preview_office_fileOffice 预览A
在 Antigravity 右侧面板中直接原样预览本机 Word (.docx)、Excel (.xlsx/.xls/.csv)、PowerPoint (.pptx) 或 PDF (.pdf) 文档。不传 path 时打开空预览器与近期文档列表。
Inputs: path.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
app_list_recent and app_load_file are clearly distinct (listing vs. reading bytes), but preview_office_file overlaps both: with no path it opens an empty previewer with a recent-documents list, duplicating app_list_recent, and it implicitly reads documents that app_load_file reads explicitly. The descriptions hint at the split, but an agent could plausibly pick the wrong tool for 'show me recent files'.
Two tools use an app_ prefix (app_list_recent, app_load_file) while the third uses preview_ (preview_office_file), and the verb-noun ordering differs (list_recent vs. load_file vs. preview_office_file). The names remain readable and snake_case throughout, but the prefix scheme is inconsistent.
Three tools is on the thin side even for a narrow preview-focused server; listing, previewing, and raw loading could arguably be two tools. Each does earn its place, so it is borderline rather than excessive.
The core flow of discover recent files, render a preview, and fetch raw bytes for a given path is covered for all advertised formats. Minor gaps exist (no document metadata/info, no search by name, no way to close or refresh the preview panel), but agents can work around these via app_list_recent and app_load_file.
Maintenance
Related MCP Connectors
Convert, create and edit Word, PowerPoint, Excel and PDF documents from any AI agent.
Send files as tracked links from any AI agent and see who opened them, page by page.
Online office suite for AI agents: edit docs, sheets, slides and PDFs in browser or via MCP.
Create, open and edit documents, spreadsheets and PDFs in MR Office's editor, inline in chat.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables Google Antigravity agents to quickly inspect and read PDF, Word, Excel, PowerPoint, and text documents, extracting structure and content as token-efficient Markdown.-
- AlicenseNot gradedqualityCmaintenanceEnables 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.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables 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
- AlicenseNot gradedqualityBmaintenanceEnables 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