deputy-mcp 0.1.0 → 0.1.2
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 +4 -0
- package/dist/deputy-mcp.js +131 -19
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ 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 is free to start: without a key your agent gets 10 tools. [Deputy Pro](https://razin.ai/deputy/)
|
|
15
|
+
adds the other 17 and hosted models; paste its license key on the extension's setup page. The
|
|
16
|
+
open-source version is at [github.com/zraisan/deputy](https://github.com/zraisan/deputy).
|
|
17
|
+
|
|
14
18
|
Several clients can use the same browser at once. The first one to start owns the connection to
|
|
15
19
|
the extension on `127.0.0.1:7331`; later ones share it, and take over if it exits. `DEPUTY_PORT`
|
|
16
20
|
picks another port.
|
package/dist/deputy-mcp.js
CHANGED
|
@@ -69306,7 +69306,7 @@ var VISUAL_QUESTION = /\b(colou?rs?|looks?\s+like|images?|pictures?|photos?|char
|
|
|
69306
69306
|
function isVisualQuestion(question) {
|
|
69307
69307
|
return VISUAL_QUESTION.test(question);
|
|
69308
69308
|
}
|
|
69309
|
-
function pixelNote(visual, hasPro) {
|
|
69309
|
+
function pixelNote(visual, hasPro, free = false) {
|
|
69310
69310
|
if (!visual)
|
|
69311
69311
|
return;
|
|
69312
69312
|
const opaque = visual.canvas + visual.unlabeled + visual.svg;
|
|
@@ -69315,7 +69315,7 @@ function pixelNote(visual, hasPro) {
|
|
|
69315
69315
|
visual.unlabeled && `${visual.unlabeled} image${visual.unlabeled > 1 ? "s" : ""} without alt text`,
|
|
69316
69316
|
visual.svg && `${visual.svg} SVG graphic${visual.svg > 1 ? "s" : ""}`
|
|
69317
69317
|
].filter(Boolean).join(", ");
|
|
69318
|
-
const see = `browser_screenshot shows them to you${hasPro ? "; browser_look describes them in text" : ""}`;
|
|
69318
|
+
const see = free ? "Deputy Pro's browser_screenshot and browser_look can see them (https://deputy.razin.ai/buy)" : `browser_screenshot shows them to you${hasPro ? "; browser_look describes them in text" : ""}`;
|
|
69319
69319
|
if (opaque > 0 && visual.textLength < 600 || opaque > 0 && visual.area >= 0.5) {
|
|
69320
69320
|
return `Most of this page is pixels with no text behind them (${parts}, largest ${visual.largest}). Text tools can't read them: ${see}.`;
|
|
69321
69321
|
}
|
|
@@ -69329,15 +69329,82 @@ 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;
|
|
69364
|
+
var FREE_TOOLS = new Set([
|
|
69365
|
+
"browser_capabilities",
|
|
69366
|
+
"browser_invoke",
|
|
69367
|
+
"browser_fill",
|
|
69368
|
+
"browser_click",
|
|
69369
|
+
"browser_read",
|
|
69370
|
+
"browser_navigate",
|
|
69371
|
+
"browser_ask",
|
|
69372
|
+
"delegate_goal",
|
|
69373
|
+
"task_status",
|
|
69374
|
+
"answer_task"
|
|
69375
|
+
]);
|
|
69376
|
+
var onFreeTier = () => current?.free?.() != null;
|
|
69334
69377
|
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
69378
|
async function needBrowser() {
|
|
69336
69379
|
if (!await link.ready(1e4))
|
|
69337
69380
|
throw new Error(NOT_CONNECTED);
|
|
69381
|
+
const why = current?.locked?.();
|
|
69382
|
+
if (why)
|
|
69383
|
+
throw new Error(why);
|
|
69338
69384
|
}
|
|
69339
69385
|
function setLink(next) {
|
|
69340
69386
|
current = next;
|
|
69387
|
+
accessChanged();
|
|
69388
|
+
}
|
|
69389
|
+
var servers = new Set;
|
|
69390
|
+
var toolsOf = new WeakMap;
|
|
69391
|
+
function accessChanged() {
|
|
69392
|
+
const off = new Set(hiddenTools(current?.off?.() ?? []));
|
|
69393
|
+
const free = onFreeTier();
|
|
69394
|
+
const hidden = (name) => off.has(name) || free && !FREE_TOOLS.has(name);
|
|
69395
|
+
for (const ref of servers) {
|
|
69396
|
+
const server = ref.deref();
|
|
69397
|
+
if (!server) {
|
|
69398
|
+
servers.delete(ref);
|
|
69399
|
+
continue;
|
|
69400
|
+
}
|
|
69401
|
+
for (const [name, tool] of toolsOf.get(server) ?? []) {
|
|
69402
|
+
if (hidden(name) && tool.enabled)
|
|
69403
|
+
tool.disable();
|
|
69404
|
+
else if (!hidden(name) && !tool.enabled)
|
|
69405
|
+
tool.enable();
|
|
69406
|
+
}
|
|
69407
|
+
}
|
|
69341
69408
|
}
|
|
69342
69409
|
var link = {
|
|
69343
69410
|
get registry() {
|
|
@@ -69374,11 +69441,11 @@ async function activePlanner() {
|
|
|
69374
69441
|
if (!(planner instanceof HeuristicPlanner))
|
|
69375
69442
|
return planner;
|
|
69376
69443
|
const pro = await proConfig();
|
|
69377
|
-
if (!pro.licenseKey || !pro.url)
|
|
69444
|
+
if (!pro.licenseKey || !pro.url || onFreeTier())
|
|
69378
69445
|
return planner;
|
|
69379
69446
|
const id = `${pro.url}|${pro.licenseKey}`;
|
|
69380
69447
|
if (!proPlanners.has(id)) {
|
|
69381
|
-
proPlanners.set(id, new OpenRouterPlanner({ apiKey: pro.licenseKey, model: "
|
|
69448
|
+
proPlanners.set(id, new OpenRouterPlanner({ apiKey: pro.licenseKey, model: "anthropic/claude-haiku-5.5", baseUrl: `${pro.url}/v1/chat` }));
|
|
69382
69449
|
}
|
|
69383
69450
|
return proPlanners.get(id);
|
|
69384
69451
|
}
|
|
@@ -69540,6 +69607,8 @@ async function pageText(tab) {
|
|
|
69540
69607
|
async function pagePixels(t2) {
|
|
69541
69608
|
if (!t2?.visual)
|
|
69542
69609
|
return;
|
|
69610
|
+
if (onFreeTier())
|
|
69611
|
+
return pixelNote(t2.visual, false, true);
|
|
69543
69612
|
return pixelNote(t2.visual, !!(await proConfig()).licenseKey);
|
|
69544
69613
|
}
|
|
69545
69614
|
async function pageSummary(t2, lead = "Now on") {
|
|
@@ -69565,7 +69634,7 @@ async function pageSummary(t2, lead = "Now on") {
|
|
|
69565
69634
|
})),
|
|
69566
69635
|
actions: actions.slice(0, 25).map((a2) => ({ ref: a2.ref, label: a2.label, kind: a2.kind, ...a2.inputType ? { inputType: a2.inputType } : {} })),
|
|
69567
69636
|
...actions.length > 25 ? { moreActions: `${actions.length - 25} more; narrow with browser_capabilities actionQuery` } : {},
|
|
69568
|
-
howTo: "Page tools are not MCP tools: run one with browser_invoke({ tool, args }). Act on an action with browser_act({ ref, action })."
|
|
69637
|
+
howTo: "Page tools are not MCP tools: run one with browser_invoke({ tool, args }). " + (onFreeTier() ? "Click an action with browser_click({ ref }); set a field with browser_fill({ ref, value })." : "Act on an action with browser_act({ ref, action }).")
|
|
69569
69638
|
}, null, 1);
|
|
69570
69639
|
}
|
|
69571
69640
|
var ALWAYS_LOAD = new Set(["browser_navigate", "browser_invoke", "browser_act", "browser_find", "browser_read", "browser_ask", "browser_screenshot"]);
|
|
@@ -69601,9 +69670,10 @@ var SEARCH_HINTS = {
|
|
|
69601
69670
|
browser_capabilities: "page forms tools actions refs what can I do",
|
|
69602
69671
|
browser_downloads: "download downloaded file saved export csv pdf report"
|
|
69603
69672
|
};
|
|
69604
|
-
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.";
|
|
69673
|
+
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. Without Deputy Pro only the free tools are listed: act with browser_click/browser_fill. If the user needs one that is missing (screenshots, tabs, scrolling, console, network and more), Deputy Pro adds it: https://deputy.razin.ai/buy.";
|
|
69605
69674
|
var json = (v2) => text(JSON.stringify(v2, null, 2));
|
|
69606
69675
|
async function runGoal(taskId, goal, tabId) {
|
|
69676
|
+
await needBrowser();
|
|
69607
69677
|
const tab = link.registry.resolve(tabId);
|
|
69608
69678
|
tasks.progress(taskId, `looking at ${tab.title} (${tab.url})`);
|
|
69609
69679
|
if (tab.tools.length === 0) {
|
|
@@ -69628,17 +69698,24 @@ async function runGoal(taskId, goal, tabId) {
|
|
|
69628
69698
|
}
|
|
69629
69699
|
}
|
|
69630
69700
|
function buildServer() {
|
|
69631
|
-
const server = new McpServer({ name: "deputy", version: "0.1.
|
|
69701
|
+
const server = new McpServer({ name: "deputy", version: "0.1.2" }, { instructions: INSTRUCTIONS });
|
|
69632
69702
|
const register2 = server.registerTool.bind(server);
|
|
69633
|
-
|
|
69634
|
-
|
|
69635
|
-
|
|
69636
|
-
|
|
69637
|
-
...config2.
|
|
69638
|
-
|
|
69639
|
-
|
|
69640
|
-
|
|
69641
|
-
|
|
69703
|
+
const tools = new Map;
|
|
69704
|
+
server.registerTool = (name, config2, cb) => {
|
|
69705
|
+
const tool = register2(name, {
|
|
69706
|
+
...config2,
|
|
69707
|
+
annotations: { ...config2.annotations, ...READ_ONLY.has(name) ? { readOnlyHint: true } : {} },
|
|
69708
|
+
_meta: {
|
|
69709
|
+
...config2._meta,
|
|
69710
|
+
...ALWAYS_LOAD.has(name) ? { "anthropic/alwaysLoad": true } : {},
|
|
69711
|
+
...SEARCH_HINTS[name] ? { "anthropic/searchHint": SEARCH_HINTS[name] } : {}
|
|
69712
|
+
}
|
|
69713
|
+
}, cb);
|
|
69714
|
+
tools.set(name, tool);
|
|
69715
|
+
return tool;
|
|
69716
|
+
};
|
|
69717
|
+
toolsOf.set(server, tools);
|
|
69718
|
+
servers.add(new WeakRef(server));
|
|
69642
69719
|
server.registerTool("browser_capabilities", {
|
|
69643
69720
|
title: "What can the browser do right now?",
|
|
69644
69721
|
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 +69754,7 @@ function buildServer() {
|
|
|
69677
69754
|
tabId: number2().optional()
|
|
69678
69755
|
})
|
|
69679
69756
|
}, async ({ tool, args, tabId }, ctx) => {
|
|
69757
|
+
await needBrowser();
|
|
69680
69758
|
const found = link.registry.findTool(tool, tabId);
|
|
69681
69759
|
if (!found) {
|
|
69682
69760
|
const available = link.registry.tabs().flatMap((t2) => t2.tools.map((x2) => x2.name));
|
|
@@ -70034,7 +70112,7 @@ The tab is on ${tab.title} <${tab.url}>.` : ""}`);
|
|
|
70034
70112
|
const tab = link.registry.resolve(tabId);
|
|
70035
70113
|
const content = await pageText(tab).catch(() => "");
|
|
70036
70114
|
const notes = [
|
|
70037
|
-
isVisualQuestion(question) ?
|
|
70115
|
+
isVisualQuestion(question) ? `This asks how the page looks, which its text can't show: ${onFreeTier() ? "Deputy Pro's browser_screenshot does (https://deputy.razin.ai/buy)" : "browser_screenshot does"}.` : "",
|
|
70038
70116
|
await pagePixels(tab) ?? ""
|
|
70039
70117
|
].filter(Boolean).map((n2) => `[${n2}]`).join(`
|
|
70040
70118
|
`);
|
|
@@ -70118,6 +70196,7 @@ ${excerpt}` + (whole ? "" : `
|
|
|
70118
70196
|
await runGoal(taskId, task.goal, task.tabId).catch((e2) => tasks.fail(taskId, String(e2)));
|
|
70119
70197
|
return json(tasks.get(taskId));
|
|
70120
70198
|
});
|
|
70199
|
+
accessChanged();
|
|
70121
70200
|
return server;
|
|
70122
70201
|
}
|
|
70123
70202
|
|
|
@@ -70532,6 +70611,9 @@ async function startHub() {
|
|
|
70532
70611
|
}
|
|
70533
70612
|
}
|
|
70534
70613
|
let tabsReported = false;
|
|
70614
|
+
let locked = null;
|
|
70615
|
+
let free = null;
|
|
70616
|
+
let off = [];
|
|
70535
70617
|
const readyWaiters = new Set;
|
|
70536
70618
|
const isReady = () => ext !== null && tabsReported;
|
|
70537
70619
|
const wakeReady = () => {
|
|
@@ -70562,7 +70644,10 @@ async function startHub() {
|
|
|
70562
70644
|
t: "snapshot",
|
|
70563
70645
|
tabs: registry2.tabs(),
|
|
70564
70646
|
activeTabId: registry2.activeTab()?.tabId ?? null,
|
|
70565
|
-
extension: ext !== null
|
|
70647
|
+
extension: ext !== null,
|
|
70648
|
+
locked,
|
|
70649
|
+
free,
|
|
70650
|
+
off
|
|
70566
70651
|
});
|
|
70567
70652
|
let notifyTimer;
|
|
70568
70653
|
let lastVersion = registry2.version();
|
|
@@ -70630,6 +70715,10 @@ async function startHub() {
|
|
|
70630
70715
|
return;
|
|
70631
70716
|
ext = null;
|
|
70632
70717
|
tabsReported = false;
|
|
70718
|
+
locked = null;
|
|
70719
|
+
free = null;
|
|
70720
|
+
off = [];
|
|
70721
|
+
accessChanged();
|
|
70633
70722
|
for (const [id, p2] of pending) {
|
|
70634
70723
|
p2.reject(new Error("The browser disconnected."));
|
|
70635
70724
|
pending.delete(id);
|
|
@@ -70663,6 +70752,15 @@ async function startHub() {
|
|
|
70663
70752
|
case "activeTab":
|
|
70664
70753
|
registry2.setActive(msg.tabId);
|
|
70665
70754
|
break;
|
|
70755
|
+
case "license":
|
|
70756
|
+
locked = msg.ok ? null : msg.message ?? "Deputy needs a Deputy Pro license key.";
|
|
70757
|
+
free = msg.ok && msg.pro === false ? msg.message ?? "" : null;
|
|
70758
|
+
accessChanged();
|
|
70759
|
+
break;
|
|
70760
|
+
case "access":
|
|
70761
|
+
off = parseOff(msg.off);
|
|
70762
|
+
accessChanged();
|
|
70763
|
+
break;
|
|
70666
70764
|
case "reply": {
|
|
70667
70765
|
const p2 = pending.get(msg.id);
|
|
70668
70766
|
if (!p2)
|
|
@@ -70706,7 +70804,7 @@ async function startHub() {
|
|
|
70706
70804
|
if (!bound)
|
|
70707
70805
|
return null;
|
|
70708
70806
|
return {
|
|
70709
|
-
link: { registry: registry2, call: callExtension, ready },
|
|
70807
|
+
link: { registry: registry2, call: callExtension, ready, locked: () => locked, free: () => free, off: () => off },
|
|
70710
70808
|
close: () => new Promise((r2) => {
|
|
70711
70809
|
for (const p2 of peers)
|
|
70712
70810
|
p2.terminate();
|
|
@@ -70727,6 +70825,9 @@ function joinHub() {
|
|
|
70727
70825
|
const pending = new Map;
|
|
70728
70826
|
let opened = false;
|
|
70729
70827
|
let extension2 = false;
|
|
70828
|
+
let locked = null;
|
|
70829
|
+
let free = null;
|
|
70830
|
+
let off = [];
|
|
70730
70831
|
const waiters = new Set;
|
|
70731
70832
|
let closeHub;
|
|
70732
70833
|
const closed = new Promise((r2) => closeHub = r2);
|
|
@@ -70736,6 +70837,9 @@ function joinHub() {
|
|
|
70736
70837
|
closed,
|
|
70737
70838
|
link: {
|
|
70738
70839
|
registry: registry2,
|
|
70840
|
+
locked: () => locked,
|
|
70841
|
+
free: () => free,
|
|
70842
|
+
off: () => off,
|
|
70739
70843
|
ready(timeoutMs) {
|
|
70740
70844
|
if (extension2)
|
|
70741
70845
|
return Promise.resolve(true);
|
|
@@ -70784,6 +70888,14 @@ function joinHub() {
|
|
|
70784
70888
|
if (msg.t === "snapshot") {
|
|
70785
70889
|
registry2.reconcile(msg.tabs, msg.activeTabId);
|
|
70786
70890
|
extension2 = msg.extension;
|
|
70891
|
+
locked = msg.locked ?? null;
|
|
70892
|
+
const nextFree = msg.free ?? null;
|
|
70893
|
+
const nextOff = msg.off ?? [];
|
|
70894
|
+
if (nextFree !== free || nextOff.join() !== off.join()) {
|
|
70895
|
+
free = nextFree;
|
|
70896
|
+
off = nextOff;
|
|
70897
|
+
accessChanged();
|
|
70898
|
+
}
|
|
70787
70899
|
if (extension2) {
|
|
70788
70900
|
for (const w2 of waiters)
|
|
70789
70901
|
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.2",
|
|
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; free to start, Deputy Pro adds 17 tools and hosted models.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"bin": {
|
|
7
8
|
"deputy-mcp": "dist/deputy-mcp.js"
|