Skip to content

Commit 6f10afa

Browse files
committed
Merge branch 'v2/fix/4792-everything-conditional-tools' into v2/fix/5004-everything-wave1-rollup
2 parents 7dc2f3a + 88ae87f commit 6f10afa

6 files changed

Lines changed: 53 additions & 7 deletions

File tree

‎.changeset/everything-conditional-tools-4792.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@modelcontextprotocol/server-everything": patch
33
---
44

5-
Server instructions no longer tell every client to use tools that are registered only for clients declaring a capability; they list those tools and the capability each needs (#4792, ported from #4835). `trigger-elicitation-request` is now registered only for clients that support form-mode elicitation, so a client that declared only URL-mode elicitation no longer sees a tool it cannot answer (#4985).
5+
Server instructions no longer tell every client to use tools that are registered only for clients declaring a capability; they list those tools and the capability each needs (#4792, ported from #4835). `trigger-elicitation-request` and `trigger-elicitation-request-async` are now registered only for clients that support form-mode elicitation, so a client that declared only URL-mode elicitation no longer sees tools it cannot answer (#4985).

‎src/everything/__tests__/registrations.test.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,32 @@ describe("Registration Index Files", () => {
128128
// Should not register any capability-gated tools when capabilities are missing
129129
expect(mockServerNoCapabilities.registerTool).not.toHaveBeenCalled();
130130
});
131+
132+
it("should register no form-mode elicitation tool for a URL-only client, even with task support", () => {
133+
// Both elicitation tools send form-mode requests, which a client that
134+
// declared only `elicitation.url` cannot answer (#4985).
135+
const mockServerUrlOnly = {
136+
registerTool: vi.fn(),
137+
server: {
138+
getClientCapabilities: vi.fn(() => ({
139+
elicitation: { url: {} },
140+
tasks: { requests: { elicitation: { create: {} } } },
141+
})),
142+
},
143+
experimental: {
144+
tasks: {
145+
registerToolTask: vi.fn(),
146+
},
147+
},
148+
} as unknown as McpServer; // partial mock: McpServer's private members rule out a structural literal
149+
150+
registerConditionalTools(mockServerUrlOnly);
151+
152+
const registeredTools = vi
153+
.mocked(mockServerUrlOnly.registerTool)
154+
.mock.calls.map((call) => call[0]);
155+
expect(registeredTools).toEqual(["trigger-url-elicitation"]);
156+
});
131157
});
132158

133159
describe("prompts/index.ts", () => {
@@ -181,7 +207,7 @@ describe("Registration Index Files", () => {
181207
registerToolTask: vi.fn(),
182208
},
183209
},
184-
} as unknown as McpServer;
210+
} as unknown as McpServer; // partial mock: McpServer's private members rule out a structural literal
185211

186212
registerConditionalTools(mockServer);
187213

‎src/everything/__tests__/surface.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ describe("tools/list", () => {
146146
{ elicitation: {}, tasks: { requests: { elicitation: { create: {} } } } },
147147
["trigger-elicitation-request", "trigger-elicitation-request-async"],
148148
],
149+
[
150+
{
151+
elicitation: { form: {} },
152+
tasks: { requests: { elicitation: { create: {} } } },
153+
},
154+
["trigger-elicitation-request", "trigger-elicitation-request-async"],
155+
],
156+
// The async tool's request is form mode too, so a URL-only client does
157+
// not get it even with task support (#4985).
158+
[
159+
{
160+
elicitation: { url: {} },
161+
tasks: { requests: { elicitation: { create: {} } } },
162+
},
163+
["trigger-url-elicitation"],
164+
],
149165
// The async tools need the base capability as well as the task one.
150166
[{ tasks: { requests: { sampling: { createMessage: {} } } } }, []],
151167
[{ tasks: { requests: { elicitation: { create: {} } } } }, []],

‎src/everything/docs/features.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
- `trigger-sampling-request` (tools/trigger-sampling-request.ts): Issues a `sampling/createMessage` request to the client/LLM using provided `prompt` and optional generation controls; returns the LLM's response payload.
2828
- `simulate-research-query` (tools/simulate-research-query.ts): Demonstrates MCP Tasks (SEP-1686) with a simulated multi-stage research operation. Accepts `topic` and `ambiguous` parameters. Returns a task that progresses through stages with status updates. If `ambiguous` is true and client supports elicitation, sends an elicitation request directly to gather clarification before completing.
2929
- `trigger-sampling-request-async` (tools/trigger-sampling-request-async.ts): Demonstrates bidirectional tasks where the server sends a sampling request that the client executes as a background task. Server polls for status and retrieves the LLM result when complete. Requires client to support `tasks.requests.sampling.createMessage`.
30-
- `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts): Demonstrates bidirectional tasks where the server sends an elicitation request that the client executes as a background task. Server polls while waiting for user input. Requires client to support `tasks.requests.elicitation.create`.
30+
- `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts): Demonstrates bidirectional tasks where the server sends an elicitation request that the client executes as a background task. Server polls while waiting for user input. Requires client form-mode elicitation (as for `trigger-elicitation-request`) and `tasks.requests.elicitation.create`.
3131

3232
## Prompts
3333

@@ -85,7 +85,7 @@ The server advertises support for MCP Tasks, enabling long-running operations wi
8585
Use the `simulate-research-query` tool to exercise the full task lifecycle. Set `ambiguous: true` to trigger elicitation - the server will send an `elicitation/create` request directly and await the response before completing.
8686

8787
**Client-side tasks (server calls client):**
88-
Use `trigger-sampling-request-async` or `trigger-elicitation-request-async` to demonstrate bidirectional tasks where the server sends requests that the client executes as background tasks. These require the client to advertise `tasks.requests.sampling.createMessage` or `tasks.requests.elicitation.create` capabilities respectively.
88+
Use `trigger-sampling-request-async` or `trigger-elicitation-request-async` to demonstrate bidirectional tasks where the server sends requests that the client executes as background tasks. These require the client to advertise `sampling` with `tasks.requests.sampling.createMessage`, or form-mode `elicitation` with `tasks.requests.elicitation.create`, respectively.
8989

9090
### Bidirectional Task Flow
9191

‎src/everything/docs/instructions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Registered only if your client declared the capability shown. Otherwise they are
2424
- `trigger-elicitation-request`: `elicitation.form`, or `elicitation` with no mode
2525
- `trigger-url-elicitation`: `elicitation.url`
2626
- `trigger-sampling-request-async`: `sampling` and `tasks.requests.sampling.createMessage`
27-
- `trigger-elicitation-request-async`: `elicitation` and `tasks.requests.elicitation.create`
27+
- `trigger-elicitation-request-async`: form-mode `elicitation` and `tasks.requests.elicitation.create`
2828

2929
## Operational Patterns
3030

‎src/everything/tools/trigger-elicitation-request-async.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ export const registerTriggerElicitationRequestAsyncTool = (
4747
// Check client capabilities
4848
const clientCapabilities = server.server.getClientCapabilities() || {};
4949

50-
// Client must support elicitation AND tasks.requests.elicitation
50+
// Client must support form-mode elicitation AND tasks.requests.elicitation.
51+
// The request is form mode, so a URL-only client cannot answer it (#4985):
52+
// form mode is `elicitation.form`, or `elicitation` with neither mode.
53+
const elicitation = clientCapabilities.elicitation;
5154
const clientSupportsElicitation =
52-
clientCapabilities.elicitation !== undefined;
55+
elicitation !== undefined &&
56+
(elicitation.form !== undefined || elicitation.url === undefined);
5357
const clientTasksCapability = clientCapabilities.tasks as
5458
| {
5559
requests?: { elicitation?: { create?: object } };

0 commit comments

Comments
 (0)