graft
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Why
Tampermonkey is great until you want your agent to help. graft keeps the userscript model (plain files, @match headers) and adds:
Tampermonkey | graft | |
Edit loop | edit in a browser box | edit a file in your editor β page updates instantly |
Coding agent can drive it | no | yes, via MCP (12 tools) |
Agent can see the page | no | DOM outline, screenshot, console, network |
Cross-origin fetch |
|
|
Intercept page fetch/XHR | no |
|
Strict-CSP sites | often blocked | persistent scripts ignore CSP |
Old | yes | yes, unchanged |
Rebuild to change code | no | no |
Related MCP server: browser-relay
Install (2 minutes)
git clone https://github.com/shahaklt/graft && cd graft && npm install
node bin/graft.mjs path # prints the extension folderOpen
chrome://extensions, enable Developer mode, Load unpacked β theextension/folder. (One time. You never rebuild or repack after this.)On graft's extension card, switch on Allow User Scripts (lets persistent scripts ignore page CSP; without it graft falls back to eval).
Add the MCP server to your agent:
# Claude Code
claude mcp add graft -- node /absolute/path/to/graft/bin/graft.mjs mcp
# or straight from GitHub
claude mcp add graft -- npx -y github:shahaklt/graft mcpCursor / Claude Desktop (mcpServers JSON):
{ "mcpServers": { "graft": { "command": "npx", "args": ["-y", "github:shahaklt/graft", "mcp"] } } }Codex: codex mcp add graft -- npx -y github:shahaklt/graft mcp
Try it. Open http://127.0.0.1:7777/playground (served by the hub once running) and ask your agent: "outline the playground page, add a todo, then make the heading green and keep it as a script."
No agent? Run just the hub and hand-write scripts: node bin/graft.mjs dev ./my-scripts.
Writing scripts
~/.graft/scripts/hello.graft.js (or any folder via graft dev <dir>):
// ==Graft==
// @name Hello
// @match https://*.example.com/*
// @run-at document-idle
// ==/Graft==
graft.css(`body{outline:3px solid #9fe870}`);
graft.on('a.buy', el => el.textContent = 'buy (graft)'); // current + future elements
graft.toast('hello π±');Save the file β every open matching tab re-runs it. graft.css, graft.on, graft.toast, graft.panel and graft.net.* handlers are auto-cleaned on hot reload; register your own with graft.cleanup(fn).
The graft object (in scope in every script, never on window)
API | |
| querySelector helpers |
| inject style, returns remover |
| promise for an element |
| run for existing + future matches |
| build DOM |
| shadow-DOM UI, immune to page CSS |
| cross-origin request via the extension ( |
| watch & rewrite page fetch/XHR |
| persistent per-script storage |
| desktop notification |
| run on hot reload |
Tampermonkey headers (==UserScript==, @match, @exclude, @run-at) and GM_addStyle / GM_getValue / GM_setValue / GM_xmlhttpRequest / GM_notification / GM_log / unsafeWindow work too. See examples/scripts.
MCP tools
tool | what |
| is the extension connected, which mode, where scripts live |
| tabs + ids |
| run JS in the page, get JSON back (expression or statements + |
| outline of interactive elements with selectors / html / text |
| click, type (framework-safe), press, scroll |
| PNG of the tab |
| go to a URL |
| console + uncaught errors, or network requests |
| persist a script (hot-reloaded into open tabs) |
| manage scripts |
How it fits together
coding agent ββstdio/MCPβββΆ graft mcp ββ
βββΆ hub (127.0.0.1:7777) ββwsβββΆ extension βββΆ your tabs
~/.graft/scripts/*.graft.js ββwatchβββββMultiple agents can share one hub: the first process starts it, later ones attach over /rpc.
Security model
Hub binds
127.0.0.1only. The extension socket rejects any browserOriginother thanchrome-extension://;/rpcrejects every browser origin.Privileged calls (
graft.fetch,store,notify) cross from the page to the extension over CustomEvents whose names contain a per-session secret. Thegraftobject is never exposed onwindow.Residual risk: a hostile page that monkey-patches
EventTargetbefore graft loads could try to sniff that secret. Don't run graft-privileged scripts on pages you don't trust.Scripts you install run with full access to every site they match. Read them.
graft_evalgives your agent the same power on any open tab, so only connect agents you trust.Optional
debuggerpermission (requested from the popup) lets one-off eval work on strict-CSP pages; Chrome shows a "debugging" banner while it runs.
Limits
Chrome / Chromium (MV3, β₯120) only for now. No chrome:// pages or the Web Store. Page eval on strict-CSP sites needs the debugger permission or a persistent script.
Develop
npm test # protocol smoke test (fake extension)
node scripts/make-icons.mjs # regenerate extension iconsBranding and UI spec for designers: docs/DESIGN-BRIEF.md. Landing page: docs/index.html.
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Live browser debugging for AI assistants β DOM, console, network via MCP.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server for browser automation and console log capture via a Chrome extension, enabling AI-driven DOM interaction, navigation, and screenshot capabilities.2MIT

browser-relayofficial
AlicenseNot gradedqualityDmaintenanceMCP server that drives a user's real Chrome browser via a WebSocket-connected MV3 extension, enabling tab management, navigation, page interaction, screenshots, and script evaluation through natural language.15 npmMIT- AlicenseNot gradedqualityDmaintenanceMCP server that lets coding agents control and inspect live Chrome browsers, providing full Chrome DevTools capabilities for automation, debugging, and performance analysis.1,876,272 npmApache 2.0
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to control a persistent local browser with live tabs, navigation, interaction, inspection, and state management through MCP.6-