Tampermonkey Mcp

io.github.Tampermonkey由 GitHub 帳號 Tampermonkey 發布v0.0.4更新於 Oct 24, 2026

MCP server to manage your Tampermonkey scripts

已驗證STDIO僅桌面瀏覽器自動化開發者工具

概覽

AI 產生的概覽

讓 AI 助理透過 Tampermonkey Editors 瀏覽器擴充功能讀取、建立、修改與刪除 Tampermonkey 使用者腳本。

可以做什麼
  • 取得連線碼,將伺服器與 Tampermonkey Editors 擴充功能配對
  • 列出使用者腳本,可依名稱或 URL 樣式篩選
  • 讀取腳本內容與最後修改時間
  • 更新腳本內容,可選擇性使用樂觀鎖定
  • 建立新的使用者腳本並刪除既有腳本
適用情境
適合已在 Tampermonkey 中維護瀏覽器使用者腳本、希望助理直接檢視、改寫、新增或刪除腳本而不必手動複製貼上程式碼的情境。僅限桌面環境,對象是已在 Chrome 或 Firefox 使用 Tampermonkey 的人。
執行需求
以本機程序方式透過 npm 執行(npx tampermonkey-mcp 或全域安裝),需在桌上型電腦使用。需要安裝 Tampermonkey 擴充功能,以及適用於 Chrome 或 Firefox 的 Tampermonkey Editors 擴充功能,並把助理回傳的連線碼輸入該擴充功能。建立與刪除腳本需 Tampermonkey Editors 1.0.6+ 與 Tampermonkey 5.6+。
安裝前請注意
助理可以覆寫、新增與永久刪除使用者腳本,確認前請先檢視變更。配對依賴連線碼,該碼可存取你的腳本庫,應視為機密,只輸入到 Editors 擴充功能中。腳本會在瀏覽器中執行,助理產生的程式碼使用前應先審查。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Tampermonkey Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

How to use

First install the following browser extensions:

Then install tampermonkey-mcp globally:

bash
npm install -g tampermonkey-mcp@latest

Finally configure your AI assistant to use the tampermonkey tool:

bash
{  "mcpServers": {    "tampermonkey": {      "command": "npx",      "args": [        "-y",        "tampermonkey-mcp@latest"      ]    }  }}

Your assistant will call tampermonkey_get_connection_code and return a connection code that you can enter in the Tampermonkey Editors extension.

Claude Code configuration example

npm install -g @anthropic-ai/claude-code
// either use your local checkoutnpm run watchclaude mcp add --transport http --scope project tampermonkey http://localhost:4001/mcp
// or the npm packagenpm install -g tampermonkey-mcp@latestclaude mcp add --transport stdio --scope project tampermonkey -- npx -y tampermonkey-mcp
// more browser control needed?// Open chrome://inspect/#remote-debugging// [x] Allow remote debugging for this browser instance// orchromium --user-data-dir=/tmp/chrome-devtools-mcp-test-profile --remote-debugging-port=9222
npm install -g chrome-devtools-mcp@latest// install Tampermonkey and Tampermonkey Editorsclaude mcp add --transport stdio --scope project chrome-devtools-mcp -- npx -y chrome-devtools-mcp@latest --slim --no-usage-statistics --auto-connect --browser-url http://127.0.0.1:9222

Build

bash
npm installnpm run all

Tampermonkey MCP Server Architecture

Overview

This project implements an MCP (Model Context Protocol) server that allows AI assistants to read and modify Tampermonkey userscripts via the Tampermonkey Editors browser extension.

Architecture Components

┌─────────────────────────────────────────────────────────────────────────────┐│                              AI Assistant                                   │└─────────────────────────────────────────────────────────────────────────────┘                                   │                                   │ MCP Protocol (stdio transport)                                   ▼┌─────────────────────────────────────────────────────────────────────────────┐│                         tampermonkey_mcp (MCP Server)                       ││                                                                             ││  ┌───────────────────────────────────────────────────────────────────────┐  ││  │  server.ts                    │  Main entry point                     │  ││  │                               │  - HTTP or stdio transport            │  ││  │                               │  - MCP middleware                     │  ││  └───────────────────────────────────────────────────────────────────────┘  ││                                  │                                          ││                                  ▼                                          ││  ┌───────────────────────────────────────────────────────────────────────┐  ││  │  tampermonkey.ts              │  MCP Tool Definitions                 │  ││  │                               │  - tampermonkey_get_connection_code   │  ││  │                               │  - tampermonkey_list                  │  ││  │                               │  - tampermonkey_get                   │  ││  │                               │  - tampermonkey_patch                 │  ││  └───────────────────────────────────────────────────────────────────────┘  ││                                  │                                          ││                                  ▼                                          ││  ┌───────────────────────────────────────────────────────────────────────┐  ││  │  tampermonkey-ws-client.ts    │  WebSocket Server                     │  ││  │                               │  - Connection code generation         │  ││  │                               │  - Authentication handshake           │  ││  │                               │  - Message relay to extension         │  ││  └───────────────────────────────────────────────────────────────────────┘  │└─────────────────────────────────────────────────────────────────────────────┘                                   │                                   │ WebSocket (local, port derived from code)                                   ▼┌─────────────────────────────────────────────────────────────────────────────┐│                   Tampermonkey Editors Extension                            ││                                                                             ││  ┌───────────────────────────────────────────────────────────────────────┐  ││  │  Service Worker               │  Receives connection code,            │  ││  │                               │  establishes WebSocket connection     │  ││  └───────────────────────────────────────────────────────────────────────┘  ││                                  │                                          ││                                  │ Chrome Extension Messaging               ││                                  ▼                                          ││  ┌───────────────────────────────────────────────────────────────────────┐  ││  │  Content Script               │  Bridges extension ↔ Tampermonkey     │  ││  └───────────────────────────────────────────────────────────────────────┘  ││                                  │                                          ││                                  ▼                                          ││  ┌───────────────────────────────────────────────────────────────────────┐  ││  │  Tampermonkey                 │  Userscript storage & execution       │  ││  └───────────────────────────────────────────────────────────────────────┘  │└─────────────────────────────────────────────────────────────────────────────┘

Connection Flow

  1. MCP Server starts - Creates WebSocket server on a random available port
  2. Connection code generated - Format: <base32(port - 1024)><auth_token><echo_token>
  3. User calls tampermonkey_get_connection_code - Gets the connection code
  4. User enters code in Tampermonkey Editors - Extension parses code to get port and auth
  5. Extension connects to MCP server - WebSocket handshake with authentication
  6. MCP tools become available - list, get, patch can now be called

Authentication Protocol

Extension                              MCP Server    │                                      │    │───── auth (token) ──────────────────>│    │                                      │    │<──── auth (echo_token) ──────────────│    │                                      │    │───── auth (echo_token) ─────────────>│    │                                      │    │<──── authOK ─────────────────────────│    │                                      │    │<───── pings (every 15s) ─────────────│  (keep-alive)    │───── pongs ─────────────────────────>│    │                                      │    │<───── commands (list/get/patch) ─────│    │───── responses ─────────────────────>│

MCP Tools

tampermonkey_get_connection_code

  • Purpose: Initialize connection by getting the WebSocket connection code.
  • Required: Must be called first to start the WebSocket server.
  • Output: Connection code to enter in Tampermonkey Editors.

tampermonkey_list

  • Purpose: List all available userscripts.
  • Input: Optional filter by name pattern or include URL pattern.
  • Output: Array of userscript metadata (name, namespace, path, requires).

tampermonkey_get

  • Purpose: Get content of a specific userscript.
  • Input: path (from list), optional ifNotModifiedSince timestamp.
  • Output: Script content, lastModified timestamp, or error.

tampermonkey_patch

  • Purpose: Update userscript content.
  • Input: path, value (new content), optional lastModified for optimistic locking.
  • Output: Success confirmation or error.

tampermonkey_put

  • Purpose: Create a new userscript with the given name and namespace.
  • Input: value (new script), optional lastModified.
  • Output: Success confirmation, path of created script, or error.
  • Requires: Tampermonkey Editors 1.0.6+ and Tampermonkey 5.6+

tampermonkey_delete

  • Purpose: Delete an existing userscript.
  • Input: path (from list).
  • Output: Success confirmation or error.
  • Requires: Tampermonkey Editors 1.0.6+ and Tampermonkey 5.6+

Basic testing

MCP Server capabilities

bash
curl -X POST http://localhost:4001/mcp \  -H "Content-Type: application/json" \  -H "Accept: application/json, text/event-stream" \  -d '{    "jsonrpc": "2.0",    "id": 1,    "method": "initialize",    "params": {      "protocolVersion": "2024-11-05",      "clientInfo": {        "name": "curl-client",        "version": "1.0.0"      },      "capabilities": {}    }  }'

test stdio

bash
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"test-client","version":"1.0.0"},"capabilities":{}}}' | npx -y tampermonkey-mcpecho '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | npx -y tampermonkey-mcpecho '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"tampermonkey_list","arguments":{"pattern":""}}}' | npx -y tampermonkey-mcp

來源:README.md,提交 72a8ae1

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.0.4最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。