🧷 fix: Tick Every Named Tool With the Whole-Server Item When Authorizing a Schedule (#18561)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Backend Unit Tests / backend (push) Blocked by required conditions
Channel Gateway / gateway (push) Waiting to run
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Frontend Unit Tests / frontend (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
Playwright E2E Tests / Codegraph select (push) Waiting to run
Playwright E2E Tests / Shard timings (push) Waiting to run
Playwright E2E Tests / e2e () (push) Blocked by required conditions
Playwright E2E Tests / MCP list_changed (replica count 1) (push) Blocked by required conditions
Playwright E2E Tests / MCP list_changed (replica count 2) (push) Blocked by required conditions
Playwright E2E Tests / MCP Apps (browser and server) (push) Waiting to run
Playwright E2E Tests / e2e (push) Blocked by required conditions
Playwright Shard Timings / Record shard timings (push) Waiting to run
Repository Safety / Confine repository symlinks (push) Waiting to run

The dialog lists a server's tools once, for all agents. With the
whole-server item ticked and a named tool left out, the agent that
selects the whole server could call that tool while an agent that names
it was refused, and the tool showed as unticked under copy that says
anything unticked is refused.

Ticking the whole-server item now ticks every named tool on the server
and locks those boxes; unticking it leaves them ticked for the owner to
choose from. The item sits above the tick-all box instead of under it,
and its label wraps at word boundaries on a narrow screen.
This commit is contained in:
Danny Avila 2026-11-19 17:34:35 -05:00 • committed by GitHub
parent bc0ddc6b14
commit f5784b4e8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 192 additions and 127 deletions

View file

@ -63,6 +63,16 @@ function unmarked(tool: string, marked: readonly string[], seen: readonly string
return marked.every((name) => seen.includes(name));
}
/**
* The whole server ticked is every tool on it ticked. One agent may select the server as a
* whole while another names a tool there, and the owner sees one list for the server: a named
* tool left out beside a ticked whole server would be allowed for the first agent and refused
* for the second, with nothing on screen to tell them apart.
*/
function spread(offered: readonly string[], ticked: string[]): string[] {
return ticked.includes(Constants.mcp_all) ? [...offered] : ticked;
}
/**
* The owner's starting point: what the stored grant already allows and is still on offer.
* A tool whose definition changed starts unticked, so allowing the new one is a decision.
@ -79,10 +89,13 @@ function initialChoice(data: ScheduleMCPConsentView): Record<string, string[]> {
const changed = data.changed[target.resource.serverName] ?? [];
return [
target.resource.serverName,
offered.filter(
(tool) =>
(allowed.includes(tool) || allowed.includes(Constants.mcp_all)) &&
unmarked(tool, changed),
spread(
offered,
offered.filter(
(tool) =>
(allowed.includes(tool) || allowed.includes(Constants.mcp_all)) &&
unmarked(tool, changed),
),
),
];
}),
@ -120,8 +133,11 @@ function currentChoice(
const seen = edited.revision === data.revision ? (edited.changed[serverName] ?? []) : [];
return [
serverName,
(edited.choice[serverName] ?? initial[serverName]).filter(
(tool) => offered.includes(tool) && unmarked(tool, marked, seen),
spread(
offered,
(edited.choice[serverName] ?? initial[serverName]).filter(
(tool) => offered.includes(tool) && unmarked(tool, marked, seen),
),
),
];
}),
@ -561,37 +577,82 @@ function ToolChoice({
const groupId = useId();
/**
* A selection of the whole server is one item of its own, listed first: every tool there,
* including ones the server gains later. It is not what ticking each named tool means, so
* the shared box below leaves it as the owner set it.
* including ones the server gains later. While it is ticked each named tool is ticked with
* it and cannot be unticked on its own; unticked, the named tools stay as they are.
*/
const every: string = Constants.mcp_all;
const named = offered.filter((tool) => tool !== every);
const items = [...offered.filter((tool) => tool === every), ...named];
const kept = chosen.filter((tool) => tool === every);
/** The whole-server item covers every changed tool there: they are named beside it. */
const warns = (tool: string): boolean =>
tool === every ? changed.length > 0 : changed.includes(tool);
const whole = offered.includes(every);
const covered = chosen.includes(every);
/**
* Questions the grant holds about tools whose own ask box is not showing: a tool with no row
* (reached only through the whole server), or one whose row is unticked. While the whole
* server is ticked they are still allowed and still asked about, so each gets a row under
* that item, where the owner can keep asking or stop.
* Questions the grant holds about tools that have no row here: reached only through the
* whole server. Each gets a row under that item while it is ticked, so the owner can keep
* asking or stop.
*/
const retained = chosen.includes(every)
? asking.filter((tool) => tool !== every && !(named.includes(tool) && chosen.includes(tool)))
: [];
const retained = covered ? asking.filter((tool) => tool !== every && !named.includes(tool)) : [];
/** Checked only when every tool is: the shared box has no partly-selected appearance. */
const all = named.length > 0 && named.every((tool) => chosen.includes(tool));
const everyId = `${groupId}-every`;
return (
<fieldset className="mt-2 space-y-1" disabled={disabled}>
{whole && (
<div>
<div className="flex items-start gap-2">
<Checkbox
id={everyId}
checked={covered}
disabled={disabled}
className="mt-0.5"
aria-labelledby={`${everyId}-label`}
aria-describedby={changed.length > 0 ? `${everyId}-changed` : undefined}
onCheckedChange={(checked) =>
onChange(
checked === true ? [...chosen, every] : chosen.filter((name) => name !== every),
)
}
/>
<Label id={`${everyId}-label`} htmlFor={everyId} className="text-xs wrap-anywhere">
{localize('com_ui_schedule_consent_server_every', { server: serverName })}
</Label>
</div>
{changed.length > 0 && (
<p id={`${everyId}-changed`} className="text-status-warning pl-6 text-xs wrap-anywhere">
{localize('com_ui_schedule_consent_server_changed', { tools: changed.join(', ') })}
</p>
)}
{retained.length > 0 && (
<ul className="space-y-1 pl-6">
{retained.map((asked) => (
<li key={asked} className="flex items-start gap-2">
<Checkbox
id={`${groupId}-${asked}-retained`}
checked
disabled={disabled}
className="mt-0.5"
aria-label={localize('com_ui_schedule_consent_ask_tool', { tool: asked })}
aria-describedby={askNoteId}
onCheckedChange={(checked) => {
if (checked !== true) onAskingChange(asking.filter((name) => name !== asked));
}}
/>
<Label htmlFor={`${groupId}-${asked}-retained`} className="text-xs wrap-anywhere">
{localize('com_ui_schedule_consent_ask_tool', { tool: asked })}
</Label>
</li>
))}
</ul>
)}
</div>
)}
{named.length > 0 && (
<div className="flex items-center gap-2">
<Checkbox
id={`${groupId}-all`}
checked={all}
disabled={disabled}
disabled={disabled || covered}
aria-label={localize('com_ui_schedule_consent_allow_server', { server: serverName })}
onCheckedChange={(checked) => onChange(checked === true ? [...kept, ...named] : kept)}
aria-describedby={covered ? `${everyId}-label` : undefined}
onCheckedChange={(checked) => onChange(checked === true ? named : [])}
/>
<Label htmlFor={`${groupId}-all`} className="text-xs">
{localize('com_ui_schedule_consent_allow_server', { server: serverName })}
@ -599,87 +660,70 @@ function ToolChoice({
</div>
)}
<ul className="space-y-1 pl-6">
{items.map((tool) => (
<li key={tool}>
<div className="flex items-center gap-2">
<Checkbox
id={`${groupId}-${tool}`}
checked={chosen.includes(tool)}
disabled={disabled}
aria-labelledby={`${groupId}-${tool}-label`}
aria-describedby={warns(tool) ? `${groupId}-${tool}-changed` : undefined}
onCheckedChange={(checked) =>
onChange(
checked === true
? offered.filter((name) => name === tool || chosen.includes(name))
: chosen.filter((name) => name !== tool),
)
}
/>
<Label
id={`${groupId}-${tool}-label`}
htmlFor={`${groupId}-${tool}`}
className="text-xs break-all"
>
{tool === every
? localize('com_ui_schedule_consent_server_every', { server: serverName })
: tool}
</Label>
{tool !== every && askable.includes(tool) && chosen.includes(tool) && (
<span className="ml-auto flex shrink-0 items-center gap-2">
<Checkbox
id={`${groupId}-${tool}-ask`}
checked={asking.includes(tool)}
disabled={disabled}
aria-label={localize('com_ui_schedule_consent_ask_tool', { tool })}
aria-describedby={askNoteId}
onCheckedChange={(checked) =>
onAskingChange(
checked === true
? [...asking, tool]
: asking.filter((name) => name !== tool),
)
}
/>
<Label htmlFor={`${groupId}-${tool}-ask`} variant="secondary" className="text-xs">
{localize('com_ui_schedule_consent_ask_first')}
</Label>
</span>
)}
</div>
{warns(tool) && (
<p id={`${groupId}-${tool}-changed`} className="text-status-warning pl-6 text-xs">
{tool === every
? localize('com_ui_schedule_consent_server_changed', {
tools: changed.join(', '),
})
: localize('com_ui_schedule_consent_tool_changed')}
</p>
)}
{tool === every && retained.length > 0 && (
<ul className="space-y-1 pl-6">
{retained.map((asked) => (
<li key={asked} className="flex items-center gap-2">
{named.map((tool) => {
const warned = changed.includes(tool);
const described = [
covered ? `${everyId}-label` : undefined,
warned ? `${groupId}-${tool}-changed` : undefined,
].filter(Boolean);
return (
<li key={tool}>
<div className="flex items-center gap-2">
<Checkbox
id={`${groupId}-${tool}`}
checked={chosen.includes(tool)}
disabled={disabled || covered}
aria-labelledby={`${groupId}-${tool}-label`}
aria-describedby={described.length > 0 ? described.join(' ') : undefined}
onCheckedChange={(checked) =>
onChange(
checked === true
? offered.filter((name) => name === tool || chosen.includes(name))
: chosen.filter((name) => name !== tool),
)
}
/>
<Label
id={`${groupId}-${tool}-label`}
htmlFor={`${groupId}-${tool}`}
className="text-xs break-all"
>
{tool}
</Label>
{askable.includes(tool) && chosen.includes(tool) && (
<span className="ml-auto flex shrink-0 items-center gap-2">
<Checkbox
id={`${groupId}-${asked}-retained`}
checked
id={`${groupId}-${tool}-ask`}
checked={asking.includes(tool)}
disabled={disabled}
aria-label={localize('com_ui_schedule_consent_ask_tool', { tool: asked })}
aria-label={localize('com_ui_schedule_consent_ask_tool', { tool })}
aria-describedby={askNoteId}
onCheckedChange={(checked) => {
if (checked !== true)
onAskingChange(asking.filter((name) => name !== asked));
}}
onCheckedChange={(checked) =>
onAskingChange(
checked === true
? [...asking, tool]
: asking.filter((name) => name !== tool),
)
}
/>
<Label htmlFor={`${groupId}-${asked}-retained`} className="text-xs break-all">
{localize('com_ui_schedule_consent_ask_tool', { tool: asked })}
<Label
htmlFor={`${groupId}-${tool}-ask`}
variant="secondary"
className="text-xs"
>
{localize('com_ui_schedule_consent_ask_first')}
</Label>
</li>
))}
</ul>
)}
</li>
))}
</span>
)}
</div>
{warned && (
<p id={`${groupId}-${tool}-changed`} className="text-status-warning pl-6 text-xs">
{localize('com_ui_schedule_consent_tool_changed')}
</p>
)}
</li>
);
})}
</ul>
</fieldset>
);

View file

@ -513,7 +513,7 @@ it('reads the tool and the server out of a key against the servers in use, not b
expect(splitToolKey('send_action_mail.example', ['notes'])).toBeUndefined();
});
it('offers a selection of a whole server as its own item, apart from ticking each tool', async () => {
it('offers a selection of a whole server as its own item, which ticks and locks each named tool', async () => {
const whole: ScheduleMCPConsentView = {
...view,
approval: true,
@ -530,29 +530,36 @@ it('offers a selection of a whole server as its own item, apart from ticking eac
const every = await screen.findByRole('checkbox', {
name: 'com_ui_schedule_consent_server_every',
});
const all = screen.getByRole('checkbox', { name: 'com_ui_schedule_consent_allow_server' });
const query = screen.getByRole('checkbox', { name: 'query' });
expect(every).not.toBeChecked();
expect(screen.queryByRole('checkbox', { name: 'sys__all__sys' })).not.toBeInTheDocument();
// Ticking every named tool is not allowing whatever the server gains later.
await userEvent.click(
screen.getByRole('checkbox', { name: 'com_ui_schedule_consent_allow_server' }),
);
expect(screen.getByRole('checkbox', { name: 'query' })).toBeChecked();
await userEvent.click(all);
expect(query).toBeChecked();
expect(every).not.toBeChecked();
await userEvent.click(all);
expect(query).not.toBeChecked();
// The whole server is every tool on it: the named ones are ticked with it, and stay so.
await userEvent.click(every);
// It names no tool, so there is nothing to be asked about for it.
expect(query).toBeChecked();
expect(query).toBeDisabled();
expect(all).toBeChecked();
expect(all).toBeDisabled();
// It names no tool, so there is nothing to be asked about for it: only `query` has a box.
expect(
screen.getAllByRole('checkbox', { name: 'com_ui_schedule_consent_ask_tool' }),
).toHaveLength(1);
// Unticking the named tools leaves it as the owner set it.
await userEvent.click(
screen.getByRole('checkbox', { name: 'com_ui_schedule_consent_allow_server' }),
);
expect(every).toBeChecked();
// Unticked, the named tools are the owner's to choose again, starting from ticked.
await userEvent.click(every);
expect(query).toBeChecked();
expect(query).toBeEnabled();
await userEvent.click(every);
await userEvent.click(screen.getByRole('button', { name: 'com_ui_schedule_consent_confirm' }));
await waitFor(() =>
expect(dataService.confirmScheduleMCPConsent).toHaveBeenCalledWith(
'schedule',
expect.objectContaining({ allow: { warehouse: ['sys__all__sys'] } }),
expect.objectContaining({ allow: { warehouse: ['query', 'sys__all__sys'] } }),
),
);
});
@ -685,32 +692,41 @@ describe('the whole-server item beside named tools', () => {
);
});
it('keeps a question in view when its tool is unticked and the whole server still covers it', async () => {
const data = stored(
{
allowed: { warehouse: ['query', 'sys__all__sys'] },
asking: { warehouse: ['query'] },
},
['query', 'sys__all__sys'],
);
it('allows a tool another agent names along with the whole server, not only for the agent that holds it', async () => {
// The root selects the whole server and the child names `query`. The grant on file holds
// the whole server alone, so the child is refused `query` while the root may call it.
const data: ScheduleMCPConsentView = {
...stored({ allowed: { warehouse: ['sys__all__sys'] }, asking: { warehouse: ['query'] } }, [
'sys__all__sys',
]),
targets: [
{
...view.targets[0],
permittedTools: [
{ agentId: 'root', tools: ['sys__all__sys'] },
{ agentId: 'child', tools: ['query'] },
],
},
],
};
jest.mocked(dataService.getScheduleMCPConsent).mockResolvedValue(data);
jest.mocked(dataService.confirmScheduleMCPConsent).mockResolvedValue(data);
display();
expect(await every()).toBeChecked();
// Ticked, `query` shows its own ask box. Unticked, the root still reaches it through the
// whole server and is still asked: the question moves under that item, it is not hidden.
const asks = () =>
screen.getAllByRole('checkbox', { name: 'com_ui_schedule_consent_ask_tool' });
expect(asks()).toHaveLength(1);
await userEvent.click(screen.getByRole('checkbox', { name: 'query' }));
expect(asks()).toHaveLength(1);
expect(asks()[0]).toBeChecked();
// One list for the server: with the whole of it ticked, no tool on it is shown left out.
const query = screen.getByRole('checkbox', { name: 'query' });
expect(query).toBeChecked();
expect(query).toBeDisabled();
// Its question shows once, on its own row.
const asks = screen.getAllByRole('checkbox', { name: 'com_ui_schedule_consent_ask_tool' });
expect(asks).toHaveLength(1);
expect(asks[0]).toBeChecked();
await userEvent.click(confirm());
await waitFor(() =>
expect(dataService.confirmScheduleMCPConsent).toHaveBeenCalledWith(
'schedule',
expect.objectContaining({
allow: { warehouse: ['sys__all__sys'] },
allow: { warehouse: ['query', 'sys__all__sys'] },
ask: { warehouse: ['query'] },
}),
),

View file

@ -155,6 +155,11 @@ refused once its definition changes. It names no tool, so it cannot be asked abo
call. A grant that names tools keeps meaning those tools when the agent later selects the
whole server.
The owner chooses per server, not per agent, and one agent may select the whole server while
another names a tool there. The dialog therefore sends each named tool along with the item
whenever the item is ticked, and shows them ticked and locked: otherwise a tool left out
beside a ticked whole server would be allowed for the first agent and refused for the second.
### Tools on a server the operator did not declare
A server with nothing under `mcpConsent.resources` has no recipient to hold a consent for: a