monaco-mcp
Writes code into CodeMirror 6 editors via view.dispatch(), bypassing paste blocking, and verifies the editor content by reading it back.
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., "@monaco-mcp write a two-sum solution into the open editor and run it"
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.
monaco-mcp
An MCP server that reads and writes code in web-based code editors from your AI assistant — bypassing paste blocking.
You know the scenario: you ask your assistant to solve a problem, it writes the solution, and then... you can't get it into the Monaco editor on the page because right-click → Paste is disabled, Ctrl+V is swallowed, and drag-and-drop is off.
This server fixes that. It drives a real browser and writes into the editor through the editor's own API, so the code simply appears in the editor — no paste event is ever fired.
How it works
The paste blocker only listens for the paste event. We never send one.
set_code tries a chain of strategies, in order, and verifies the result by reading the editor back:
# | Strategy | When it works |
1 |
| Monaco's public API is on |
2 | DOM expando properties + React prop/fiber walk to find a hidden editor instance | Monaco is bundled (no global), e.g. |
3 | Ace → | Ace editors |
4 | CodeMirror 6 → | CM6 editors |
5 | Focus editor → | Universal fallback. This is IME-style typing, not a paste, so paste blockers don't fire |
The result reports verified: "exact" only after the code was read back out and matched. A silent failure can never look like a success.
Related MCP server: byob
Requirements
Node.js ≥ 18.17
Google Chrome or Microsoft Edge (auto-detected), or any Chromium via
MONACO_MCP_EXECUTABLE
Install
git clone https://github.com/siddubakka/monaco-mcp.git
cd monaco-mcp
npm installRun the test suite (opens a browser, loads a fixture with paste blocked, injects code, asserts nothing was pasted):
npm testConfigure
The server speaks MCP over stdio. Point your client at src/index.js.
OpenCode
~/.config/opencode/opencode.json (or a project-level opencode.json):
{
"mcp": {
"servers": {
"monaco": {
"type": "local",
"command": ["node", "/absolute/path/to/monaco-mcp/src/index.js"],
"timeout": 120000
}
}
}
}The default MCP timeout is 5000 ms, which is too short for a cold browser launch. Raise
timeout.
Claude Desktop
claude_desktop_config.json:
{
"mcpServers": {
"monaco": {
"command": "node",
"args": ["/absolute/path/to/monaco-mcp/src/index.js"]
}
}
}Cursor / Windsurf
{
"mcpServers": {
"monaco": {
"command": "node",
"args": ["/absolute/path/to/monaco-mcp/src/index.js"]
}
}
}Windows: use forward slashes (
C:/Users/you/...) so JSON needs no escaping.
Once published to npm you can use npx -y monaco-mcp instead of node path/to/src/index.js.
Configuration (environment variables)
Variable | Default | Purpose |
|
| Persistent browser profile. Log in once, sessions survive restarts. |
| (unset) | Attach to a browser you started yourself instead of launching one. |
| auto ( | Which browser to launch. |
| (unset) | Explicit path to a Chromium-family binary. |
|
| Run without a window (some sites refuse headless). |
| (unset) | Extra CLI args, comma separated. |
Attach to your own Chrome (keeps the logins you already have):
{
"mcp": {
"servers": {
"monaco": {
"type": "local",
"command": ["node", "/path/to/monaco-mcp/src/index.js"],
"environment": { "MONACO_MCP_CDP_URL": "http://127.0.0.1:9222" },
"timeout": 120000
}
}
}
}Start Chrome with debugging enabled first (fully quit Chrome first, or the flag is ignored):
chrome.exe --remote-debugging-port=9222Tools
Tool | Purpose |
| Open or navigate to a URL. |
| List open tabs. |
| Read the page's visible text (problem statement, output panel, verdict). |
| Read the current editor contents. |
| Write code into the editor, bypassing paste blocking. Supports |
| Diagnostics: which editors were detected and how. Use when |
| Click a button or link by its visible text ( |
| Wait for text to appear — e.g. a verdict like |
| Capture the page as an image. |
| Close the managed browser (logins are kept in the profile). |
A typical session
user: solve the problem in the open tab
assistant: open_page(...) # or use the tab already open
get_content() # read the problem statement
set_code(code=...) # code lands in the editor, verified exact
click_element(text="Run") # run the sample tests
wait_for(text="Accepted")
screenshot() # show the resultNotes
The browser starts lazily on the first tool call, so the MCP server starts instantly.
Only one "current" page is targeted — the most recently used one.
open_pageselects it.set_codeoverwrites the editor (mode: "append"if you want to add instead).
License
MIT
Available Tools
10 toolsclick_elementClick elementA
Click a button or link by its visible text. This is how you press Run, Submit, Test, or switch tabs. Matches buttons and links first, then any visible text.
Inputs: text (required), timeoutMs.
close_browserClose browserBDestructive
Close the browser this server controls (including the profile it launched). Sessions are saved to the profile, so logins survive.
Inputs: no named parameters.
get_codeRead editor codeARead-only
Read the current contents of the code editor on the page. Returns the code plus which editor instance it came from.
Inputs: modelIndex.
get_contentRead page textARead-only
Read the visible text of the current page (main content when it can be identified). Use it to read a problem statement, output panel, or verdict.
Inputs: maxChars, selector.
inspect_editorInspect editorsARead-only
Diagnostics: report which editors exist on the page (Monaco global API, Monaco DOM nodes, React fibers, CodeMirror, Ace). Use this when set_code fails.
Inputs: no named parameters.
list_pagesList pagesARead-only
List the tabs currently open in the managed browser.
Inputs: no named parameters.
open_pageOpen pageA
Open (or navigate to) a URL in the managed browser. Use this first, or to move between problems.
Inputs: url (required), newTab.
screenshotScreenshot pageCRead-only
Capture the current page so you can see the editor state, results, or any error.
Inputs: fullPage, maxWidth.
set_codeInject code into editorADestructive
Write code into the page's code editor, bypassing paste blocking. Tries the editor's own API first, then falls back to IME-style typing (insertText, never a paste event). The result is verified by reading the editor back, so 'verified: exact' means the code really is in the editor.
Inputs: code (required), mode, modelIndex.
wait_forWait for textARead-only
Wait until some text appears on the page. Use after Run/Submit to wait for the verdict, e.g. 'Accepted' or 'Wrong Answer'.
Inputs: text (required), timeoutMs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
The core intents are clearly separated: navigate (open_page), read page text (get_content), read editor code (get_code), write code (set_code), and interact (click_element, wait_for). Minor overlap exists between open_page and click_element (both can change the page) and between get_content/screenshot/get_code as ways to 'see' state, but descriptions steer the agent correctly. inspect_editor is well-differentiated as a fallback diagnostic for set_code failures.
Nine of ten tools follow a clean snake_case verb_noun or verb_noun-ish pattern (open_page, list_pages, get_content, set_code, click_element, wait_for, close_browser, inspect_editor). The lone outlier is 'screenshot', which is a bare noun rather than an action phrase like capture_screenshot. Otherwise highly predictable.
Ten tools is well-scoped for a browser-plus-Monaco-editor automation server; each tool maps to a distinct step in the solve loop (navigate, read, edit, run, wait, verify). No redundant or filler tools, and no obvious need to split or merge any of them.
The read/edit/run/verify loop is fully covered, including a diagnostic fallback (inspect_editor) and session persistence. However, there is no general text-input tool for non-editor fields (login forms, search boxes, custom test-case inputs), which is a real dead end despite the note that logins survive via the profile. Scrolling/selector-based clicking beyond visible text is also absent.
Related MCP Connectors
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
AI-powered browser automation — navigate, click, fill forms, and extract data from any website.
Let your AI agent operate any website through a real, logged-in browser session.
Stealth web automation for AI agents. Login, signup, navigate, screenshot.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to control the user's real Chrome or Firefox tabs, with their existing logins, to read pages, click, type, fill forms, take screenshots, inspect network traffic and run JavaScript. It works through a paired browser extension over a local WebSocket connection, so automation happens in the browser the user is actually looking at, including shadow DOM, cross-origin iframes, dialogs and single-page apps.MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to drive the user's real, already-logged-in Chrome browser locally, so they can read and navigate pages, click, type, fill forms, take screenshots, and inspect cookies, tabs, console, and network traffic without headless browsers or remote-debugging ports.1 npmISC
- AlicenseNot gradedqualityAmaintenanceLets AI coding tools drive the real, already-logged-in Chrome browser over local stdio—snapshotting and reading pages, clicking, typing, managing tabs, capturing screenshots, and inspecting network, console, storage, and cookies—without opening a remote-debugging port. It installs as a Chrome extension plus native-messaging bridge, so agents work in the user's authenticated sessions while passing bot detection.1 npmISC
- AlicenseNot gradedqualityAmaintenanceLets AI coding tools drive the user's already-signed-in Chrome browser — reading and snapshotting pages, clicking, typing, uploading files, screenshotting, and inspecting tabs, cookies, console, and network traffic. It works through a local Chrome extension bridge, so no remote debugging port is opened and the real, authenticated browser session is used.1 npmISC