Skip to main content
Glama

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.editor.getEditors() / getModels() → setValue()

Monaco's public API is on window

2

DOM expando properties + React prop/fiber walk to find a hidden editor instance

Monaco is bundled (no global), e.g. @monaco-editor/react

3

Ace → ace.edit(node).setValue()

Ace editors

4

CodeMirror 6 → view.dispatch()

CM6 editors

5

Focus editor → Ctrl+A → keyboard.insertText()

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 install

Run the test suite (opens a browser, loads a fixture with paste blocked, injects code, asserts nothing was pasted):

npm test

Configure

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

MONACO_MCP_PROFILE_DIR

~/.monaco-mcp/profile

Persistent browser profile. Log in once, sessions survive restarts.

MONACO_MCP_CDP_URL

(unset)

Attach to a browser you started yourself instead of launching one.

MONACO_MCP_CHANNEL

auto (chrome, msedge, chromium)

Which browser to launch.

MONACO_MCP_EXECUTABLE

(unset)

Explicit path to a Chromium-family binary.

MONACO_MCP_HEADLESS

1 to enable

Run without a window (some sites refuse headless).

MONACO_MCP_ARGS

(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=9222

Tools

Tool

Purpose

open_page

Open or navigate to a URL.

list_pages

List open tabs.

get_content

Read the page's visible text (problem statement, output panel, verdict).

get_code

Read the current editor contents.

set_code

Write code into the editor, bypassing paste blocking. Supports replace / append.

inspect_editor

Diagnostics: which editors were detected and how. Use when set_code fails.

click_element

Click a button or link by its visible text (Run Code, Submit, …).

wait_for

Wait for text to appear — e.g. a verdict like Accepted.

screenshot

Capture the page as an image.

close_browser

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 result

Notes

  • 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_page selects it.

  • set_code overwrites the editor (mode: "append" if you want to add instead).

License

MIT

Available Tools

10 tools
click_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 browserB
Destructive

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 codeA
Read-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 textA
Read-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 editorsA
Read-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 pagesA
Read-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 pageC
Read-only

Capture the current page so you can see the editor state, results, or any error.

Inputs: fullPage, maxWidth.

set_codeInject code into editorA
Destructive

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 textA
Read-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

    A3.5/5.0

    Scored across 10 tools

    Disambiguation4/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness3/5

    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

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables 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 npm
      ISC
    • A
      license
      Not graded
      quality
      A
      maintenance
      Lets 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 npm
      ISC
    • A
      license
      Not graded
      quality
      A
      maintenance
      Lets 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 npm
      ISC