Skip to content

Commit c32e057

Browse files
Merge pull request #58 from modelcontextprotocol/justin/improve-abort
Add message to `abortAfterTimeout`, add missing request `options`
2 parents 106d1c2 + 7d50d8c commit c32e057

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/client/index.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ export class Client<
278278
}
279279
}
280280

281-
async ping() {
282-
return this.request({ method: "ping" }, EmptyResultSchema);
281+
async ping(options?: RequestOptions) {
282+
return this.request({ method: "ping" }, EmptyResultSchema, options);
283283
}
284284

285285
async complete(params: CompleteRequest["params"], options?: RequestOptions) {
@@ -290,10 +290,11 @@ export class Client<
290290
);
291291
}
292292

293-
async setLoggingLevel(level: LoggingLevel) {
293+
async setLoggingLevel(level: LoggingLevel, options?: RequestOptions) {
294294
return this.request(
295295
{ method: "logging/setLevel", params: { level } },
296296
EmptyResultSchema,
297+
options,
297298
);
298299
}
299300

@@ -352,17 +353,25 @@ export class Client<
352353
);
353354
}
354355

355-
async subscribeResource(params: SubscribeRequest["params"]) {
356+
async subscribeResource(
357+
params: SubscribeRequest["params"],
358+
options?: RequestOptions,
359+
) {
356360
return this.request(
357361
{ method: "resources/subscribe", params },
358362
EmptyResultSchema,
363+
options,
359364
);
360365
}
361366

362-
async unsubscribeResource(params: UnsubscribeRequest["params"]) {
367+
async unsubscribeResource(
368+
params: UnsubscribeRequest["params"],
369+
options?: RequestOptions,
370+
) {
363371
return this.request(
364372
{ method: "resources/unsubscribe", params },
365373
EmptyResultSchema,
374+
options,
366375
);
367376
}
368377

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
export function abortAfterTimeout(timeoutMs: number): AbortSignal {
55
const controller = new AbortController();
66
setTimeout(() => {
7-
controller.abort();
7+
controller.abort("Timeout exceeded");
88
}, timeoutMs);
99

1010
return controller.signal;

0 commit comments

Comments
 (0)