{"slug": "when-an-mcp-server-wasn-t-enough-building-a-vscode-extension-for-sheets", "title": "When an MCP Server Wasn't Enough: Building a VSCode Extension for Sheets", "summary": "A developer built a VSCode extension, google-sheets-preview, after finding that an existing Google Sheets MCP server (@beatmaster/google-sheets-mcp) still forced browser round-trips for editing and formatting checks. The extension renders Google Sheets data and formatting as an HTML table in a VSCode webview, supports cell editing and sheet management, and opens previews via a vscode:// URI handler so Claude can launch the correct sheet tab directly. The developer reports that caching sheet data in memory fixed tab-switch lag, while initial load time remains slow.", "body_md": "This post was generated by an AI agent from an article the account owner published in Japanese on note. The wording is not human-written.\n\nA project that built an MCP server letting Claude Code create, read, write, format, and share Google Sheets directly ran into a practical snag once it was in daily use: any fine-tuning after the AI generated something still required switching to a browser. Fixing a bit of wording, or checking formatting after a spec change, meant opening the spreadsheet in a browser, finding the right cell, editing it, and switching back to VSCode. That back-and-forth became the next problem to solve.\n\nThe setup for this second project:\n\n`@beatmaster/google-sheets-mcp` (npm package)`google-sheets-preview` (VSCode extension)\nThe first idea was to add a `sheets_preview` tool to the existing MCP server. The approach was simple: fetch the spreadsheet's data and formatting, generate an HTML file, and open it automatically in a browser. To keep token usage down, the HTML itself was never sent back to Claude — only the file path was returned, with a message saying the preview had been shown.\n\nAfter implementing it and publishing the update, the result was underwhelming. It still opened a browser, so the back-and-forth with VSCode didn't go away. If anything, the sequence now felt longer: call the MCP tool, wait for the browser to open, check the result, switch back to VSCode. That made it clear the approach itself was wrong at a fundamental level.\n\nThe actual goal was viewing the spreadsheet inside VSCode. An MCP server gives an AI new tools to call, but it has no way to control VSCode's own UI — the editor panes, panels, and so on. MCP communicates over stdio, standard input/output, so there's no mechanism for drawing anything on screen.\n\nShowing a spreadsheet inside VSCode required VSCode's \"Webview Panel\" feature, which only a VSCode extension can use. That meant building a separate extension from scratch, apart from the MCP server. Development shifted to this new extension.\n\nThe extension pulls all data and formatting from the Google Sheets API and renders it as an HTML table inside a VSCode webview.\n\nViewing features:\n\nEditing features:\n\nSheet management:\n\nThree ways to open a preview were added: pressing Ctrl+Shift+G and entering a URL, running \"Google Sheets: Open Preview\" from the command palette, or selecting a spreadsheet URL in the editor and right-clicking it.\n\nSwitching sheet tabs triggered a new Google Sheets API request every time, causing a few seconds of lag. The fix was caching loaded sheet data in memory: after the first load, switching tabs shows the cached version immediately while the latest data is fetched in the background.\n\nThe Dropbox file-locking issue from the earlier MCP server build showed up again: compiling TypeScript inside a Dropbox-synced folder produced an EBUSY error. The same workaround applied — copy the project to a temporary folder, build there, and copy only the output back.\n\nA separate issue came from `vsce`, the VSCode extension packaging tool, which turned out to be incompatible with Node.js v18 and errored out at runtime. The fix was to build the VSIX package (the extension's packaging format) manually instead of relying on `vsce`.\n\nTo connect the extension back to Claude, VSCode's URI handler feature was used — a mechanism where a specific URI scheme automatically launches the extension. When Claude runs a command like:\n\n```\nvscode://beatmaster.google-sheets-preview/open?spreadsheetId=XXX&gid=YYY\n```\n\nthe preview opens directly inside VSCode. The `gid` parameter in the URL is used to automatically select the right sheet tab, so the correct sheet opens immediately.\n\nWhat ended up working: formatted spreadsheet previews inside VSCode, direct cell editing without leaving VSCode, no more switching to a browser, and automatic preview display just by telling Claude which spreadsheet to open.\n\nTwo things remain unresolved: the initial load is still slow, since the first API call takes a few seconds, and chart rendering is difficult because of limitations in the Sheets API.\n\nThe project clarified how the two tools divide labor. An MCP server exists to give an AI new tools to call. A VSCode extension exists to let a human see the result visually. Only with both in place does a full loop — the AI acting, and a human checking the outcome by eye — stay entirely inside VSCode.\n\nThe MCP server package from the earlier project is available at [https://www.npmjs.com/package/@beatmaster/google-sheets-mcp](https://www.npmjs.com/package/@beatmaster/google-sheets-mcp).\n\nFollow [@kmrb_works](https://dev.to/kmrb_works) here on DEV for more field notes from real development work. Also on [X](https://x.com/kmrb_works) and [note](https://note.com/quirky_hosta1908), mostly in Japanese.", "url": "https://wpnews.pro/news/when-an-mcp-server-wasn-t-enough-building-a-vscode-extension-for-sheets", "canonical_source": "https://dev.to/kmrb_works/when-an-mcp-server-wasnt-enough-building-a-vscode-extension-for-sheets-3p4m", "published_at": "2026-11-30 13:02:16+00:00", "updated_at": "2026-11-30 13:15:16.212865+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "developer-tools", "ai-tools"], "entities": ["Claude Code", "Google Sheets", "VSCode", "Dropbox", "vsce", "Node.js", "@beatmaster/google-sheets-mcp", "google-sheets-preview"], "also_reported_by": [], "takeaway": "An MCP server can't draw in VSCode's UI, so pair it with a VSCode extension that uses Webview Panels and a vscode:// URI handler to open the right sheet tab, and cache loaded sheet data in memory to avoid multi-second tab-switch lag.", "recommendation": {"advice": "When an MCP tool needs to render UI, build a companion VSCode extension with a Webview Panel and a vscode:// URI handler, and cache fetched data in memory to keep tab switches instant.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/when-an-mcp-server-wasn-t-enough-building-a-vscode-extension-for-sheets", "markdown": "https://wpnews.pro/news/when-an-mcp-server-wasn-t-enough-building-a-vscode-extension-for-sheets.md", "text": "https://wpnews.pro/news/when-an-mcp-server-wasn-t-enough-building-a-vscode-extension-for-sheets.txt", "jsonld": "https://wpnews.pro/news/when-an-mcp-server-wasn-t-enough-building-a-vscode-extension-for-sheets.jsonld"}}