Skip to content

Commit 0efabac

Browse files
feat(mcp): support filtering tool results by a jq expression
1 parent 0ec3383 commit 0efabac

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/core.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ export abstract class APIClient {
299299
return null;
300300
}
301301

302-
buildRequest<Req>(
302+
async buildRequest<Req>(
303303
inputOptions: FinalRequestOptions<Req>,
304304
{ retryCount = 0 }: { retryCount?: number } = {},
305-
): { req: RequestInit; url: string; timeout: number } {
305+
): Promise<{ req: RequestInit; url: string; timeout: number }> {
306306
const options = { ...inputOptions };
307307
const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
308308

@@ -450,7 +450,9 @@ export abstract class APIClient {
450450

451451
await this.prepareOptions(options);
452452

453-
const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining });
453+
const { req, url, timeout } = await this.buildRequest(options, {
454+
retryCount: maxRetries - retriesRemaining,
455+
});
454456

455457
await this.prepareRequest(req, { url, options });
456458

tests/index.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ describe('instantiate client', () => {
2626
apiKey: 'My API Key',
2727
});
2828

29-
test('they are used in the request', () => {
30-
const { req } = client.buildRequest({ path: '/foo', method: 'post' });
29+
test('they are used in the request', async () => {
30+
const { req } = await client.buildRequest({ path: '/foo', method: 'post' });
3131
expect((req.headers as Headers)['x-my-default-header']).toEqual('2');
3232
});
3333

34-
test('can ignore `undefined` and leave the default', () => {
35-
const { req } = client.buildRequest({
34+
test('can ignore `undefined` and leave the default', async () => {
35+
const { req } = await client.buildRequest({
3636
path: '/foo',
3737
method: 'post',
3838
headers: { 'X-My-Default-Header': undefined },
3939
});
4040
expect((req.headers as Headers)['x-my-default-header']).toEqual('2');
4141
});
4242

43-
test('can be removed with `null`', () => {
44-
const { req } = client.buildRequest({
43+
test('can be removed with `null`', async () => {
44+
const { req } = await client.buildRequest({
4545
path: '/foo',
4646
method: 'post',
4747
headers: { 'X-My-Default-Header': null },
@@ -237,20 +237,20 @@ describe('request building', () => {
237237
const client = new Browserbase({ apiKey: 'My API Key' });
238238

239239
describe('Content-Length', () => {
240-
test('handles multi-byte characters', () => {
241-
const { req } = client.buildRequest({ path: '/foo', method: 'post', body: { value: '—' } });
240+
test('handles multi-byte characters', async () => {
241+
const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: '—' } });
242242
expect((req.headers as Record<string, string>)['content-length']).toEqual('20');
243243
});
244244

245-
test('handles standard characters', () => {
246-
const { req } = client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' } });
245+
test('handles standard characters', async () => {
246+
const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' } });
247247
expect((req.headers as Record<string, string>)['content-length']).toEqual('22');
248248
});
249249
});
250250

251251
describe('custom headers', () => {
252-
test('handles undefined', () => {
253-
const { req } = client.buildRequest({
252+
test('handles undefined', async () => {
253+
const { req } = await client.buildRequest({
254254
path: '/foo',
255255
method: 'post',
256256
body: { value: 'hello' },

0 commit comments

Comments
 (0)