tiny-http-mcp-server 0.1.65 → 0.1.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.65",
21
+ "version": "0.1.66",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -101,7 +101,7 @@ const transport = new HttpTransport({
101
101
  });
102
102
  ```
103
103
 
104
- You can also call `discoverOAuthMetadata(resourceUrl, options)` directly, or instantiate `OAuthMetadataDiscovery` with a custom `fetch` implementation and shared cache. Lookup options accept `signal`; cancellation stops metadata fetches and body reads without trying another discovery candidate.
104
+ You can also call `discoverOAuthMetadata(resourceUrl, options)` directly, or instantiate `OAuthMetadataDiscovery` with a custom `fetch` implementation and shared cache. Lookup options accept `signal`; cancellation stops metadata fetches and body reads without trying another discovery candidate. It also settles while shared-cache reads, writes or eviction wait. Host cache work may finish afterward; its late rejection remains observed, and canceled discovery does not start another candidate.
105
105
 
106
106
  OAuth provider inputs receive the originating request's `signal`, covering header authorization and unauthorized handling. Modern request cancellation stops its OAuth work while leaving other requests usable; transport disposal cancels all pending OAuth operations. The default provider propagates this signal to callback, registration and token work. Custom providers must observe it for their own operations.
107
107
 
@@ -6423,6 +6423,20 @@ function validateCachedDiscovery(value, resource) {
6423
6423
  authorizationServerMetadata
6424
6424
  });
6425
6425
  }
6426
+ async function waitForCache(operation, signal) {
6427
+ if (signal === void 0) return operation;
6428
+ let abort;
6429
+ try {
6430
+ return await new Promise((resolve, reject) => {
6431
+ abort = () => reject(signal.reason);
6432
+ signal.addEventListener("abort", abort, { once: true });
6433
+ Promise.resolve(operation).then(resolve, reject);
6434
+ if (signal.aborted) abort();
6435
+ });
6436
+ } finally {
6437
+ signal.removeEventListener("abort", abort);
6438
+ }
6439
+ }
6426
6440
  var OAuthMetadataDiscovery = class {
6427
6441
  fetchImpl;
6428
6442
  cache;
@@ -6459,7 +6473,7 @@ var OAuthMetadataDiscovery = class {
6459
6473
  if (memoryCachedResult !== void 0 && resourceMetadataUrl === void 0) {
6460
6474
  return structuredClone(memoryCachedResult);
6461
6475
  }
6462
- const sharedCachedResult = await this.cache?.get(cacheKey);
6476
+ const sharedCachedResult = await waitForCache(this.cache?.get(cacheKey), signal);
6463
6477
  signal?.throwIfAborted();
6464
6478
  if (sharedCachedResult !== null && sharedCachedResult !== void 0 && resourceMetadataUrl === void 0) {
6465
6479
  try {
@@ -6467,7 +6481,7 @@ var OAuthMetadataDiscovery = class {
6467
6481
  this.memoryCache.set(cacheKey, structuredClone(result));
6468
6482
  return result;
6469
6483
  } catch {
6470
- await this.cache?.delete?.(cacheKey);
6484
+ await waitForCache(this.cache?.delete?.(cacheKey), signal);
6471
6485
  }
6472
6486
  }
6473
6487
  const { location: resourceMetadataLocation, metadata: resourceMetadata } = await this.discoverProtectedResource(cacheKey, resourceMetadataUrl, signal);
@@ -6490,7 +6504,7 @@ var OAuthMetadataDiscovery = class {
6490
6504
  authorizationServerMetadata
6491
6505
  };
6492
6506
  this.memoryCache.set(cacheKey, structuredClone(result));
6493
- await this.cache?.set(cacheKey, structuredClone(result));
6507
+ await waitForCache(this.cache?.set(cacheKey, structuredClone(result)), signal);
6494
6508
  return result;
6495
6509
  } catch (error) {
6496
6510
  signal?.throwIfAborted();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.65",
3
+ "version": "0.1.66",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",