Skip to content

Commit 8949723

Browse files
chore: lint/format fixes; update integration discoverRoundtrip for A11 discharge
The integration discoverRoundtrip test asserted the OLD A11-rider behavior (advertisement excludes listChanged); updated to assert the discharged behavior (a designed existing-test modification — the rider's own acceptance criterion, same mandate as discover.test.ts).
1 parent 0af5011 commit 8949723

5 files changed

Lines changed: 18 additions & 15 deletions

File tree

examples/client/src/subscriptionsListenClient.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ async function autoOpenLeg(): Promise<void> {
4444
}
4545
});
4646
await client.connect(new StreamableHTTPClientTransport(new globalThis.URL(URL)));
47-
console.log(`[client] (auto) connected (${client.getNegotiatedProtocolVersion()}); auto-opened filter:`, client.autoOpenedSubscription?.honoredFilter);
47+
console.log(
48+
`[client] (auto) connected (${client.getNegotiatedProtocolVersion()}); auto-opened filter:`,
49+
client.autoOpenedSubscription?.honoredFilter
50+
);
4851
await finished;
4952
await client.autoOpenedSubscription?.close();
5053
await client.close();

examples/server/src/subscriptionsListen.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ let extraToolEnabled = false;
2626
function buildServer(): McpServer {
2727
const server = new McpServer({ name: 'subscriptions-listen-example', version: '1.0.0' });
2828

29-
server.registerTool(
30-
'greet',
31-
{ description: 'Returns a greeting', inputSchema: z.object({ name: z.string() }) },
32-
async ({ name }) => ({ content: [{ type: 'text', text: `hello, ${name}` }] })
33-
);
29+
server.registerTool('greet', { description: 'Returns a greeting', inputSchema: z.object({ name: z.string() }) }, async ({ name }) => ({
30+
content: [{ type: 'text', text: `hello, ${name}` }]
31+
}));
3432
if (extraToolEnabled) {
3533
server.registerTool(
3634
'farewell',

packages/client/src/client/client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import {
6464
ListChangedOptionsBaseSchema,
6565
mergeCapabilities,
6666
parseSchema,
67-
PROTOCOL_VERSION_META_KEY,
6867
Protocol,
6968
PROTOCOL_VERSION_META_KEY,
7069
ProtocolError,
@@ -1217,7 +1216,7 @@ export class Client extends Protocol<ClientContext> {
12171216
}
12181217

12191218
const requestAbort = new AbortController();
1220-
const transportKind = this.transport !== undefined ? detectProbeTransportKind(this.transport) : 'http';
1219+
const transportKind = this.transport === undefined ? 'http' : detectProbeTransportKind(this.transport);
12211220

12221221
let closed = false;
12231222
let parked!: ReturnType<typeof this._parkRequest>;
@@ -1279,10 +1278,10 @@ export class Client extends Protocol<ClientContext> {
12791278
reject(error ?? new Error('subscriptions/listen failed'));
12801279
}
12811280
});
1282-
parked.sent.catch(err => {
1281+
parked.sent.catch(error => {
12831282
clearTimeout(timer);
12841283
void close();
1285-
reject(err instanceof Error ? err : new Error(String(err)));
1284+
reject(error instanceof Error ? error : new Error(String(error)));
12861285
});
12871286
});
12881287

packages/client/test/client/listen.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ describe('Client.listen()', () => {
110110
const client = new Client({ name: 'c', version: '1' }, { versionNegotiation: { mode: 'auto' } });
111111
await client.connect(clientTx);
112112
const sub = await client.listen({ toolsListChanged: true });
113-
const listenId = (
114-
written.find(m => (m as { method?: string }).method === 'subscriptions/listen') as { id: number | string }
115-
).id;
113+
const listenId = (written.find(m => (m as { method?: string }).method === 'subscriptions/listen') as { id: number | string }).id;
116114
written.length = 0;
117115
await sub.close();
118116
expect(written).toEqual([{ jsonrpc: '2.0', method: 'notifications/cancelled', params: { requestId: listenId } }]);
@@ -147,7 +145,12 @@ describe('Client.listen()', () => {
147145
void serverTx.send({
148146
jsonrpc: '2.0',
149147
id: req.id,
150-
result: { resultType: 'complete', supportedVersions: [MODERN], capabilities: {}, serverInfo: { name: 's', version: '1' } }
148+
result: {
149+
resultType: 'complete',
150+
supportedVersions: [MODERN],
151+
capabilities: {},
152+
serverInfo: { name: 's', version: '1' }
153+
}
151154
});
152155
}
153156
if (req.method === 'subscriptions/listen' && req.id !== undefined) {

test/e2e/scenarios/subscriptions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ verifies('typescript:subscriptions:listChanged-auto-open-modern', async () => {
108108
verifies('typescript:subscriptions:listen:legacy-era-steer', async ({ transport }: TestArgs) => {
109109
const client = new Client({ name: 'c', version: '0' });
110110
await using _ = await wire(transport, makeServer, client);
111-
const error = await client.listen({ toolsListChanged: true }).catch(e => e as SdkError);
111+
const error = await client.listen({ toolsListChanged: true }).catch(error_ => error_ as SdkError);
112112
expect(error).toBeInstanceOf(SdkError);
113113
expect((error as SdkError).code).toBe(SdkErrorCode.MethodNotSupportedByProtocolVersion);
114114
expect((error as SdkError).message).toContain('resources/subscribe');

0 commit comments

Comments
 (0)