ai-agentmanager 1.41.0 → 1.42.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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.42.0 (2026-11-11)
4
+
5
+ - **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.
6
+ - **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.
7
+
3
8
  ## 1.41.0 (2026-11-11)
4
9
 
5
10
  - **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, and run any tool in an agent's session or once in its workspace.
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.
@@ -1127,6 +1128,16 @@ 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. The app asks Claude Code itself through its control protocol, which connects to each server but makes no model call. The list is kept for 5 minutes, and **Refresh** asks again. Environment variables, headers, URL queries and secret-looking arguments are never shown.
1134
+
1135
+ **Run…** on a tool takes an optional request in plain words, then runs it in one of two ways:
1136
+ - **Run in 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.
1137
+ - **Run once in workspace** (or `agentmgr mcp run <agent|home> <server> <tool> [request]`) is a separate one-off Claude Code call in that folder. It may use only that one tool, works out the arguments from your request, and shows what the tool returned. The agent isn't interrupted.
1138
+
1139
+ A destructive tool needs a second click. Plugins can refuse one-off runs with the `mcp.run` policy.
1140
+
1130
1141
  ## Configuration
1131
1142
 
1132
1143
  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 once in a folder (the MCP panel's **Run once**, `agentmgr mcp run`); running it in a session goes through `agent.message` | `agent` (or null for the home folder), `dir`, `tool`, `input` |
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.42.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';
@@ -296,6 +297,9 @@ $('#bugs-btn').onclick = () => bugsUi.open();
296
297
  // Value: what the delivered work is worth, for you and for management.
297
298
  const valueUi = initValue({ api, $, esc, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)) });
298
299
  $('#value-btn').onclick = () => valueUi.open();
300
+ // MCP: the MCP servers and tools Claude Code has in a folder, and running one.
301
+ const mcpUi = initMcp({ api, $, esc, ago, md: (t) => md(t), toast: (m, ms) => toast(m, ms), agents: () => [...agents.values()] });
302
+ $('#mcp-btn').onclick = () => mcpUi.open(selectedId && agents.get(selectedId)?.workdir ? selectedId : null);
299
303
  // Keyboard shortcuts (keys.js): the same actions as the buttons.
300
304
  const keysUi = initKeys({ $, esc, run: (act) => shortcut(act) });
301
305
  $('#keys-btn').onclick = () => keysUi.help();
@@ -2288,6 +2292,7 @@ function renderDetail() {
2288
2292
  ${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
2293
  ${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
2294
  ${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>` : ''}
2295
+ <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
2296
  <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
2297
  <button data-act="edit" title="Change its name, request, project, priority, permission mode or model">Edit</button>
2293
2298
  <button data-act="refresh" title="Re-scan git, PRs and transcripts">Refresh</button>
@@ -3882,6 +3887,8 @@ $('#detail-body').addEventListener('click', async (e) => {
3882
3887
  case 'overview':
3883
3888
  case 'questions':
3884
3889
  return openNeeds(a.id, btn.dataset.act);
3890
+ case 'mcp':
3891
+ return mcpUi.open(a.id);
3885
3892
  case 'memory':
3886
3893
  return openMemory(a);
3887
3894
  case 'fork':
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>
package/public/mcp.js ADDED
@@ -0,0 +1,185 @@
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; any tool runs in the agent's session, or once in the
3
+ // workspace with only that tool allowed.
4
+
5
+ const SOURCE = { project: 'Project (.mcp.json)', user: 'User', local: 'Local', claudeai: 'claude.ai connector', dynamic: 'Added at launch', enterprise: 'Managed' };
6
+ const STATUS = { connected: 'mcp-ok', pending: 'mcp-wait', failed: 'fail', 'needs-auth': 'mcp-wait', disabled: '' };
7
+
8
+ export function initMcp({ api, $, esc, ago, md, toast, agents }) {
9
+ const dialog = $('#mcp-dialog');
10
+ const body = $('#mcp-body');
11
+ let where = 'home';
12
+ let data = null;
13
+ let loading = false;
14
+ let query = '';
15
+ const results = new Map(); // "<where>:<tool id>" -> { text, ms, at } | { error } | { running }
16
+ const forms = new Set(); // tool ids with their run form open
17
+ const sure = new Set(); // destructive tools waiting for a second click
18
+
19
+ 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 ?? '');
20
+
21
+ async function load(refresh = false) {
22
+ loading = true;
23
+ render();
24
+ try {
25
+ data = await api('GET', `/mcp?agent=${encodeURIComponent(where)}${refresh ? '&refresh=1' : ''}`);
26
+ } catch (e) {
27
+ data = { servers: [], error: e.message };
28
+ } finally {
29
+ loading = false;
30
+ }
31
+ render();
32
+ }
33
+
34
+ function picker() {
35
+ const list = agents().filter((a) => a.workdir && a.status !== 'preparing');
36
+ return `<select id="mcp-where" title="Whose folder: an agent's workspace has its project's servers too">
37
+ <option value="home" ${where === 'home' ? 'selected' : ''}>Home folder (your servers and connectors)</option>
38
+ ${list.map((a) => `<option value="${esc(a.id)}" ${where === a.id ? 'selected' : ''}>${esc(a.name)}</option>`).join('')}
39
+ </select>`;
40
+ }
41
+
42
+ function toolHtml(s, t) {
43
+ const key = `${where}:${t.id}`;
44
+ const r = results.get(key);
45
+ const agent = data.agent;
46
+ const canSession = agent && agent.engine === 'claude';
47
+ const open = forms.has(t.id);
48
+ 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>' : ''}`;
49
+ const form = open
50
+ ? `<div class="mcp-form">
51
+ <textarea data-mcp-input="${esc(t.id)}" rows="2" placeholder="What it should do, or its arguments in plain words (optional)"></textarea>
52
+ ${sure.has(t.id) ? `<p class="hint error">${esc(t.name)} may change or delete things. Click again to run it.</p>` : ''}
53
+ <div class="mcp-actions">
54
+ ${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 session</button>` : ''}
55
+ <button type="button" class="small primary" data-mcp-run="workspace" data-server="${esc(s.name)}" data-tool="${esc(t.name)}" ${r?.running ? 'disabled' : ''} title="A separate one-off Claude Code call in ${agent ? 'the workspace' : 'your home folder'} that may use only this tool; the agent is not interrupted">${r?.running ? 'Running…' : `Run once in ${agent ? 'workspace' : 'home folder'}`}</button>
56
+ </div>
57
+ </div>`
58
+ : '';
59
+ const out = r?.error
60
+ ? `<p class="error">${esc(r.error)}</p>`
61
+ : r?.text
62
+ ? `<div class="mcp-result"><p class="hint">Ran ${ago(r.at)} in ${(r.ms / 1000).toFixed(1)} s</p><div class="md">${md(r.text)}</div></div>`
63
+ : r?.told
64
+ ? `<p class="hint">Sent to ${esc(r.told)}. Its answer is in the session.</p>`
65
+ : '';
66
+ return `<li class="mcp-tool">
67
+ <div class="mcp-tool-row"><code title="${esc(t.id)}">${esc(t.name)}</code>${t.title ? ` <span class="hint">${esc(t.title)}</span>` : ''} ${tags}
68
+ <span class="spacer"></span>${s.status === 'connected' ? `<button type="button" class="small ghost" data-mcp-form="${esc(t.id)}">${open ? 'Hide' : 'Run…'}</button>` : ''}</div>
69
+ ${form}${out}
70
+ </li>`;
71
+ }
72
+
73
+ function serverHtml(s) {
74
+ const q = query.toLowerCase();
75
+ const tools = s.tools.filter((t) => !q || s.name.toLowerCase().includes(q) || t.name.toLowerCase().includes(q) || (t.title ?? '').toLowerCase().includes(q));
76
+ if (q && !tools.length) return '';
77
+ return `<details class="mcp-server" ${q || s.tools.length <= 12 ? 'open' : ''}>
78
+ <summary><b>${esc(s.name)}</b> <span class="tag ${STATUS[s.status] ?? ''}">${esc(s.status)}</span> <span class="tag">${esc(sourceOf(s))}</span>
79
+ <span class="hint">${s.tools.length} tool${s.tools.length === 1 ? '' : 's'}</span></summary>
80
+ ${s.target ? `<p class="hint mcp-target" title="${esc(s.transport ?? '')}">${esc(s.target)}</p>` : ''}
81
+ ${s.error ? `<p class="error">${esc(s.error)}</p>` : ''}
82
+ ${s.status === 'needs-auth' ? '<p class="hint">Sign in to it from Claude Code (/mcp) to use its tools.</p>' : ''}
83
+ ${tools.length ? `<ul class="mcp-tools">${tools.map((t) => toolHtml(s, t)).join('')}</ul>` : s.status === 'connected' ? '<p class="hint">No tools.</p>' : ''}
84
+ </details>`;
85
+ }
86
+
87
+ function render() {
88
+ if (!dialog.open) return;
89
+ const focus = document.activeElement?.dataset?.mcpInput;
90
+ const typed = Object.fromEntries([...body.querySelectorAll('[data-mcp-input]')].map((t) => [t.dataset.mcpInput, t.value]));
91
+ const n = data?.servers?.reduce((k, s) => k + s.tools.length, 0) ?? 0;
92
+ $('#mcp-head').innerHTML = `${picker()}<input id="mcp-filter" type="search" placeholder="Filter servers and tools" value="${esc(query)}" />
93
+ <button type="button" class="small" id="mcp-refresh" ${loading ? 'disabled' : ''} title="Ask Claude Code again (it connects to each server)">${loading ? 'Listing…' : 'Refresh'}</button>`;
94
+ body.innerHTML = loading && !data
95
+ ? '<p class="hint">Asking Claude Code for its MCP servers here (it connects to each one)…</p>'
96
+ : !data
97
+ ? ''
98
+ : `<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.</p>
99
+ ${data.error ? `<p class="error">${esc(data.error)}</p>` : ''}
100
+ ${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>')}`;
101
+ for (const [id, v] of Object.entries(typed)) {
102
+ const box = body.querySelector(`[data-mcp-input="${CSS.escape(id)}"]`);
103
+ if (box) box.value = v;
104
+ }
105
+ if (focus) body.querySelector(`[data-mcp-input="${CSS.escape(focus)}"]`)?.focus();
106
+ }
107
+
108
+ async function run(btn) {
109
+ const how = btn.dataset.mcpRun;
110
+ const server = btn.dataset.server;
111
+ const tool = btn.dataset.tool;
112
+ const t = data.servers.find((s) => s.name === server)?.tools.find((x) => x.name === tool);
113
+ if (!t) return;
114
+ if (t.destructive && !sure.has(t.id)) {
115
+ sure.add(t.id);
116
+ return render();
117
+ }
118
+ sure.delete(t.id);
119
+ const input = body.querySelector(`[data-mcp-input="${CSS.escape(t.id)}"]`)?.value ?? '';
120
+ const key = `${where}:${t.id}`;
121
+ if (how === 'session') {
122
+ try {
123
+ await api('POST', '/mcp/run', { agent: where, server, tool, input, where: 'session' });
124
+ results.set(key, { told: data.agent.name });
125
+ toast(`Asked ${data.agent.name} to use ${tool}`);
126
+ } catch (e) {
127
+ results.set(key, { error: e.message });
128
+ }
129
+ return render();
130
+ }
131
+ results.set(key, { running: true });
132
+ render();
133
+ try {
134
+ results.set(key, await api('POST', '/mcp/run', { agent: where, server, tool, input, where: 'workspace' }));
135
+ } catch (e) {
136
+ results.set(key, { error: e.message });
137
+ }
138
+ render();
139
+ }
140
+
141
+ dialog.addEventListener('click', (e) => {
142
+ const b = e.target.closest('button');
143
+ if (!b) return;
144
+ if (b.id === 'mcp-close') return dialog.close();
145
+ if (b.id === 'mcp-refresh') return load(true);
146
+ if (b.dataset.mcpForm) {
147
+ if (forms.has(b.dataset.mcpForm)) forms.delete(b.dataset.mcpForm);
148
+ else forms.add(b.dataset.mcpForm);
149
+ sure.delete(b.dataset.mcpForm);
150
+ return render();
151
+ }
152
+ if (b.dataset.mcpRun) return run(b);
153
+ });
154
+ dialog.addEventListener('change', (e) => {
155
+ if (e.target.id !== 'mcp-where') return;
156
+ where = e.target.value;
157
+ data = null;
158
+ forms.clear();
159
+ load();
160
+ });
161
+ dialog.addEventListener('input', (e) => {
162
+ if (e.target.id !== 'mcp-filter') return;
163
+ query = e.target.value.trim();
164
+ const pos = e.target.selectionStart;
165
+ render();
166
+ const box = $('#mcp-filter');
167
+ box.focus();
168
+ box.setSelectionRange(pos, pos);
169
+ });
170
+
171
+ return {
172
+ /** Open for an agent's workspace, or the home folder. */
173
+ open(agentId = null) {
174
+ const next = agentId ?? 'home';
175
+ if (next !== where) {
176
+ where = next;
177
+ data = null;
178
+ forms.clear();
179
+ }
180
+ dialog.showModal();
181
+ render();
182
+ load();
183
+ },
184
+ };
185
+ }
package/public/style.css CHANGED
@@ -731,6 +731,23 @@ pre.diff .meta { color: var(--muted); font-weight: 600; }
731
731
  .needs-body .needs .needs { margin-top: 0; }
732
732
  .needs-body h4 { margin: 16px 0 6px; }
733
733
  .needs-body .answered { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
734
+ .mcp-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
735
+ .mcp-head select { max-width: 280px; }
736
+ .mcp-head input { width: 200px; }
737
+ .mcp-body > p:first-child { margin-top: 10px; }
738
+ .mcp-server { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin: 8px 0; }
739
+ .mcp-server summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
740
+ .mcp-target { margin: 4px 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }
741
+ .mcp-tools { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
742
+ .mcp-tool { border-top: 1px solid var(--border); padding-top: 4px; }
743
+ .mcp-tool-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
744
+ .mcp-tool-row .spacer { flex: 1; }
745
+ .mcp-form { display: grid; gap: 6px; margin: 6px 0; }
746
+ .mcp-form textarea { width: 100%; box-sizing: border-box; }
747
+ .mcp-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
748
+ .mcp-result { border-left: 3px solid var(--border); padding-left: 10px; margin: 6px 0; max-height: 320px; overflow: auto; }
749
+ .tag.mcp-ok { color: var(--green); }
750
+ .tag.mcp-wait { color: var(--yellow); }
734
751
  .rv-summary { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
735
752
  .rv-warn { margin: 0; color: var(--yellow); }
736
753
  .rv-add { color: var(--green); font-family: var(--mono); font-size: 12px; }
package/src/cli.js CHANGED
@@ -821,6 +821,43 @@ export async function main(argv) {
821
821
  }
822
822
  });
823
823
 
824
+ const mcp = program.command('mcp').description("MCP servers and their tools as Claude Code has them in an agent's folder (or your home folder), and running one");
825
+ mcp
826
+ .command('list', { isDefault: true })
827
+ .description('List the MCP servers, their status and tools')
828
+ .argument('[agent]', "an agent: its folder's servers too (default: your home folder)")
829
+ .option('-r, --refresh', 'ask Claude Code again instead of the list from the last 5 minutes')
830
+ .option('--json', 'print JSON')
831
+ .action(async (ref, opts) => {
832
+ await daemon();
833
+ const a = ref ? await resolveAgent(ref) : null;
834
+ const r = await api('GET', `/mcp?agent=${encodeURIComponent(a?.id ?? 'home')}${opts.refresh ? '&refresh=1' : ''}`);
835
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
836
+ if (r.error) console.log(red(r.error));
837
+ if (!r.servers.length) return console.log(dim(`No MCP servers in ${r.dir}.`));
838
+ console.log(dim(`In ${r.dir}:`));
839
+ for (const s of r.servers) {
840
+ console.log(`${bold(s.name)} ${s.status === 'connected' ? green(s.status) : yellow(s.status)} ${dim([s.source, s.target].filter(Boolean).join(' '))}`);
841
+ for (const t of s.tools) console.log(` ${t.name}${t.readOnly ? dim(' read-only') : ''}${t.destructive ? red(' destructive') : ''}`);
842
+ }
843
+ });
844
+ mcp
845
+ .command('run')
846
+ .description("Run a tool once in the agent's folder (a separate call allowed only that tool), or in its session with --session")
847
+ .argument('<agent>', 'the agent, or "home" for your home folder')
848
+ .argument('<server>')
849
+ .argument('<tool>')
850
+ .argument('[request...]', 'what it should do, or its arguments in plain words')
851
+ .option('-s, --session', 'tell the agent to use it in its session instead')
852
+ .action(async (ref, server, tool, request, opts) => {
853
+ await daemon();
854
+ const agent = ref === 'home' ? 'home' : (await resolveAgent(ref)).id;
855
+ const r = await api('POST', '/mcp/run', { agent, server, tool, input: request.join(' '), where: opts.session ? 'session' : 'workspace' });
856
+ if (r.where === 'session') return console.log(`${green('✓')} asked ${r.agent.name} to use ${r.tool}; its answer is in the session`);
857
+ console.log(r.text);
858
+ console.log(dim(`(${r.tool}, ${(r.ms / 1000).toFixed(1)} s)`));
859
+ });
860
+
824
861
  program
825
862
  .command('review')
826
863
  .description("Start a reviewer agent on someone else's pull request: it asks the critical questions and finds what blocks approval; nothing is posted")
package/src/manager.js CHANGED
@@ -2522,16 +2522,17 @@ export class AgentManager extends EventEmitter {
2522
2522
  }
2523
2523
 
2524
2524
  /** One tool-less, read-only call to an engine; resolves to its text output. */
2525
- oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools }) {
2525
+ oneShot(agent, text, { engine, model, timeoutMs = 300_000, tools, cwd = paths.home }) {
2526
2526
  // Some engines take the prompt as an argument instead of on stdin, and some need their extra
2527
2527
  // arguments after a subcommand (oneShotExtra: they place them). `tools`: Claude Code only, a
2528
- // call that may use just these connector tools (and none of its own).
2528
+ // call that may use just these connector tools (and none of its own). `cwd`: where it runs, which
2529
+ // decides the project MCP servers it loads.
2529
2530
  const extra = engine.extraArgs(this.config);
2530
2531
  const args = tools
2531
2532
  ? [...extra, ...engine.connectorArgs(this.config, { model, tools })]
2532
2533
  : engine.oneShotExtra ? engine.oneShotArgs(this.config, { model, prompt: text, extra }) : [...extra, ...engine.oneShotArgs(this.config, { model, prompt: text })];
2533
2534
  return new Promise((resolve, reject) => {
2534
- const child = spawn(engine.bin(this.config), args, { cwd: paths.home, env: this.childEnv(agent), stdio: ['pipe', 'pipe', 'pipe'] });
2535
+ const child = spawn(engine.bin(this.config), args, { cwd, env: this.childEnv(agent), stdio: ['pipe', 'pipe', 'pipe'] });
2535
2536
  let out = '';
2536
2537
  let err = '';
2537
2538
  const timer = setTimeout(() => child.kill('SIGTERM'), timeoutMs);
package/src/mcp.js ADDED
@@ -0,0 +1,208 @@
1
+ // MCP servers and their tools as Claude Code sees them in a folder: user, project and local
2
+ // servers, claude.ai connectors and plugins' servers. Listed through Claude Code's own control
3
+ // protocol (no model call), and run in an agent's session, or once in its workspace with only
4
+ // that one tool allowed.
5
+ import os from 'node:os';
6
+ import { spawn } from 'node:child_process';
7
+ import { DEFAULT_ENGINE, ENGINES } from './engines/index.js';
8
+
9
+ export const LIST_TTL_MS = 5 * 60_000;
10
+ const RUN_TIMEOUT_MS = 5 * 60_000;
11
+
12
+ /** Claude Code's name for a tool: mcp__<server>__<tool>, other characters in the server name as "_". */
13
+ export const toolId = (server, tool) => `mcp__${String(server).replace(/[^\w-]/g, '_')}__${tool}`;
14
+
15
+ const SECRET = /key|token|secret|passw|auth|bearer|cookie|credential/i;
16
+
17
+ /** Where a server runs, without secrets: the command line (values of secret-looking flags hidden), or the URL without its query. */
18
+ export function targetOf(config = {}) {
19
+ if (config.url) {
20
+ try {
21
+ const u = new URL(config.url);
22
+ return `${u.origin}${u.pathname}`;
23
+ } catch {
24
+ return '';
25
+ }
26
+ }
27
+ if (!config.command) return '';
28
+ const args = (config.args ?? []).map(String);
29
+ const shown = args.map((a, i) => {
30
+ const flag = a.match(/^(--?[\w-]+)=/)?.[1];
31
+ if (flag) return SECRET.test(flag) ? `${flag}=•••` : a;
32
+ if (/^-/.test(args[i - 1] ?? '') && SECRET.test(args[i - 1])) return '•••';
33
+ return /^[\w-]{32,}$/.test(a) ? '•••' : a;
34
+ });
35
+ return [config.command, ...shown].join(' ');
36
+ }
37
+
38
+ /** One server for the UI: no env, headers or other config values. */
39
+ export function serverView(s) {
40
+ return {
41
+ name: String(s.name),
42
+ status: s.status ?? 'unknown',
43
+ scope: s.scope ?? null,
44
+ source: s.source ?? null,
45
+ transport: s.transport ?? s.config?.type ?? null,
46
+ target: targetOf(s.config),
47
+ version: s.serverInfo?.version ?? null,
48
+ error: s.error ? String(s.error).slice(0, 300) : null,
49
+ tools: (s.tools ?? []).map((t) => ({
50
+ name: String(t.name),
51
+ id: toolId(s.name, t.name),
52
+ title: t.annotations?.title ?? null,
53
+ readOnly: t.annotations?.readOnlyHint === true,
54
+ destructive: t.annotations?.destructiveHint === true,
55
+ })),
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Ask Claude Code in `cwd` for its MCP servers: start it in stream-json mode, initialize, and ask
61
+ * for their status until none is still connecting. No message is sent, so no model call is made.
62
+ */
63
+ export function mcpStatus({ bin, args = [], cwd, env, timeoutMs = 30_000 }) {
64
+ return new Promise((resolve, reject) => {
65
+ const child = spawn(bin, [...args, '-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose', '--no-session-persistence'], {
66
+ cwd,
67
+ env,
68
+ stdio: ['pipe', 'pipe', 'pipe'],
69
+ });
70
+ let buf = '';
71
+ let err = '';
72
+ let last = null;
73
+ let n = 0;
74
+ let done = false;
75
+ let poll = null;
76
+ const finish = (fn, value) => {
77
+ if (done) return;
78
+ done = true;
79
+ clearTimeout(timer);
80
+ clearTimeout(poll);
81
+ child.kill();
82
+ fn(value);
83
+ };
84
+ const send = (request) => child.stdin.write(`${JSON.stringify({ type: 'control_request', request_id: `r${++n}`, request })}\n`);
85
+ const timer = setTimeout(() => (last ? finish(resolve, last) : finish(reject, new Error('Claude Code did not list its MCP servers in time'))), timeoutMs);
86
+ child.stdout.on('data', (d) => {
87
+ buf += d;
88
+ const lines = buf.split('\n');
89
+ buf = lines.pop();
90
+ for (const line of lines) {
91
+ let m;
92
+ try {
93
+ m = JSON.parse(line);
94
+ } catch {
95
+ continue;
96
+ }
97
+ if (m.type !== 'control_response') continue;
98
+ const r = m.response ?? {};
99
+ if (r.subtype === 'error') return finish(reject, new Error(`Claude Code: ${r.error ?? 'error'}`));
100
+ if (r.request_id === 'r1') {
101
+ send({ subtype: 'mcp_status' });
102
+ continue;
103
+ }
104
+ const servers = r.response?.mcpServers;
105
+ if (!Array.isArray(servers)) continue;
106
+ last = servers;
107
+ if (servers.some((s) => s.status === 'pending')) poll = setTimeout(() => send({ subtype: 'mcp_status' }), 1000);
108
+ else finish(resolve, servers);
109
+ }
110
+ });
111
+ child.stderr.on('data', (d) => (err += d));
112
+ child.stdin.on('error', () => {});
113
+ child.on('error', (e) => finish(reject, e));
114
+ child.on('close', (code) => (last ? finish(resolve, last) : finish(reject, new Error(`Claude Code stopped before listing its MCP servers (exit ${code}): ${err.trim().slice(-300)}`))));
115
+ send({ subtype: 'initialize' });
116
+ });
117
+ }
118
+
119
+ /** The one-off call in a workspace: use the tool for the request, and report what it returned. */
120
+ export function runPrompt(id, input) {
121
+ return [
122
+ `Use the MCP tool ${id} for the request below, calling it as few times as needed (once if you can).`,
123
+ "Work out its arguments from the request and the tool's description.",
124
+ '',
125
+ `Request: ${input?.trim() || '(none: call it with no arguments, or the simplest valid ones)'}`,
126
+ '',
127
+ 'Then reply with what the tool returned, as it is (for long output, the part that answers the request),',
128
+ 'and one last line with the arguments you used. If the tool fails or is not available, say so and why.',
129
+ ].join('\n');
130
+ }
131
+
132
+ /** What an agent is told to run a tool in its session. */
133
+ export const sessionMessage = (id, input) => `Use the MCP tool ${id}${input?.trim() ? ` for this: ${input.trim()}` : ''}. Show me what it returned.`;
134
+
135
+ export class Mcp {
136
+ constructor({ manager, homeDir = os.homedir() }) {
137
+ this.manager = manager;
138
+ this.homeDir = homeDir;
139
+ this.cache = new Map(); // folder -> { at, servers } | { pending }
140
+ }
141
+
142
+ /** Where the tools run: an agent's folder, or the home folder (user servers and connectors). */
143
+ where(ref) {
144
+ if (!ref || ref === 'home') return { agent: null, dir: this.homeDir };
145
+ const agent = this.manager.mustGet(ref);
146
+ return { agent, dir: agent.workdir ?? agent.planning?.dir ?? this.homeDir };
147
+ }
148
+
149
+ async list(ref, { refresh = false } = {}) {
150
+ const { agent, dir } = this.where(ref);
151
+ let hit = this.cache.get(dir);
152
+ if (refresh || !hit || (hit.at && Date.now() - hit.at > LIST_TTL_MS) || hit.error) {
153
+ if (!hit?.pending) {
154
+ const engine = ENGINES[DEFAULT_ENGINE];
155
+ const pending = mcpStatus({ bin: engine.bin(this.manager.config), args: engine.extraArgs(this.manager.config), cwd: dir, env: this.manager.childEnv(agent) })
156
+ .then((servers) => ({ at: Date.now(), servers: servers.map(serverView).sort((a, b) => a.name.localeCompare(b.name)) }))
157
+ .catch((e) => ({ at: Date.now(), servers: [], error: e.message }));
158
+ hit = { pending };
159
+ this.cache.set(dir, hit);
160
+ pending.then((r) => this.cache.set(dir, r));
161
+ }
162
+ hit = await this.cache.get(dir).pending;
163
+ }
164
+ return {
165
+ agent: agent ? { id: agent.id, name: agent.name, engine: agent.engine ?? DEFAULT_ENGINE, running: Boolean(this.manager.runtimes.get(agent.id)?.pty) } : null,
166
+ dir,
167
+ at: new Date(hit.at).toISOString(),
168
+ servers: hit.servers,
169
+ error: hit.error ?? null,
170
+ };
171
+ }
172
+
173
+ /** The tool, checked against the last list for that folder. */
174
+ tool(dir, server, tool) {
175
+ const s = this.cache.get(dir)?.servers?.find((x) => x.name === server);
176
+ const t = s?.tools.find((x) => x.name === tool);
177
+ if (!t) throw Object.assign(new Error(`No tool "${tool}" on the MCP server "${server}" here; refresh the list`), { status: 404 });
178
+ if (s.status !== 'connected') throw Object.assign(new Error(`The MCP server "${server}" is ${s.status}`), { status: 409 });
179
+ return t;
180
+ }
181
+
182
+ /** Run a tool: "session" tells the agent to use it; "workspace" runs it once, apart from the session. */
183
+ async run(ref, { server, tool, input = '', where = 'workspace' } = {}) {
184
+ const { agent, dir } = this.where(ref);
185
+ if (!this.cache.get(dir)?.servers) await this.list(ref);
186
+ const t = this.tool(dir, String(server ?? ''), String(tool ?? ''));
187
+ input = String(input ?? '').slice(0, 8000);
188
+ if (where === 'session') {
189
+ if (!agent) throw Object.assign(new Error('Pick an agent to run it in its session'), { status: 400 });
190
+ if ((agent.engine ?? DEFAULT_ENGINE) !== DEFAULT_ENGINE) throw Object.assign(new Error('Running MCP tools in the session works for Claude Code agents'), { status: 409 });
191
+ return { where, tool: t.id, agent: this.manager.tell(agent.id, sessionMessage(t.id, input), { source: 'mcp' }) };
192
+ }
193
+ if (where !== 'workspace') throw Object.assign(new Error('where must be "session" or "workspace"'), { status: 400 });
194
+ const scope = { agent: agent ? this.manager.auditView(agent) : null, dir, tool: t.id, input };
195
+ this.manager.plugins.check('mcp.run', scope);
196
+ this.manager.plugins.emit('mcp.run', scope);
197
+ const engine = ENGINES[DEFAULT_ENGINE];
198
+ const t0 = Date.now();
199
+ const text = await this.manager.oneShot(agent, runPrompt(t.id, input), {
200
+ engine,
201
+ model: this.manager.config.explainModel,
202
+ tools: [t.id],
203
+ cwd: dir,
204
+ timeoutMs: RUN_TIMEOUT_MS,
205
+ });
206
+ return { where, tool: t.id, text, ms: Date.now() - t0, at: new Date().toISOString() };
207
+ }
208
+ }
package/src/server.js CHANGED
@@ -57,6 +57,7 @@ import { BugHunts } from './bughunt.js';
57
57
  import { ModuleBenchmarks } from './benchmarks.js';
58
58
  import { Evals, readTail, stateHash } from './eval.js';
59
59
  import { engineOf } from './engines/index.js';
60
+ import { Mcp } from './mcp.js';
60
61
  import * as git from './git.js';
61
62
 
62
63
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -181,6 +182,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
181
182
  const review = new Review({ manager });
182
183
  // The walkthrough explains the same diff the review screen shows.
183
184
  manager.changesSource = (id) => review.get(id);
185
+ const mcp = new Mcp({ manager });
184
186
  const studio = new Studio({ manager, review });
185
187
  const teams = new Teams({ manager, store, config });
186
188
  const cleanup = new Cleanup({ manager, store, config, teams });
@@ -955,6 +957,9 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
955
957
  // Your action on issues: assign (starts an agent from the proposal), skip, done, remove, or null to clear.
956
958
  api.post('/issues/action', wrap((req) => proposed.setAction(Array.isArray(req.body?.keys) ? req.body.keys.map(String) : [], req.body?.action ?? null, { until: req.body?.until ?? null })));
957
959
  // Design docs of all agents; the same ?group= and ?format=markdown.
960
+ // MCP servers and their tools as Claude Code sees them in an agent's folder (or the home folder), and running one.
961
+ api.get('/mcp', wrap((req) => mcp.list(req.query.agent, { refresh: req.query.refresh === '1' })));
962
+ api.post('/mcp/run', wrap((req) => mcp.run(req.body?.agent, req.body ?? {})));
958
963
  api.get('/designs', wrap((req) => {
959
964
  const v = manager.designs();
960
965
  const group = req.query.group ? String(req.query.group) : null;