deputy-mcp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/deputy-mcp.js +99 -13
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -11,6 +11,9 @@ codex mcp add deputy -- npx -y deputy-mcp # Codex
|
|
|
11
11
|
|
|
12
12
|
Any other MCP client: run `npx -y deputy-mcp` as a stdio server.
|
|
13
13
|
|
|
14
|
+
Deputy needs a [Deputy Pro](https://razin.ai/deputy/) license key, pasted on the extension's setup
|
|
15
|
+
page. The free, open-source version is at [github.com/zraisan/deputy](https://github.com/zraisan/deputy).
|
|
16
|
+
|
|
14
17
|
Several clients can use the same browser at once. The first one to start owns the connection to
|
|
15
18
|
the extension on `127.0.0.1:7331`; later ones share it, and take over if it exits. `DEPUTY_PORT`
|
|
16
19
|
picks another port.
|
package/dist/deputy-mcp.js
CHANGED
|
@@ -69329,15 +69329,67 @@ function pixelNote(visual, hasPro) {
|
|
|
69329
69329
|
import { readFile, stat } from "node:fs/promises";
|
|
69330
69330
|
import { extname as extOf } from "node:path";
|
|
69331
69331
|
import { basename, extname, isAbsolute } from "node:path";
|
|
69332
|
+
|
|
69333
|
+
// packages/shared/src/access.ts
|
|
69334
|
+
var CAPABILITIES = {
|
|
69335
|
+
screenshots: {
|
|
69336
|
+
label: "See pages as images",
|
|
69337
|
+
tools: ["browser_screenshot", "browser_look"]
|
|
69338
|
+
},
|
|
69339
|
+
devtools: {
|
|
69340
|
+
label: "Read console messages and network requests",
|
|
69341
|
+
tools: ["browser_console", "browser_network"]
|
|
69342
|
+
},
|
|
69343
|
+
uploads: {
|
|
69344
|
+
label: "Upload files from this computer to a page",
|
|
69345
|
+
tools: ["browser_upload"]
|
|
69346
|
+
},
|
|
69347
|
+
downloads: {
|
|
69348
|
+
label: "Read files that pages download",
|
|
69349
|
+
tools: ["browser_downloads"]
|
|
69350
|
+
}
|
|
69351
|
+
};
|
|
69352
|
+
function parseOff(stored) {
|
|
69353
|
+
if (!Array.isArray(stored))
|
|
69354
|
+
return [];
|
|
69355
|
+
return [...new Set(stored.filter((c) => typeof c === "string" && Object.hasOwn(CAPABILITIES, c)))];
|
|
69356
|
+
}
|
|
69357
|
+
function hiddenTools(off) {
|
|
69358
|
+
return off.flatMap((c) => [...CAPABILITIES[c].tools]);
|
|
69359
|
+
}
|
|
69360
|
+
|
|
69361
|
+
// packages/deputyd/src/core.ts
|
|
69332
69362
|
var EMPTY = new Registry;
|
|
69333
69363
|
var current = null;
|
|
69334
69364
|
var NOT_CONNECTED = "Deputy can't reach the browser: the Deputy extension isn't connected. Make sure Chrome is open with " + "the Deputy extension installed and enabled (https://razin.ai/deputy); it connects by itself within a few seconds.";
|
|
69335
69365
|
async function needBrowser() {
|
|
69336
69366
|
if (!await link.ready(1e4))
|
|
69337
69367
|
throw new Error(NOT_CONNECTED);
|
|
69368
|
+
const why = current?.locked?.();
|
|
69369
|
+
if (why)
|
|
69370
|
+
throw new Error(why);
|
|
69338
69371
|
}
|
|
69339
69372
|
function setLink(next) {
|
|
69340
69373
|
current = next;
|
|
69374
|
+
accessChanged();
|
|
69375
|
+
}
|
|
69376
|
+
var servers = new Set;
|
|
69377
|
+
var toolsOf = new WeakMap;
|
|
69378
|
+
function accessChanged() {
|
|
69379
|
+
const hidden = new Set(hiddenTools(current?.off?.() ?? []));
|
|
69380
|
+
for (const ref of servers) {
|
|
69381
|
+
const server = ref.deref();
|
|
69382
|
+
if (!server) {
|
|
69383
|
+
servers.delete(ref);
|
|
69384
|
+
continue;
|
|
69385
|
+
}
|
|
69386
|
+
for (const [name, tool] of toolsOf.get(server) ?? []) {
|
|
69387
|
+
if (hidden.has(name) && tool.enabled)
|
|
69388
|
+
tool.disable();
|
|
69389
|
+
else if (!hidden.has(name) && !tool.enabled)
|
|
69390
|
+
tool.enable();
|
|
69391
|
+
}
|
|
69392
|
+
}
|
|
69341
69393
|
}
|
|
69342
69394
|
var link = {
|
|
69343
69395
|
get registry() {
|
|
@@ -69378,7 +69430,7 @@ async function activePlanner() {
|
|
|
69378
69430
|
return planner;
|
|
69379
69431
|
const id = `${pro.url}|${pro.licenseKey}`;
|
|
69380
69432
|
if (!proPlanners.has(id)) {
|
|
69381
|
-
proPlanners.set(id, new OpenRouterPlanner({ apiKey: pro.licenseKey, model: "
|
|
69433
|
+
proPlanners.set(id, new OpenRouterPlanner({ apiKey: pro.licenseKey, model: "anthropic/claude-haiku-5.5", baseUrl: `${pro.url}/v1/chat` }));
|
|
69382
69434
|
}
|
|
69383
69435
|
return proPlanners.get(id);
|
|
69384
69436
|
}
|
|
@@ -69604,6 +69656,7 @@ var SEARCH_HINTS = {
|
|
|
69604
69656
|
var INSTRUCTIONS = "Deputy drives the user's real browser. Start with browser_navigate: its result lists the page's forms as typed tools with JSON Schemas, plus clickable actions with refs. Fill a whole form with ONE " + "browser_invoke call — those page tools are not MCP tools, never search for them. For anything else use " + "browser_act with a ref; every action result says what changed on the page, so you rarely need to check. Read with browser_ask/browser_read/browser_extract; use browser_screenshot only when you must see pixels.";
|
|
69605
69657
|
var json = (v2) => text(JSON.stringify(v2, null, 2));
|
|
69606
69658
|
async function runGoal(taskId, goal, tabId) {
|
|
69659
|
+
await needBrowser();
|
|
69607
69660
|
const tab = link.registry.resolve(tabId);
|
|
69608
69661
|
tasks.progress(taskId, `looking at ${tab.title} (${tab.url})`);
|
|
69609
69662
|
if (tab.tools.length === 0) {
|
|
@@ -69628,17 +69681,24 @@ async function runGoal(taskId, goal, tabId) {
|
|
|
69628
69681
|
}
|
|
69629
69682
|
}
|
|
69630
69683
|
function buildServer() {
|
|
69631
|
-
const server = new McpServer({ name: "deputy", version: "0.1.
|
|
69684
|
+
const server = new McpServer({ name: "deputy", version: "0.1.1" }, { instructions: INSTRUCTIONS });
|
|
69632
69685
|
const register2 = server.registerTool.bind(server);
|
|
69633
|
-
|
|
69634
|
-
|
|
69635
|
-
|
|
69636
|
-
|
|
69637
|
-
...config2.
|
|
69638
|
-
|
|
69639
|
-
|
|
69640
|
-
|
|
69641
|
-
|
|
69686
|
+
const tools = new Map;
|
|
69687
|
+
server.registerTool = (name, config2, cb) => {
|
|
69688
|
+
const tool = register2(name, {
|
|
69689
|
+
...config2,
|
|
69690
|
+
annotations: { ...config2.annotations, ...READ_ONLY.has(name) ? { readOnlyHint: true } : {} },
|
|
69691
|
+
_meta: {
|
|
69692
|
+
...config2._meta,
|
|
69693
|
+
...ALWAYS_LOAD.has(name) ? { "anthropic/alwaysLoad": true } : {},
|
|
69694
|
+
...SEARCH_HINTS[name] ? { "anthropic/searchHint": SEARCH_HINTS[name] } : {}
|
|
69695
|
+
}
|
|
69696
|
+
}, cb);
|
|
69697
|
+
tools.set(name, tool);
|
|
69698
|
+
return tool;
|
|
69699
|
+
};
|
|
69700
|
+
toolsOf.set(server, tools);
|
|
69701
|
+
servers.add(new WeakRef(server));
|
|
69642
69702
|
server.registerTool("browser_capabilities", {
|
|
69643
69703
|
title: "What can the browser do right now?",
|
|
69644
69704
|
description: "The full contract of every open tab: each form as a typed tool with its JSON Schema (types, allowed values, min/max, required fields), what those fields currently hold, and every button and link with a ref you can click. This is what you read instead of a " + "screenshot — it is complete, so you should not need to probe. Long pages return a window " + "of their links: the reply always states the true total, and you can narrow with actionQuery or page with actionOffset.",
|
|
@@ -69677,6 +69737,7 @@ function buildServer() {
|
|
|
69677
69737
|
tabId: number2().optional()
|
|
69678
69738
|
})
|
|
69679
69739
|
}, async ({ tool, args, tabId }, ctx) => {
|
|
69740
|
+
await needBrowser();
|
|
69680
69741
|
const found = link.registry.findTool(tool, tabId);
|
|
69681
69742
|
if (!found) {
|
|
69682
69743
|
const available = link.registry.tabs().flatMap((t2) => t2.tools.map((x2) => x2.name));
|
|
@@ -70118,6 +70179,7 @@ ${excerpt}` + (whole ? "" : `
|
|
|
70118
70179
|
await runGoal(taskId, task.goal, task.tabId).catch((e2) => tasks.fail(taskId, String(e2)));
|
|
70119
70180
|
return json(tasks.get(taskId));
|
|
70120
70181
|
});
|
|
70182
|
+
accessChanged();
|
|
70121
70183
|
return server;
|
|
70122
70184
|
}
|
|
70123
70185
|
|
|
@@ -70532,6 +70594,8 @@ async function startHub() {
|
|
|
70532
70594
|
}
|
|
70533
70595
|
}
|
|
70534
70596
|
let tabsReported = false;
|
|
70597
|
+
let locked = null;
|
|
70598
|
+
let off = [];
|
|
70535
70599
|
const readyWaiters = new Set;
|
|
70536
70600
|
const isReady = () => ext !== null && tabsReported;
|
|
70537
70601
|
const wakeReady = () => {
|
|
@@ -70562,7 +70626,9 @@ async function startHub() {
|
|
|
70562
70626
|
t: "snapshot",
|
|
70563
70627
|
tabs: registry2.tabs(),
|
|
70564
70628
|
activeTabId: registry2.activeTab()?.tabId ?? null,
|
|
70565
|
-
extension: ext !== null
|
|
70629
|
+
extension: ext !== null,
|
|
70630
|
+
locked,
|
|
70631
|
+
off
|
|
70566
70632
|
});
|
|
70567
70633
|
let notifyTimer;
|
|
70568
70634
|
let lastVersion = registry2.version();
|
|
@@ -70630,6 +70696,9 @@ async function startHub() {
|
|
|
70630
70696
|
return;
|
|
70631
70697
|
ext = null;
|
|
70632
70698
|
tabsReported = false;
|
|
70699
|
+
locked = null;
|
|
70700
|
+
off = [];
|
|
70701
|
+
accessChanged();
|
|
70633
70702
|
for (const [id, p2] of pending) {
|
|
70634
70703
|
p2.reject(new Error("The browser disconnected."));
|
|
70635
70704
|
pending.delete(id);
|
|
@@ -70663,6 +70732,13 @@ async function startHub() {
|
|
|
70663
70732
|
case "activeTab":
|
|
70664
70733
|
registry2.setActive(msg.tabId);
|
|
70665
70734
|
break;
|
|
70735
|
+
case "license":
|
|
70736
|
+
locked = msg.ok ? null : msg.message ?? "Deputy needs a Deputy Pro license key.";
|
|
70737
|
+
break;
|
|
70738
|
+
case "access":
|
|
70739
|
+
off = parseOff(msg.off);
|
|
70740
|
+
accessChanged();
|
|
70741
|
+
break;
|
|
70666
70742
|
case "reply": {
|
|
70667
70743
|
const p2 = pending.get(msg.id);
|
|
70668
70744
|
if (!p2)
|
|
@@ -70706,7 +70782,7 @@ async function startHub() {
|
|
|
70706
70782
|
if (!bound)
|
|
70707
70783
|
return null;
|
|
70708
70784
|
return {
|
|
70709
|
-
link: { registry: registry2, call: callExtension, ready },
|
|
70785
|
+
link: { registry: registry2, call: callExtension, ready, locked: () => locked, off: () => off },
|
|
70710
70786
|
close: () => new Promise((r2) => {
|
|
70711
70787
|
for (const p2 of peers)
|
|
70712
70788
|
p2.terminate();
|
|
@@ -70727,6 +70803,8 @@ function joinHub() {
|
|
|
70727
70803
|
const pending = new Map;
|
|
70728
70804
|
let opened = false;
|
|
70729
70805
|
let extension2 = false;
|
|
70806
|
+
let locked = null;
|
|
70807
|
+
let off = [];
|
|
70730
70808
|
const waiters = new Set;
|
|
70731
70809
|
let closeHub;
|
|
70732
70810
|
const closed = new Promise((r2) => closeHub = r2);
|
|
@@ -70736,6 +70814,8 @@ function joinHub() {
|
|
|
70736
70814
|
closed,
|
|
70737
70815
|
link: {
|
|
70738
70816
|
registry: registry2,
|
|
70817
|
+
locked: () => locked,
|
|
70818
|
+
off: () => off,
|
|
70739
70819
|
ready(timeoutMs) {
|
|
70740
70820
|
if (extension2)
|
|
70741
70821
|
return Promise.resolve(true);
|
|
@@ -70784,6 +70864,12 @@ function joinHub() {
|
|
|
70784
70864
|
if (msg.t === "snapshot") {
|
|
70785
70865
|
registry2.reconcile(msg.tabs, msg.activeTabId);
|
|
70786
70866
|
extension2 = msg.extension;
|
|
70867
|
+
locked = msg.locked ?? null;
|
|
70868
|
+
const nextOff = msg.off ?? [];
|
|
70869
|
+
if (nextOff.join() !== off.join()) {
|
|
70870
|
+
off = nextOff;
|
|
70871
|
+
accessChanged();
|
|
70872
|
+
}
|
|
70787
70873
|
if (extension2) {
|
|
70788
70874
|
for (const w2 of waiters)
|
|
70789
70875
|
w2();
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deputy-mcp",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"mcpName": "io.github.zraisan/deputy",
|
|
5
|
+
"description": "Deputy's MCP bridge: Claude Code, Codex, Cursor and any MCP client use the pages in your browser as typed tools. Needs the Deputy Chrome extension and a Deputy Pro license.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"bin": {
|
|
7
8
|
"deputy-mcp": "dist/deputy-mcp.js"
|