ai-agentmanager 1.41.0 → 1.43.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.43.0 (2026-11-11)
4
+
5
+ - **An MCP session of its own.** Each folder (your home folder or an agent's workspace) gets one Claude Code process for MCP, separate from any agent's session. Listing servers, signing in, reconnecting and calling a tool make no model call and don't interrupt an agent. It closes after 15 minutes unused; **Refresh all** starts a new one.
6
+ - **Sign in to MCP servers.** A server that needs it shows **Sign in** (or `agentmgr mcp signin`), which opens its sign-in page. Claude Code keeps the tokens; the app never sees them. From another device, paste the address the browser ended on.
7
+ - **Reconnect one server** with **↻** (or `agentmgr mcp reconnect`), leaving the others alone.
8
+ - **Run a tool directly.** **Run** with JSON arguments (or none) calls the tool with no model call and shows its output as it is; plain words still go through a one-off Claude Code call allowed only that tool, and **Run in agent session** asks the agent. The last 30 runs are kept with their results, and **↗ Window** opens the panel on its own (`#mcp`). The `mcp.run` plugin policy now gets `where`.
9
+ - **Update from the app** shows an in-page dialog with live progress (install, restart, reload) instead of a browser confirm and a short toast.
10
+
11
+ ## 1.42.0 (2026-11-11)
12
+
13
+ - **MCP servers and tools.** **MCP** in the top bar (or **MCP tools** in an agent's detail, or `agentmgr mcp [agent]`) lists the MCP servers Claude Code has in your home folder or an agent's workspace: your own, the project's `.mcp.json`, claude.ai connectors and plugins' servers. Each shows its status, where it comes from and its tools. Listing makes no model call, and secrets are never shown.
14
+ - **Run a tool.** **Run in session** tells the agent to use it, with its conversation and context. **Run once in workspace** (or `agentmgr mcp run`) is a separate one-off call that may use only that tool and shows what it returned, without interrupting the agent. Destructive tools need a second click, and plugins can refuse one-off runs with the `mcp.run` policy.
15
+
3
16
  ## 1.41.0 (2026-11-11)
4
17
 
5
18
  - **Estimate.** A human time estimate for planning any Jira fix or feature: how long one experienced developer would take to do it by hand, without an AI agent. It's split into tasks of a day or less, each with optimistic, likely, pessimistic and expected hours and a total. Work over about 3 days gets a suggested split into tickets, and it lists the roles, assumptions and risks.
package/README.md CHANGED
@@ -27,6 +27,7 @@ Run one background [Claude Code](https://claude.com/claude-code) agent per inten
27
27
  - **Slack alerts.** A message in your channel when an agent needs input, finishes a backlog item, or fails.
28
28
  - **Priority.** Mark agents P0–P3. P0 and P1 are highlighted, and lists sort by priority.
29
29
  - **Share for review.** One click writes an **Analysis**, **Design**, **Flow** or **Proposal** document from the agent's work, a human time **Estimate** for planning, or the change's **Documentation** with an OpenAPI spec of any API changes. Copy it as Markdown, download it, or print it to PDF with diagrams.
30
+ - **MCP servers and tools.** See every MCP server Claude Code has in a folder (yours, the project's, claude.ai connectors and plugins) with its tools, sign in to the ones that need it, and run any tool directly, through Claude Code, or in an agent's session.
30
31
  - **Human vs AI.** It splits the open questions about the work into the top 5 that need your judgment and the ones a model can answer from the evidence. It answers those, then a second model double-checks every answer.
31
32
  - **Review changes.** Each agent's diff file by file, line comments sent back to the agent as one message, then **Commit all** and **Push & open PR**, without leaving the page.
32
33
  - **Standup.** Each weekday at 9:00 (or whenever you press **Standup**, or `p`), each agent with news since the last one is read aloud in a sentence or two, each in its own voice: what it did, what it's on, what it needs from you. Agents that need you go first and quiet ones are left out. It stops on an agent that needs you, with its questions beside it to answer by tap, or by voice when **Answer by voice** is on (what you say is read back, then sent when you say "send"). The wording comes from one short tool-less model call, plain wording if that fails. A Slack alert says when it's ready (Alerts). Change the time, weekends and wording in the player, or in config.json: `"standup": { "at": "09:00", "weekends": false, "ai": true, "notify": true }`. Speech is your browser's own; voice answers may be sent to your browser's maker to be turned into text.
@@ -110,7 +111,7 @@ npm install
110
111
  npm link
111
112
  ```
112
113
 
113
- **Updating.** `agentmgr update` installs the newest release and restarts onto it; running agents pause briefly and resume. In the app, **Update to …** appears in the top bar when a release is out (checked twice a day; turn it off in **☰ → Settings** or with `agentmgr update --auto-check off`), and **About → Update and restart** does the same. Both work from a signed-in phone too: the install and restart run on the computer, and the page reloads when it's back. A clone at a release tag (or one you `npm link`ed) moves to the newest tag; a clone on a branch or with uncommitted changes is left alone. By hand, use the command for how you installed, then `agentmgr restart`:
114
+ **Updating.** `agentmgr update` installs the newest release and restarts onto it; running agents pause briefly and resume. In the app, **Update to …** appears in the top bar when a release is out (checked twice a day; turn it off in **☰ → Settings** or with `agentmgr update --auto-check off`), and **About → Update and restart** does the same. Either one opens a window that asks first, then shows each step as it happens: the install (how long it has taken, how many packages npm has fetched and its last line), the restart, and the page's reload. If the install fails, the error stays on screen with the command to run by hand, and nothing is restarted. Both work from a signed-in phone too: the install and restart run on the computer, and the page reloads when it's back. A clone at a release tag (or one you `npm link`ed) moves to the newest tag; a clone on a branch or with uncommitted changes is left alone. By hand, use the command for how you installed, then `agentmgr restart`:
114
115
 
115
116
  | Installed with | Update |
116
117
  | --- | --- |
@@ -1127,6 +1128,23 @@ Usage comes from the session transcripts and is refreshed every few seconds whil
1127
1128
  - If a tab stays blank on a device, open it once with **↗** and accept the certificate there.
1128
1129
  - **Ask Agent** (or `agentmgr ask`, with `--engine` for another engine) creates a `general` agent. All general sessions share `~/.agentmanager/general`, so Claude's folder-trust prompt only appears the first time.
1129
1130
 
1131
+ ## MCP servers and tools
1132
+
1133
+ **MCP** in the top bar (or **MCP tools** in an agent's detail, or `agentmgr mcp [agent]`) lists the MCP servers Claude Code has in a folder: your own servers, the project's `.mcp.json`, local ones, claude.ai connectors and plugins' servers. Each shows its status, where it comes from, where it runs and its tools, marked *read-only* or *destructive* when the server says so. Pick the home folder or any agent's workspace at the top, since a workspace adds its project's servers. Environment variables, headers, URL queries and secret-looking arguments are never shown.
1134
+
1135
+ **Its own MCP session.** Each folder gets an MCP session of its own on the daemon: one Claude Code process, separate from any agent's session, that the app talks to through Claude Code's control protocol. It keeps the servers connected, so listing, signing in, reconnecting and calling a tool make no model call and don't interrupt an agent. The session closes after 15 minutes unused and starts again when needed. **Refresh all** starts a new one, which reads the configuration again. **↗ Window** opens the panel in a window of its own (`#mcp` or `#mcp/<agent>`), and **Runs in this MCP session** at the bottom keeps the last 30 runs with their results.
1136
+
1137
+ **Signing in.** A server that needs it shows **needs sign-in** and a **Sign in** button (or `agentmgr mcp signin <agent|home> <server>`), which opens that server's sign-in page in a new tab and keeps the link on the page. Claude Code runs the sign-in and keeps the tokens; the app never sees them. When you finish, the server connects by itself. The sign-in ends on an address on the computer the daemon runs on, so from another device (or when that last page doesn't load) paste the address the browser ended on into the box under the link. A claude.ai connector is connected on claude.ai instead: the link goes there.
1138
+
1139
+ **↻ on each server** (or `agentmgr mcp reconnect <agent|home> <server>`) connects that one server again and lists its tools, after signing in or when it failed. The others are left alone.
1140
+
1141
+ **Run…** on a tool takes its input and runs it in one of three ways:
1142
+ - **Run** with the tool's arguments as JSON (`{"query": "…"}`), or with nothing: the tool is called directly in the folder's MCP session, with no model call, and its output is shown as it is.
1143
+ - **Run** with a request in plain words: a separate one-off Claude Code call in that folder, allowed only that one tool, works out the arguments and shows what the tool returned.
1144
+ - **Run in agent session** tells the agent to use the tool, with its conversation and context. The answer is in the session. This works for Claude Code agents.
1145
+
1146
+ `agentmgr mcp run <agent|home> <server> <tool> [arguments or request]` does the first two, and `--session` the third. A destructive tool needs a second click. Plugins can refuse runs outside an agent's session with the `mcp.run` policy.
1147
+
1130
1148
  ## Configuration
1131
1149
 
1132
1150
  State lives in `~/.agentmanager/` (`state.json`, `daemon.log`, `repos/` for shared clones, `workspaces/` for worktrees). Set `AGENTMGR_HOME` or `AGENTMGR_PORT` to change the location or port. Optional `~/.agentmanager/config.json`:
package/docs/plugins.md CHANGED
@@ -53,6 +53,7 @@ Policies are synchronous so every code path can call them. Keep them fast; do sl
53
53
  | `agent.start` | Before an agent's engine is launched or resumed (including after a restart) | `agent`, `fresh` |
54
54
  | `agent.message` | Before a message is typed into an agent (`tell`, inbox replies) | `agent`, `text`, `source` |
55
55
  | `agent.remove` | Before an agent is deleted | `agent`, `deleteWorkspace` |
56
+ | `mcp.run` | Before an MCP tool runs in a folder's MCP session (the MCP panel's **Run**, `agentmgr mcp run`); running it in an agent's session goes through `agent.message` | `agent` (or null for the home folder), `dir`, `tool`, `input`, `where` (`direct`: called with the JSON arguments in `input`; `workspace`: through a one-off Claude Code call) |
56
57
  | `agent.commit` | Before Commit in the review screen commits an agent's worktree | `agent`, `message` |
57
58
  | `agent.pr` | Before the review screen pushes an agent's branch and opens a pull request | `agent`, `title`, `draft` |
58
59
  | `agent.merge` | Before Merge (or auto-merge) in the Land tab merges an agent's pull request | `agent`, `url`, `method`, `auto` |
@@ -64,7 +65,7 @@ Policies are synchronous so every code path can call them. Keep them fast; do sl
64
65
 
65
66
  ## Daemon events (listeners)
66
67
 
67
- `agent.created`, `agent.starting`, `agent.stopping`, `agent.message`, `agent.removed`, `agent.commit` (with `sha`), `agent.pr` (with `url`), `agent.merge`, `hub.action`, each with the same `agent` summary and an `at` timestamp.
68
+ `agent.created`, `agent.starting`, `agent.stopping`, `agent.message`, `agent.removed`, `agent.commit` (with `sha`), `agent.pr` (with `url`), `agent.merge`, `hub.action`, `mcp.run`, each with the same `agent` summary and an `at` timestamp.
68
69
 
69
70
  ## Engines
70
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.41.0",
3
+ "version": "1.43.0",
4
4
  "description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
5
5
  "keywords": [
6
6
  "claude",
package/public/app.js CHANGED
@@ -38,6 +38,7 @@ import { initReviews } from '/reviews.js';
38
38
  import { initBugHunt } from '/bughunt.js';
39
39
  import { drawDiagram } from '/diagram.js';
40
40
  import { initValue } from '/value.js';
41
+ import { initMcp } from '/mcp.js';
41
42
  import { initCodeMap } from '/codemap.js';
42
43
  import { initKeys } from '/keys.js';
43
44
  import { morph } from '/morph.js';
@@ -66,8 +67,10 @@ const standupOnLoad = hashId === 'standup';
66
67
  const mapOnLoad = hashId === 'map';
67
68
  const valueOnLoad = hashId === 'value';
68
69
  const reviewsOnLoad = hashId === 'reviews';
70
+ // "#mcp" or "#mcp/<agent>": the MCP window on its own.
71
+ const mcpOnLoad = hashId === 'mcp';
69
72
  let watchShown = false;
70
- let selectedId = (watchOnLoad || standupOnLoad || mapOnLoad || valueOnLoad || reviewsOnLoad ? null : hashId) || null;
73
+ let selectedId = (watchOnLoad || standupOnLoad || mapOnLoad || valueOnLoad || reviewsOnLoad || mcpOnLoad ? null : hashId) || null;
71
74
  let openTermOnLoad = hashView === 'term' || hashView === 'code' || isShell(hashView) || isBrowser(hashView);
72
75
  let filterText = '';
73
76
  // "Only agents created in the last N days": remembered in this browser.
@@ -296,6 +299,9 @@ $('#bugs-btn').onclick = () => bugsUi.open();
296
299
  // Value: what the delivered work is worth, for you and for management.
297
300
  const valueUi = initValue({ api, $, esc, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)) });
298
301
  $('#value-btn').onclick = () => valueUi.open();
302
+ // MCP: the MCP servers and tools Claude Code has in a folder, and running one.
303
+ const mcpUi = initMcp({ api, $, esc, ago, md: (t) => md(t), toast: (m, ms) => toast(m, ms), agents: () => [...agents.values()] });
304
+ $('#mcp-btn').onclick = () => mcpUi.open(selectedId && agents.get(selectedId)?.workdir ? selectedId : null);
299
305
  // Keyboard shortcuts (keys.js): the same actions as the buttons.
300
306
  const keysUi = initKeys({ $, esc, run: (act) => shortcut(act) });
301
307
  $('#keys-btn').onclick = () => keysUi.help();
@@ -2288,6 +2294,7 @@ function renderDetail() {
2288
2294
  ${noRepo(a) ? '' : `<button data-act="changes" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="Read its changes, comment on lines for the agent, commit and open a pull request">Review changes${a.git?.dirtyFiles ? ` <span class="count">${a.git.dirtyFiles}</span>` : ''}</button>`}
2289
2295
  ${a.aiReview?.verdict ? `<button data-act="overview" title="The AI review: what's done, what's missing, the risks">Overview${a.aiReview.seen ? '' : ' <span class="count">new</span>'}</button>` : ''}
2290
2296
  ${a.questions?.length ? `<button data-act="questions" title="What the agent asked you, and your answers">Questions${openQuestions(a) ? ` <span class="count">${openQuestions(a)}</span>` : ''}</button>` : ''}
2297
+ <button data-act="mcp" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="The MCP servers and tools Claude Code has in this agent's folder; run one in its session or once in the workspace">MCP tools</button>
2291
2298
  <button data-act="fork" ${a.workdir && a.git?.branch ? '' : 'disabled'} title="A new agent with this one's code and conversation, in its own worktree, to try another approach">Fork</button>
2292
2299
  <button data-act="edit" title="Change its name, request, project, priority, permission mode or model">Edit</button>
2293
2300
  <button data-act="refresh" title="Re-scan git, PRs and transcripts">Refresh</button>
@@ -3882,6 +3889,8 @@ $('#detail-body').addEventListener('click', async (e) => {
3882
3889
  case 'overview':
3883
3890
  case 'questions':
3884
3891
  return openNeeds(a.id, btn.dataset.act);
3892
+ case 'mcp':
3893
+ return mcpUi.open(a.id);
3885
3894
  case 'memory':
3886
3895
  return openMemory(a);
3887
3896
  case 'fork':
@@ -4397,6 +4406,11 @@ function handleEvent(msg) {
4397
4406
  history.replaceState(null, '', '#');
4398
4407
  standupUi.open();
4399
4408
  }
4409
+ if (mcpOnLoad && !watchShown) {
4410
+ watchShown = true;
4411
+ history.replaceState(null, '', '#');
4412
+ mcpUi.open(agents.has(hashView) ? hashView : null);
4413
+ }
4400
4414
  if (watchOnLoad && !watchUi.isOpen() && !watchShown) {
4401
4415
  watchShown = true;
4402
4416
  watchUi.show(true);
package/public/index.html CHANGED
@@ -42,6 +42,7 @@
42
42
  <button id="value-btn" title="Value: what the delivered work is worth, by day, week, month and quarter, against the AI cost and your time; reports for management">Value</button>
43
43
  <button id="map-btn" title="The codebase map: where each agent is changing and reading code, and who is about to collide">Map</button>
44
44
  <button id="watch-btn" title="Running agents' sessions side by side, live: follow them all without clicking from one to the next">Watch</button>
45
+ <button id="mcp-btn" title="MCP: the MCP servers Claude Code has (yours, projects', claude.ai connectors and plugins), their tools, and running one in an agent's session or workspace">MCP</button>
45
46
  <button id="machine-btn" title="A terminal on this computer (your home folder), from any device you're signed in on">Terminal</button>
46
47
  <button id="ask-btn" title="A general session with no repo or folder, on Claude Code or another engine you have (Codex, Muse Code, …)">Ask Agent</button>
47
48
  <div class="menu-wrap top-more" id="top-more" hidden>
@@ -527,6 +528,16 @@
527
528
  <div id="team-body" class="race-body team-body"></div>
528
529
  </dialog>
529
530
 
531
+ <dialog id="mcp-dialog" class="doc-dialog" aria-label="MCP servers and tools">
532
+ <div class="doc-head">
533
+ <h2>MCP servers and tools</h2>
534
+ <span class="spacer"></span>
535
+ <span id="mcp-head" class="mcp-head"></span>
536
+ <button type="button" id="mcp-close" class="small ghost">Close</button>
537
+ </div>
538
+ <div id="mcp-body" class="needs-body mcp-body"></div>
539
+ </dialog>
540
+
530
541
  <dialog id="needs-dialog" class="doc-dialog">
531
542
  <div class="doc-head">
532
543
  <h2 id="needs-title">Overview</h2>
@@ -846,6 +857,12 @@
846
857
  </div>
847
858
  </dialog>
848
859
 
860
+ <dialog id="update-dialog" class="update-dialog" aria-label="Update">
861
+ <h2 id="update-title">Update</h2>
862
+ <div id="update-body"></div>
863
+ <div class="dialog-actions" id="update-actions"></div>
864
+ </dialog>
865
+
849
866
  <dialog id="about-dialog" class="about-dialog">
850
867
  <h2>AI Agent Manager</h2>
851
868
  <p class="hint">Run and track background coding agents, one per intent.</p>
package/public/mcp.js ADDED
@@ -0,0 +1,327 @@
1
+ // MCP: the MCP servers Claude Code has in an agent's folder (or the home folder), each with its
2
+ // status, where it comes from and its tools. Each folder has its own MCP session on the daemon
3
+ // (apart from any agent's), where a server is signed in to, connected again and its tools are
4
+ // called directly; a tool can also run through Claude Code from plain words, or in the agent's
5
+ // session. The window also opens on its own (#mcp or #mcp/<agent>).
6
+
7
+ const SOURCE = { project: 'Project (.mcp.json)', user: 'User', local: 'Local', claudeai: 'claude.ai connector', dynamic: 'Added at launch', enterprise: 'Managed' };
8
+ const STATUS = { connected: 'mcp-ok', pending: 'mcp-wait', failed: 'fail', 'needs-auth': 'mcp-wait', disabled: '' };
9
+ const STATUS_LABEL = { 'needs-auth': 'needs sign-in' };
10
+ const RAN = { direct: 'called directly', workspace: 'through Claude Code', session: 'in the session' };
11
+ const SIGN_IN_WAIT_MS = 5 * 60_000;
12
+
13
+ /** Arguments typed for a tool: nothing or a JSON object is a direct call; anything else is plain words. */
14
+ export function directArgs(input) {
15
+ const text = String(input ?? '').trim();
16
+ if (!text) return true;
17
+ if (!text.startsWith('{')) return false;
18
+ try {
19
+ const v = JSON.parse(text);
20
+ return Boolean(v) && typeof v === 'object' && !Array.isArray(v);
21
+ } catch {
22
+ return false;
23
+ }
24
+ }
25
+
26
+ export function initMcp({ api, $, esc, ago, md, toast, agents }) {
27
+ const dialog = $('#mcp-dialog');
28
+ const body = $('#mcp-body');
29
+ let where = 'home';
30
+ let data = null;
31
+ let loading = false;
32
+ let query = '';
33
+ const results = new Map(); // "<where>:<tool id>" -> a run | { error } | { running } | { told }
34
+ const forms = new Set(); // tool ids with their run form open
35
+ const sure = new Set(); // destructive tools waiting for a second click
36
+ const signIns = new Map(); // "<where>:<server>" -> { url, callback, local, since, error, busy }
37
+ const reconnecting = new Set(); // "<where>:<server>"
38
+ let watching = null;
39
+
40
+ const sourceOf = (s) => SOURCE[s.source] ?? (String(s.source ?? '').startsWith('plugin') ? `Plugin${s.source.includes(':') ? `: ${s.source.split(':').slice(1).join(':')}` : ''}` : s.source ?? s.scope ?? '');
41
+
42
+ async function load({ refresh = false, quiet = false } = {}) {
43
+ if (!quiet) {
44
+ loading = true;
45
+ render();
46
+ }
47
+ const at = where;
48
+ try {
49
+ const next = await api('GET', `/mcp?agent=${encodeURIComponent(at)}${refresh ? '&refresh=1' : ''}`);
50
+ if (at !== where) return;
51
+ data = next;
52
+ } catch (e) {
53
+ if (at !== where) return;
54
+ data = { servers: [], runs: [], error: e.message };
55
+ } finally {
56
+ loading = false;
57
+ }
58
+ // A sign-in is over once its server is connected.
59
+ for (const s of data.servers ?? []) if (s.status === 'connected' && signIns.delete(`${where}:${s.name}`)) toast(`Signed in to ${s.name}`);
60
+ render();
61
+ }
62
+
63
+ /** While a sign-in is open, look again every few seconds: the server connects by itself when it's done. */
64
+ function watch() {
65
+ clearInterval(watching);
66
+ watching = setInterval(() => {
67
+ for (const [k, v] of signIns) if (Date.now() - v.since > SIGN_IN_WAIT_MS) signIns.delete(k);
68
+ if (!signIns.size || !dialog.open) return clearInterval(watching);
69
+ if ([...signIns.keys()].some((k) => k.startsWith(`${where}:`))) load({ quiet: true });
70
+ }, 3000);
71
+ }
72
+
73
+ function picker() {
74
+ const list = agents().filter((a) => a.workdir && a.status !== 'preparing');
75
+ return `<select id="mcp-where" title="Whose folder: an agent's workspace has its project's servers too. Each folder has its own MCP session">
76
+ <option value="home" ${where === 'home' ? 'selected' : ''}>Home folder (your servers and connectors)</option>
77
+ ${list.map((a) => `<option value="${esc(a.id)}" ${where === a.id ? 'selected' : ''}>${esc(a.name)}</option>`).join('')}
78
+ </select>`;
79
+ }
80
+
81
+ const resultHtml = (r) =>
82
+ r?.error
83
+ ? `<p class="error">${esc(r.error)}</p>`
84
+ : r?.text
85
+ ? `<div class="mcp-result ${r.isError ? 'failed' : ''}"><p class="hint">${r.isError ? 'The tool reported an error · ' : ''}Ran ${ago(r.at)} in ${(r.ms / 1000).toFixed(1)} s, ${RAN[r.where] ?? ''}</p><div class="md">${md(r.text)}</div></div>`
86
+ : r?.told
87
+ ? `<p class="hint">Sent to ${esc(r.told)}. Its answer is in the session.</p>`
88
+ : '';
89
+
90
+ function toolHtml(s, t) {
91
+ const key = `${where}:${t.id}`;
92
+ const r = results.get(key);
93
+ const agent = data.agent;
94
+ const canSession = agent && agent.engine === 'claude';
95
+ const open = forms.has(t.id);
96
+ const tags = `${t.readOnly ? '<span class="tag mcp-ok" title="The server says it only reads">read-only</span>' : ''}${t.destructive ? '<span class="tag fail" title="The server says it may change or delete things">destructive</span>' : ''}`;
97
+ const form = open
98
+ ? `<div class="mcp-form">
99
+ <textarea data-mcp-input="${esc(t.id)}" rows="2" placeholder='Its arguments as JSON, like {"query": "…"}, or nothing: called directly, no model. Or say what it should do in plain words: Claude Code works out the arguments.'></textarea>
100
+ ${sure.has(t.id) ? `<p class="hint error">${esc(t.name)} may change or delete things. Click again to run it.</p>` : ''}
101
+ <div class="mcp-actions">
102
+ ${agent ? `<button type="button" class="small" data-mcp-run="session" data-server="${esc(s.name)}" data-tool="${esc(t.name)}" ${canSession ? '' : 'disabled'} title="${canSession ? `Tell ${esc(agent.name)} to use it, with its conversation and context${agent.running ? '' : ' (resumes the session)'}` : 'Works for Claude Code agents'}">Run in agent session</button>` : ''}
103
+ <button type="button" class="small primary" data-mcp-run="here" data-server="${esc(s.name)}" data-tool="${esc(t.name)}" ${r?.running ? 'disabled' : ''} title="In this folder's MCP session, apart from the agent's: JSON arguments (or none) call the tool directly; plain words go through a one-off Claude Code call that may use only this tool">${r?.running ? 'Running…' : 'Run'}</button>
104
+ </div>
105
+ </div>`
106
+ : '';
107
+ return `<li class="mcp-tool">
108
+ <div class="mcp-tool-row"><code title="${esc(t.id)}">${esc(t.name)}</code>${t.title ? ` <span class="hint">${esc(t.title)}</span>` : ''} ${tags}
109
+ <span class="spacer"></span>${s.status === 'connected' ? `<button type="button" class="small ghost" data-mcp-form="${esc(t.id)}">${open ? 'Hide' : 'Run…'}</button>` : ''}</div>
110
+ ${form}${resultHtml(r)}
111
+ </li>`;
112
+ }
113
+
114
+ function signInHtml(s) {
115
+ const si = signIns.get(`${where}:${s.name}`);
116
+ if (!si) return s.status === 'needs-auth' ? '<p class="hint">Sign in to use its tools. Claude Code keeps the sign-in; this app never sees it.</p>' : '';
117
+ if (si.busy) return '<p class="hint">Getting the sign-in page…</p>';
118
+ if (si.error) return `<p class="error">${esc(si.error)}</p>`;
119
+ return `<div class="mcp-signin">
120
+ <p><a href="${esc(si.url)}" target="_blank" rel="noopener">Open the sign-in page ↗</a> <span class="hint">${si.callback ? 'When you finish there, this server connects by itself.' : 'When you have connected it there, press ↻ here.'}</span></p>
121
+ ${si.callback ? `<details data-keep="cb:${esc(s.name)}"><summary class="hint">Signing in on another device, or the page at the end doesn't load?</summary>
122
+ <p class="hint">The sign-in ends on an address on this computer (localhost). Copy that address from the browser and paste it here.</p>
123
+ <div class="mcp-paste"><input type="text" data-mcp-callback="${esc(s.name)}" placeholder="http://localhost:…/callback?code=…" /><button type="button" class="small" data-mcp-callback-send="${esc(s.name)}">Finish sign-in</button></div>
124
+ </details>` : ''}
125
+ </div>`;
126
+ }
127
+
128
+ function serverHtml(s) {
129
+ const q = query.toLowerCase();
130
+ const tools = s.tools.filter((t) => !q || s.name.toLowerCase().includes(q) || t.name.toLowerCase().includes(q) || (t.title ?? '').toLowerCase().includes(q));
131
+ if (q && !tools.length && !s.name.toLowerCase().includes(q)) return '';
132
+ const busy = reconnecting.has(`${where}:${s.name}`);
133
+ const needs = s.status === 'needs-auth';
134
+ return `<details class="mcp-server" data-keep="srv:${esc(s.name)}" ${q || s.tools.length <= 12 ? 'open' : ''}>
135
+ <summary><b>${esc(s.name)}</b> <span class="tag ${STATUS[s.status] ?? ''}">${esc(STATUS_LABEL[s.status] ?? s.status)}</span> <span class="tag">${esc(sourceOf(s))}</span>
136
+ <span class="hint">${s.tools.length} tool${s.tools.length === 1 ? '' : 's'}</span><span class="spacer"></span>
137
+ ${needs && s.canSignIn ? `<button type="button" class="small primary" data-mcp-signin="${esc(s.name)}" title="Open ${esc(s.name)}'s sign-in page">Sign in</button>` : ''}
138
+ ${s.status === 'disabled' ? '' : `<button type="button" class="small ghost mcp-again" data-mcp-reconnect="${esc(s.name)}" ${busy ? 'disabled' : ''} title="Connect ${esc(s.name)} again and list its tools${needs ? ' (after signing in)' : ''}" aria-label="Refresh ${esc(s.name)}">${busy ? '…' : '↻'}</button>`}</summary>
139
+ ${s.target ? `<p class="hint mcp-target" title="${esc(s.transport ?? '')}">${esc(s.target)}</p>` : ''}
140
+ ${s.error ? `<p class="error">${esc(s.error)}</p>` : ''}
141
+ ${signInHtml(s)}
142
+ ${tools.length ? `<ul class="mcp-tools">${tools.map((t) => toolHtml(s, t)).join('')}</ul>` : s.status === 'connected' ? '<p class="hint">No tools.</p>' : ''}
143
+ </details>`;
144
+ }
145
+
146
+ function runsHtml() {
147
+ const runs = data.runs ?? [];
148
+ if (!runs.length) return '';
149
+ return `<details class="mcp-runs" data-keep="runs"><summary><b>Runs in this MCP session</b> <span class="hint">${runs.length}, newest first</span></summary>
150
+ <ul class="mcp-tools">${runs.map((r) => `<li class="mcp-tool"><details data-keep="run:${esc(r.at)}"><summary><code>${esc(r.server)}: ${esc(r.name)}</code> ${r.isError ? '<span class="tag fail">error</span>' : ''} <span class="hint">${ago(r.at)} · ${(r.ms / 1000).toFixed(1)} s · ${RAN[r.where] ?? ''}</span></summary>
151
+ ${r.input ? `<p class="hint mcp-target">${esc(r.input)}</p>` : ''}<div class="mcp-result ${r.isError ? 'failed' : ''}"><div class="md">${md(r.text)}</div></div></details></li>`).join('')}</ul>
152
+ </details>`;
153
+ }
154
+
155
+ function render() {
156
+ if (!dialog.open) return;
157
+ // What was typed, where the cursor is and what was folded all survive a redraw.
158
+ const boxKey = (t) => (t?.dataset?.mcpInput ? `in:${t.dataset.mcpInput}` : t?.dataset?.mcpCallback ? `cb:${t.dataset.mcpCallback}` : null);
159
+ const boxes = () => [...body.querySelectorAll('[data-mcp-input], [data-mcp-callback]')];
160
+ const active = document.activeElement;
161
+ const focus = boxKey(active) && { key: boxKey(active), from: active.selectionStart, to: active.selectionEnd };
162
+ const typed = new Map(boxes().map((t) => [boxKey(t), t.value]));
163
+ const folded = new Map([...body.querySelectorAll('details[data-keep]')].map((d) => [d.dataset.keep, d.open]));
164
+ const n = data?.servers?.reduce((k, s) => k + s.tools.length, 0) ?? 0;
165
+ $('#mcp-head').innerHTML = `${picker()}<input id="mcp-filter" type="search" placeholder="Filter servers and tools" value="${esc(query)}" />
166
+ <button type="button" class="small" id="mcp-refresh" ${loading ? 'disabled' : ''} title="Start this folder's MCP session again: it reads the configuration again and connects to every server">${loading ? 'Listing…' : 'Refresh all'}</button>
167
+ ${window.name === 'agentmgr-mcp' ? '' : '<button type="button" class="small ghost" id="mcp-window" title="Open this in its own window">↗ Window</button>'}`;
168
+ body.innerHTML = loading && !data
169
+ ? '<p class="hint">Starting the MCP session here and asking Claude Code for its servers (it connects to each one)…</p>'
170
+ : !data
171
+ ? ''
172
+ : `<p class="hint">${data.servers.length} server${data.servers.length === 1 ? '' : 's'}, ${n} tool${n === 1 ? '' : 's'}${data.at ? `, listed ${ago(data.at)}` : ''}${data.dir ? ` in <code>${esc(data.dir)}</code>` : ''}. The same servers Claude Code has there: your own, the project's .mcp.json, claude.ai connectors and plugins. ${data.session ? `This folder's MCP session has been up since ${ago(data.session.startedAt)}; it is separate from any agent's session.` : ''}</p>
173
+ ${data.error ? `<p class="error">${esc(data.error)}</p>` : ''}
174
+ ${data.servers.map(serverHtml).join('') || (data.error ? '' : '<p class="hint">No MCP servers here. Add one with <code>claude mcp add</code>, or a .mcp.json in the project.</p>')}
175
+ ${runsHtml()}`;
176
+ for (const box of boxes()) {
177
+ const key = boxKey(box);
178
+ if (typed.has(key)) box.value = typed.get(key);
179
+ if (focus?.key === key) {
180
+ box.focus();
181
+ box.setSelectionRange(focus.from, focus.to);
182
+ }
183
+ }
184
+ for (const d of body.querySelectorAll('details[data-keep]')) if (folded.has(d.dataset.keep)) d.open = folded.get(d.dataset.keep);
185
+ }
186
+
187
+ async function run(btn) {
188
+ const server = btn.dataset.server;
189
+ const tool = btn.dataset.tool;
190
+ const t = data.servers.find((s) => s.name === server)?.tools.find((x) => x.name === tool);
191
+ if (!t) return;
192
+ if (t.destructive && !sure.has(t.id)) {
193
+ sure.add(t.id);
194
+ return render();
195
+ }
196
+ sure.delete(t.id);
197
+ const input = body.querySelector(`[data-mcp-input="${CSS.escape(t.id)}"]`)?.value ?? '';
198
+ const key = `${where}:${t.id}`;
199
+ if (btn.dataset.mcpRun === 'session') {
200
+ try {
201
+ await api('POST', '/mcp/run', { agent: where, server, tool, input, where: 'session' });
202
+ results.set(key, { told: data.agent.name });
203
+ toast(`Asked ${data.agent.name} to use ${tool}`);
204
+ } catch (e) {
205
+ results.set(key, { error: e.message });
206
+ }
207
+ return render();
208
+ }
209
+ results.set(key, { running: true });
210
+ render();
211
+ try {
212
+ const r = await api('POST', '/mcp/run', { agent: where, server, tool, input, where: directArgs(input) ? 'direct' : 'workspace' });
213
+ results.set(key, r);
214
+ data.runs = [r, ...(data.runs ?? [])].slice(0, 30);
215
+ } catch (e) {
216
+ results.set(key, { error: e.message });
217
+ }
218
+ render();
219
+ }
220
+
221
+ /** Sign in: the page opens in a new tab at once (so the browser doesn't block it), then goes to the address. */
222
+ async function signIn(name) {
223
+ const key = `${where}:${name}`;
224
+ const tab = window.open('', '_blank');
225
+ signIns.set(key, { busy: true, since: Date.now() });
226
+ render();
227
+ try {
228
+ const r = await api('POST', '/mcp/signin', { agent: where, server: name });
229
+ if (!r.url) {
230
+ tab?.close();
231
+ signIns.delete(key);
232
+ toast(`${name} is already signed in`);
233
+ return load({ quiet: true });
234
+ }
235
+ signIns.set(key, { url: r.url, callback: r.callback, local: r.local, since: Date.now() });
236
+ if (tab) tab.location = r.url;
237
+ watch();
238
+ } catch (e) {
239
+ tab?.close();
240
+ signIns.set(key, { error: e.message, since: Date.now() });
241
+ }
242
+ render();
243
+ }
244
+
245
+ async function reconnect(name) {
246
+ const key = `${where}:${name}`;
247
+ reconnecting.add(key);
248
+ render();
249
+ try {
250
+ data = await api('POST', '/mcp/reconnect', { agent: where, server: name });
251
+ const s = data.servers.find((x) => x.name === name);
252
+ if (s?.status === 'connected') signIns.delete(key);
253
+ toast(`${name}: ${STATUS_LABEL[s?.status] ?? s?.status ?? 'not listed'}${s?.status === 'connected' ? `, ${s.tools.length} tool${s.tools.length === 1 ? '' : 's'}` : ''}`);
254
+ } catch (e) {
255
+ toast(`${name}: ${e.message}`, 6000);
256
+ } finally {
257
+ reconnecting.delete(key);
258
+ }
259
+ render();
260
+ }
261
+
262
+ async function finishSignIn(name) {
263
+ const url = body.querySelector(`[data-mcp-callback="${CSS.escape(name)}"]`)?.value.trim();
264
+ if (!url) return;
265
+ try {
266
+ data = await api('POST', '/mcp/signin/callback', { agent: where, server: name, url });
267
+ if (data.servers.find((x) => x.name === name)?.status === 'connected') {
268
+ signIns.delete(`${where}:${name}`);
269
+ toast(`Signed in to ${name}`);
270
+ }
271
+ } catch (e) {
272
+ toast(e.message, 8000);
273
+ }
274
+ render();
275
+ }
276
+
277
+ dialog.addEventListener('click', (e) => {
278
+ const b = e.target.closest('button');
279
+ if (!b) return;
280
+ // Buttons in a server's heading don't fold it.
281
+ if (b.closest('summary')) e.preventDefault();
282
+ if (b.id === 'mcp-close') return dialog.close();
283
+ if (b.id === 'mcp-refresh') return load({ refresh: true });
284
+ if (b.id === 'mcp-window') return void window.open(`/#mcp${where === 'home' ? '' : `/${where}`}`, 'agentmgr-mcp', 'width=1040,height=820');
285
+ if (b.dataset.mcpSignin) return signIn(b.dataset.mcpSignin);
286
+ if (b.dataset.mcpReconnect) return reconnect(b.dataset.mcpReconnect);
287
+ if (b.dataset.mcpCallbackSend) return finishSignIn(b.dataset.mcpCallbackSend);
288
+ if (b.dataset.mcpForm) {
289
+ if (forms.has(b.dataset.mcpForm)) forms.delete(b.dataset.mcpForm);
290
+ else forms.add(b.dataset.mcpForm);
291
+ sure.delete(b.dataset.mcpForm);
292
+ return render();
293
+ }
294
+ if (b.dataset.mcpRun) return run(b);
295
+ });
296
+ dialog.addEventListener('change', (e) => {
297
+ if (e.target.id !== 'mcp-where') return;
298
+ where = e.target.value;
299
+ data = null;
300
+ forms.clear();
301
+ load();
302
+ });
303
+ dialog.addEventListener('input', (e) => {
304
+ if (e.target.id !== 'mcp-filter') return;
305
+ query = e.target.value.trim();
306
+ const pos = e.target.selectionStart;
307
+ render();
308
+ const box = $('#mcp-filter');
309
+ box.focus();
310
+ box.setSelectionRange(pos, pos);
311
+ });
312
+
313
+ return {
314
+ /** Open for an agent's workspace, or the home folder. */
315
+ open(agentId = null) {
316
+ const next = agentId ?? 'home';
317
+ if (next !== where) {
318
+ where = next;
319
+ data = null;
320
+ forms.clear();
321
+ }
322
+ if (!dialog.open) dialog.showModal();
323
+ render();
324
+ load();
325
+ },
326
+ };
327
+ }
package/public/style.css CHANGED
@@ -512,6 +512,19 @@ dialog::backdrop { background: rgba(0, 0, 0, .45); }
512
512
  .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
513
513
  .error { color: var(--red); margin: 0; font-size: 13px; }
514
514
 
515
+ .update-dialog { width: min(520px, calc(100vw - 32px)); padding: 20px; }
516
+ .update-dialog h2 { margin: 0 0 8px; font-size: 17px; }
517
+ .update-dialog p { margin: 6px 0; font-size: 13px; }
518
+ .update-steps { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
519
+ .update-steps li { display: grid; grid-template-columns: 22px 1fr; gap: 4px 6px; align-items: baseline; color: var(--muted); }
520
+ .update-steps li.now { color: var(--text); font-weight: 600; }
521
+ .update-steps li.done { color: var(--text); }
522
+ .update-steps li .hint { grid-column: 2; font-weight: 400; word-break: break-word; }
523
+ .update-bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin: 4px 0 10px; }
524
+ .update-bar span { display: block; height: 100%; width: 35%; background: var(--accent); border-radius: 2px; animation: update-slide 1.4s ease-in-out infinite; }
525
+ @keyframes update-slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
526
+ @media (prefers-reduced-motion: reduce) { .update-bar span { animation: none; width: 100%; opacity: 0.5; } }
527
+
515
528
  .toast button { margin-left: 8px; }
516
529
  .toast {
517
530
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
@@ -731,6 +744,31 @@ pre.diff .meta { color: var(--muted); font-weight: 600; }
731
744
  .needs-body .needs .needs { margin-top: 0; }
732
745
  .needs-body h4 { margin: 16px 0 6px; }
733
746
  .needs-body .answered { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
747
+ .mcp-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
748
+ .mcp-head select { max-width: 280px; }
749
+ .mcp-head input { width: 200px; }
750
+ .mcp-body > p:first-child { margin-top: 10px; }
751
+ .mcp-server { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin: 8px 0; }
752
+ .mcp-server summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
753
+ .mcp-target { margin: 4px 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }
754
+ .mcp-tools { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
755
+ .mcp-tool { border-top: 1px solid var(--border); padding-top: 4px; }
756
+ .mcp-tool-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
757
+ .mcp-tool-row .spacer { flex: 1; }
758
+ .mcp-form { display: grid; gap: 6px; margin: 6px 0; }
759
+ .mcp-form textarea { width: 100%; box-sizing: border-box; }
760
+ .mcp-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
761
+ .mcp-result { border-left: 3px solid var(--border); padding-left: 10px; margin: 6px 0; max-height: 320px; overflow: auto; }
762
+ .mcp-server summary .spacer { flex: 1; }
763
+ .mcp-again { min-width: 28px; font-size: 15px; line-height: 1; }
764
+ .mcp-signin p { margin: 6px 0; }
765
+ .mcp-paste { display: flex; gap: 6px; margin: 6px 0; }
766
+ .mcp-paste input { flex: 1; min-width: 0; }
767
+ .mcp-result.failed { border-left-color: var(--red); }
768
+ .mcp-runs { margin: 14px 0 0; padding: 6px 10px; border: 1px dashed var(--border); border-radius: 6px; }
769
+ .mcp-runs summary { cursor: pointer; }
770
+ .tag.mcp-ok { color: var(--green); }
771
+ .tag.mcp-wait { color: var(--yellow); }
734
772
  .rv-summary { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
735
773
  .rv-warn { margin: 0; color: var(--yellow); }
736
774
  .rv-add { color: var(--green); font-family: var(--mono); font-size: 12px; }