deputy-mcp 0.1.1 → 0.1.3

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 CHANGED
@@ -11,8 +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).
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).
16
17
 
17
18
  Several clients can use the same browser at once. The first one to start owns the connection to
18
19
  the extension on `127.0.0.1:7331`; later ones share it, and take over if it exits. `DEPUTY_PORT`
@@ -57337,17 +57337,6 @@ var inputRequired = Object.assign(buildInputRequired, {
57337
57337
  return { method: "roots/list" };
57338
57338
  }
57339
57339
  });
57340
- function acceptedContent(responses, key, schema) {
57341
- const view = inputResponse(responses, key);
57342
- if (view.kind !== "elicit" || view.action !== "accept" || view.content === undefined)
57343
- return;
57344
- if (schema === undefined)
57345
- return view.content;
57346
- const outcome = schema["~standard"].validate(view.content);
57347
- if (outcome instanceof Promise)
57348
- throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
57349
- return outcome.issues === undefined ? outcome.value : undefined;
57350
- }
57351
57340
  function inputResponse(responses, key) {
57352
57341
  if (responses === undefined || typeof responses !== "object" || responses === null)
57353
57342
  return { kind: "missing" };
@@ -69306,7 +69295,7 @@ var VISUAL_QUESTION = /\b(colou?rs?|looks?\s+like|images?|pictures?|photos?|char
69306
69295
  function isVisualQuestion(question) {
69307
69296
  return VISUAL_QUESTION.test(question);
69308
69297
  }
69309
- function pixelNote(visual, hasPro) {
69298
+ function pixelNote(visual, hasPro, free = false) {
69310
69299
  if (!visual)
69311
69300
  return;
69312
69301
  const opaque = visual.canvas + visual.unlabeled + visual.svg;
@@ -69315,7 +69304,7 @@ function pixelNote(visual, hasPro) {
69315
69304
  visual.unlabeled && `${visual.unlabeled} image${visual.unlabeled > 1 ? "s" : ""} without alt text`,
69316
69305
  visual.svg && `${visual.svg} SVG graphic${visual.svg > 1 ? "s" : ""}`
69317
69306
  ].filter(Boolean).join(", ");
69318
- const see = `browser_screenshot shows them to you${hasPro ? "; browser_look describes them in text" : ""}`;
69307
+ 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
69308
  if (opaque > 0 && visual.textLength < 600 || opaque > 0 && visual.area >= 0.5) {
69320
69309
  return `Most of this page is pixels with no text behind them (${parts}, largest ${visual.largest}). Text tools can't read them: ${see}.`;
69321
69310
  }
@@ -69361,6 +69350,19 @@ function hiddenTools(off) {
69361
69350
  // packages/deputyd/src/core.ts
69362
69351
  var EMPTY = new Registry;
69363
69352
  var current = null;
69353
+ var FREE_TOOLS = new Set([
69354
+ "browser_capabilities",
69355
+ "browser_invoke",
69356
+ "browser_fill",
69357
+ "browser_click",
69358
+ "browser_read",
69359
+ "browser_navigate",
69360
+ "browser_ask",
69361
+ "delegate_goal",
69362
+ "task_status",
69363
+ "answer_task"
69364
+ ]);
69365
+ var onFreeTier = () => current?.free?.() != null;
69364
69366
  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.";
69365
69367
  async function needBrowser() {
69366
69368
  if (!await link.ready(1e4))
@@ -69376,7 +69378,9 @@ function setLink(next) {
69376
69378
  var servers = new Set;
69377
69379
  var toolsOf = new WeakMap;
69378
69380
  function accessChanged() {
69379
- const hidden = new Set(hiddenTools(current?.off?.() ?? []));
69381
+ const off = new Set(hiddenTools(current?.off?.() ?? []));
69382
+ const free = onFreeTier();
69383
+ const hidden = (name) => off.has(name) || free && !FREE_TOOLS.has(name);
69380
69384
  for (const ref of servers) {
69381
69385
  const server = ref.deref();
69382
69386
  if (!server) {
@@ -69384,9 +69388,9 @@ function accessChanged() {
69384
69388
  continue;
69385
69389
  }
69386
69390
  for (const [name, tool] of toolsOf.get(server) ?? []) {
69387
- if (hidden.has(name) && tool.enabled)
69391
+ if (hidden(name) && tool.enabled)
69388
69392
  tool.disable();
69389
- else if (!hidden.has(name) && !tool.enabled)
69393
+ else if (!hidden(name) && !tool.enabled)
69390
69394
  tool.enable();
69391
69395
  }
69392
69396
  }
@@ -69426,7 +69430,7 @@ async function activePlanner() {
69426
69430
  if (!(planner instanceof HeuristicPlanner))
69427
69431
  return planner;
69428
69432
  const pro = await proConfig();
69429
- if (!pro.licenseKey || !pro.url)
69433
+ if (!pro.licenseKey || !pro.url || onFreeTier())
69430
69434
  return planner;
69431
69435
  const id = `${pro.url}|${pro.licenseKey}`;
69432
69436
  if (!proPlanners.has(id)) {
@@ -69524,26 +69528,70 @@ function askConsent(ctx, key, message, state) {
69524
69528
  const prior = verify(readState(ctx));
69525
69529
  const attempt = typeof prior?.attempt === "number" ? prior.attempt : 0;
69526
69530
  const view = inputResponse(ctx?.mcpReq?.inputResponses, key);
69527
- if (view?.kind === "elicitation") {
69528
- const accepted = acceptedContent(ctx?.mcpReq?.inputResponses, key);
69529
- return accepted?.confirm ? "granted" : "denied";
69530
- }
69531
+ if (view.kind === "elicit")
69532
+ return view.action === "accept" ? "granted" : "denied";
69531
69533
  if (attempt >= 1)
69532
69534
  return "denied";
69533
69535
  return inputRequired({
69534
69536
  inputRequests: {
69535
69537
  [key]: inputRequired.elicit({
69536
69538
  message,
69537
- requestedSchema: {
69538
- type: "object",
69539
- properties: { confirm: { type: "boolean", description: "Proceed?" } },
69540
- required: ["confirm"]
69541
- }
69539
+ requestedSchema: { type: "object", properties: {} }
69542
69540
  })
69543
69541
  },
69544
69542
  requestState: sign({ ...state, attempt: attempt + 1 })
69545
69543
  });
69546
69544
  }
69545
+ var approvalWaitMs = () => {
69546
+ const n2 = Number(process.env.DEPUTY_APPROVAL_WAIT_MS ?? 45000);
69547
+ return Number.isFinite(n2) && n2 >= 0 ? n2 : 45000;
69548
+ };
69549
+ var hostOf = (url2) => {
69550
+ try {
69551
+ return new URL(url2).hostname;
69552
+ } catch {
69553
+ return "";
69554
+ }
69555
+ };
69556
+ var approvalQuestion = (host) => `Submit the form your agent filled on ${host}? It changes something there. You can check it in the browser first, and answer there instead.`;
69557
+ var askCard = (p2, decision) => link.call({ op: "approval", tabId: p2.tabId, frameId: p2.frameId, tool: p2.frameTool ?? p2.tool, approval: p2.approval, decision });
69558
+ async function cardState(p2) {
69559
+ const asked = askCard(p2);
69560
+ const got = await Promise.race([asked, sleep2(2500).then(() => "old")]);
69561
+ if (got === "old")
69562
+ asked.catch(() => {});
69563
+ return got;
69564
+ }
69565
+ async function waitForApproval(p2, ms2) {
69566
+ const until = Date.now() + ms2;
69567
+ while (Date.now() < until) {
69568
+ const now = await cardState(p2);
69569
+ if (now !== "pending")
69570
+ return now;
69571
+ await sleep2(400);
69572
+ }
69573
+ const last = await askCard(p2, "cancel");
69574
+ return last === "submitted" ? last : undefined;
69575
+ }
69576
+ async function decideApproval(p2, decision) {
69577
+ if (await cardState(p2) === "old") {
69578
+ if (decision === "cancel")
69579
+ return approvalReport(p2, "cancelled");
69580
+ await link.call({ op: "invoke", tabId: p2.tabId, tool: p2.frameTool ?? p2.tool, frameId: p2.frameId, args: p2.args, submit: true });
69581
+ return approvalReport(p2, "submitted");
69582
+ }
69583
+ return approvalReport(p2, await askCard(p2, decision));
69584
+ }
69585
+ async function approvalReport(p2, outcome) {
69586
+ if (outcome === "cancelled")
69587
+ return `Not submitted: the user said no to "${p2.tool}". The form is still filled in the browser; do not submit it.`;
69588
+ if (outcome === "gone")
69589
+ return `Not submitted: the page changed before anyone approved "${p2.tool}". Fill it again if the user still wants it sent.`;
69590
+ await sleep2(600);
69591
+ const now = link.registry.tabs().find((t2) => t2.tabId === p2.tabId);
69592
+ return `Submitted "${p2.tool}": the user approved it.${now ? `
69593
+ ${await pageSummary(now)}` : ""}`;
69594
+ }
69547
69595
  function windowActions(all, query, limit, offset) {
69548
69596
  const needle = (query ?? "").trim().toLowerCase();
69549
69597
  const matched = needle ? all.filter((a2) => String(a2.label ?? "").toLowerCase().includes(needle)) : all;
@@ -69592,6 +69640,8 @@ async function pageText(tab) {
69592
69640
  async function pagePixels(t2) {
69593
69641
  if (!t2?.visual)
69594
69642
  return;
69643
+ if (onFreeTier())
69644
+ return pixelNote(t2.visual, false, true);
69595
69645
  return pixelNote(t2.visual, !!(await proConfig()).licenseKey);
69596
69646
  }
69597
69647
  async function pageSummary(t2, lead = "Now on") {
@@ -69604,7 +69654,7 @@ async function pageSummary(t2, lead = "Now on") {
69604
69654
  } catch {}
69605
69655
  const visual = await pagePixels(t2);
69606
69656
  return JSON.stringify({
69607
- page: `${lead} ${t2.title} <${t2.url}>`,
69657
+ page: `${lead} ${t2.title ? `${t2.title} ` : ""}<${t2.url}>`,
69608
69658
  tabId: t2.tabId,
69609
69659
  ...full ? { text: full.slice(0, TEXT_EXCERPT) } : {},
69610
69660
  ...visual ? { visual } : {},
@@ -69617,7 +69667,7 @@ async function pageSummary(t2, lead = "Now on") {
69617
69667
  })),
69618
69668
  actions: actions.slice(0, 25).map((a2) => ({ ref: a2.ref, label: a2.label, kind: a2.kind, ...a2.inputType ? { inputType: a2.inputType } : {} })),
69619
69669
  ...actions.length > 25 ? { moreActions: `${actions.length - 25} more; narrow with browser_capabilities actionQuery` } : {},
69620
- howTo: "Page tools are not MCP tools: run one with browser_invoke({ tool, args }). Act on an action with browser_act({ ref, action })."
69670
+ 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 }).")
69621
69671
  }, null, 1);
69622
69672
  }
69623
69673
  var ALWAYS_LOAD = new Set(["browser_navigate", "browser_invoke", "browser_act", "browser_find", "browser_read", "browser_ask", "browser_screenshot"]);
@@ -69653,7 +69703,7 @@ var SEARCH_HINTS = {
69653
69703
  browser_capabilities: "page forms tools actions refs what can I do",
69654
69704
  browser_downloads: "download downloaded file saved export csv pdf report"
69655
69705
  };
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.";
69706
+ 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.";
69657
69707
  var json = (v2) => text(JSON.stringify(v2, null, 2));
69658
69708
  async function runGoal(taskId, goal, tabId) {
69659
69709
  await needBrowser();
@@ -69681,7 +69731,7 @@ async function runGoal(taskId, goal, tabId) {
69681
69731
  }
69682
69732
  }
69683
69733
  function buildServer() {
69684
- const server = new McpServer({ name: "deputy", version: "0.1.1" }, { instructions: INSTRUCTIONS });
69734
+ const server = new McpServer({ name: "deputy", version: "0.1.3" }, { instructions: INSTRUCTIONS });
69685
69735
  const register2 = server.registerTool.bind(server);
69686
69736
  const tools = new Map;
69687
69737
  server.registerTool = (name, config2, cb) => {
@@ -69738,22 +69788,61 @@ function buildServer() {
69738
69788
  })
69739
69789
  }, async ({ tool, args, tabId }, ctx) => {
69740
69790
  await needBrowser();
69741
- const found = link.registry.findTool(tool, tabId);
69791
+ const resumed = verify(readState(ctx));
69792
+ if (typeof resumed?.approval === "string") {
69793
+ const consent = askConsent(ctx, "confirm", approvalQuestion(resumed.host), resumed);
69794
+ if (consent !== "granted" && consent !== "denied")
69795
+ return consent;
69796
+ return text(await decideApproval(resumed, consent === "granted" ? "submit" : "cancel"));
69797
+ }
69798
+ let found = link.registry.findTool(tool, tabId);
69799
+ if (!found) {
69800
+ const tab = (() => {
69801
+ try {
69802
+ return link.registry.resolve(tabId);
69803
+ } catch {
69804
+ return null;
69805
+ }
69806
+ })();
69807
+ const fresh = tab ? await link.call({ op: "annotate", tabId: tab.tabId }).catch(() => null) : null;
69808
+ if (fresh?.tabId != null && Array.isArray(fresh.tools))
69809
+ link.registry.upsert(fresh);
69810
+ found = link.registry.findTool(tool, tabId);
69811
+ }
69742
69812
  if (!found) {
69743
69813
  const available = link.registry.tabs().flatMap((t2) => t2.tools.map((x2) => x2.name));
69744
69814
  return text(`No tool "${tool}" in the browser. Available: ${available.join(", ") || "none"}.`);
69745
69815
  }
69746
- let approved = false;
69747
- if (found.tool.consequential && canElicit(ctx, server)) {
69748
- const consent = askConsent(ctx, "confirm", `Submit "${tool}" on ${found.tab.origin}? It changes something.`, { tool });
69749
- if (consent !== "granted" && consent !== "denied")
69750
- return consent;
69751
- if (consent === "denied")
69752
- return text(`Not run: the user declined "${tool}".`);
69753
- approved = true;
69816
+ const call = { op: "invoke", tabId: found.tab.tabId, tool: found.tool.frameTool ?? tool, frameId: found.tool.frameId, args: args ?? {} };
69817
+ if (found.tool.consequential) {
69818
+ const elicit = canElicit(ctx, server);
69819
+ const wait = approvalWaitMs();
69820
+ const approval = elicit || wait > 0 ? randomUUID() : undefined;
69821
+ const filled = await link.call({ ...call, approval });
69822
+ const said = typeof filled === "string" ? filled : JSON.stringify(filled ?? "Filled.");
69823
+ if (!approval)
69824
+ return text(said);
69825
+ const pending = {
69826
+ approval,
69827
+ tool,
69828
+ tabId: found.tab.tabId,
69829
+ frameId: found.tool.frameId,
69830
+ frameTool: found.tool.frameTool,
69831
+ host: hostOf(found.tab.url) || found.tab.origin,
69832
+ args: args ?? {}
69833
+ };
69834
+ if (elicit)
69835
+ return askConsent(ctx, "confirm", approvalQuestion(pending.host), pending);
69836
+ const outcome = await waitForApproval(pending, wait);
69837
+ if (outcome === "old")
69838
+ return text(said);
69839
+ if (outcome)
69840
+ return text(await approvalReport(pending, outcome));
69841
+ return text(`${said}
69842
+ Nobody answered Deputy's card in the browser within ${Math.round(wait / 1000)} s, so it was not submitted.`);
69754
69843
  }
69755
69844
  const waits = "";
69756
- const result = await link.call({ op: "invoke", tabId: found.tab.tabId, tool: found.tool.frameTool ?? tool, frameId: found.tool.frameId, args: args ?? {}, submit: approved });
69845
+ const result = await link.call(call);
69757
69846
  if (result === null || result === undefined || result === "") {
69758
69847
  await sleep2(600);
69759
69848
  const now = link.registry.tabs().find((t2) => t2.tabId === found.tab.tabId);
@@ -69819,7 +69908,11 @@ The tab is on ${tab.title} <${tab.url}>.` : ""}`);
69819
69908
  })
69820
69909
  }, async ({ url: url2, action, tabId }) => {
69821
69910
  await needBrowser();
69822
- const describe2 = (after) => pageSummary(after);
69911
+ const describe2 = (after) => {
69912
+ if (after?.tabId != null && Array.isArray(after.tools))
69913
+ link.registry.upsert(after, true);
69914
+ return pageSummary(after);
69915
+ };
69823
69916
  if (url2 && !action && tabId == null && !link.registry.activeTab()) {
69824
69917
  return text(await describe2(await link.call({ op: "tabs", action: "open", url: url2 })));
69825
69918
  }
@@ -70095,7 +70188,7 @@ The tab is on ${tab.title} <${tab.url}>.` : ""}`);
70095
70188
  const tab = link.registry.resolve(tabId);
70096
70189
  const content = await pageText(tab).catch(() => "");
70097
70190
  const notes = [
70098
- isVisualQuestion(question) ? "This asks how the page looks, which its text can't show: browser_screenshot does." : "",
70191
+ 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"}.` : "",
70099
70192
  await pagePixels(tab) ?? ""
70100
70193
  ].filter(Boolean).map((n2) => `[${n2}]`).join(`
70101
70194
  `);
@@ -70595,6 +70688,7 @@ async function startHub() {
70595
70688
  }
70596
70689
  let tabsReported = false;
70597
70690
  let locked = null;
70691
+ let free = null;
70598
70692
  let off = [];
70599
70693
  const readyWaiters = new Set;
70600
70694
  const isReady = () => ext !== null && tabsReported;
@@ -70628,6 +70722,7 @@ async function startHub() {
70628
70722
  activeTabId: registry2.activeTab()?.tabId ?? null,
70629
70723
  extension: ext !== null,
70630
70724
  locked,
70725
+ free,
70631
70726
  off
70632
70727
  });
70633
70728
  let notifyTimer;
@@ -70697,6 +70792,7 @@ async function startHub() {
70697
70792
  ext = null;
70698
70793
  tabsReported = false;
70699
70794
  locked = null;
70795
+ free = null;
70700
70796
  off = [];
70701
70797
  accessChanged();
70702
70798
  for (const [id, p2] of pending) {
@@ -70734,6 +70830,8 @@ async function startHub() {
70734
70830
  break;
70735
70831
  case "license":
70736
70832
  locked = msg.ok ? null : msg.message ?? "Deputy needs a Deputy Pro license key.";
70833
+ free = msg.ok && msg.pro === false ? msg.message ?? "" : null;
70834
+ accessChanged();
70737
70835
  break;
70738
70836
  case "access":
70739
70837
  off = parseOff(msg.off);
@@ -70782,7 +70880,7 @@ async function startHub() {
70782
70880
  if (!bound)
70783
70881
  return null;
70784
70882
  return {
70785
- link: { registry: registry2, call: callExtension, ready, locked: () => locked, off: () => off },
70883
+ link: { registry: registry2, call: callExtension, ready, locked: () => locked, free: () => free, off: () => off },
70786
70884
  close: () => new Promise((r2) => {
70787
70885
  for (const p2 of peers)
70788
70886
  p2.terminate();
@@ -70804,6 +70902,7 @@ function joinHub() {
70804
70902
  let opened = false;
70805
70903
  let extension2 = false;
70806
70904
  let locked = null;
70905
+ let free = null;
70807
70906
  let off = [];
70808
70907
  const waiters = new Set;
70809
70908
  let closeHub;
@@ -70815,6 +70914,7 @@ function joinHub() {
70815
70914
  link: {
70816
70915
  registry: registry2,
70817
70916
  locked: () => locked,
70917
+ free: () => free,
70818
70918
  off: () => off,
70819
70919
  ready(timeoutMs) {
70820
70920
  if (extension2)
@@ -70865,8 +70965,10 @@ function joinHub() {
70865
70965
  registry2.reconcile(msg.tabs, msg.activeTabId);
70866
70966
  extension2 = msg.extension;
70867
70967
  locked = msg.locked ?? null;
70968
+ const nextFree = msg.free ?? null;
70868
70969
  const nextOff = msg.off ?? [];
70869
- if (nextOff.join() !== off.join()) {
70970
+ if (nextFree !== free || nextOff.join() !== off.join()) {
70971
+ free = nextFree;
70870
70972
  off = nextOff;
70871
70973
  accessChanged();
70872
70974
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "deputy-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
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
+ "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.",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "deputy-mcp": "dist/deputy-mcp.js"