tiny-http-mcp-server 0.1.49 → 0.1.51

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.49",
21
+ "version": "0.1.51",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -187,7 +187,7 @@ export function createDefaultOAuthClientProvider(options) {
187
187
  if (forceRefresh && rejectedTokens !== undefined && (rejectedTokens === null || session?.tokens === undefined || !sameTokenGrant(session.tokens, rejectedTokens)))
188
188
  forceRefresh = false;
189
189
  const sessionDiscovery = resolveDiscovery(discovery, session);
190
- if ((options.client.mode === "static" || configuredClient?.registration !== undefined || initialGrant !== undefined) && session !== null && (session.tokens !== undefined || session.refreshState === "pending")) {
190
+ if ((options.client.mode === "static" || configuredClient !== null || initialGrant !== undefined) && session !== null && (session.tokens !== undefined || session.refreshState === "pending")) {
191
191
  const configured = configuredClient;
192
192
  if (configured === null || configured.clientId !== session.client.clientId || configured.clientSecret !== session.client.clientSecret)
193
193
  throw new Error("Stored session belongs to a different OAuth client; use separate persistence or explicitly reset it");
@@ -22,12 +22,18 @@ console.log(result.structuredContent);
22
22
  await client.close();
23
23
  ```
24
24
 
25
- `Tool` includes MCP `outputSchema` when a server advertises typed tool output. `CallToolResult` includes `structuredContent?: Record<string, unknown>` for typed results; legacy/content-block tools still use `content[]`.
25
+ `Tool` includes MCP `outputSchema` when a server advertises typed tool output.
26
+ `CallToolResult.structuredContent` preserves modern JSON values; legacy servers
27
+ require an object. Complete `content[]` blocks remain available in either case.
26
28
 
27
29
  Set `requestTimeoutMs` on `McpClient` or `timeoutMs` on individual requests.
28
30
  Numeric deadlines must be finite, nonnegative and no greater than
29
31
  2,147,483,647 ms; oversized values fail before a request is sent. Individual
30
32
  JSON-RPC requests also accept `timeoutMs: null` to disable their timer.
33
+ The deadline covers the complete request, including modern input callbacks and
34
+ continuation rounds. On expiry, callback signals abort and late input cannot
35
+ submit another round. Successful requests, cancellation and disposal clear the
36
+ timer; a timeout releases request capacity so later operations can proceed.
31
37
 
32
38
  ## Transports
33
39
 
@@ -5398,7 +5398,7 @@ function createDefaultOAuthClientProvider(options) {
5398
5398
  if (forceRefresh && rejectedTokens !== void 0 && (rejectedTokens === null || session?.tokens === void 0 || !sameTokenGrant(session.tokens, rejectedTokens)))
5399
5399
  forceRefresh = false;
5400
5400
  const sessionDiscovery = resolveDiscovery(discovery, session);
5401
- if ((options.client.mode === "static" || configuredClient?.registration !== void 0 || initialGrant !== void 0) && session !== null && (session.tokens !== void 0 || session.refreshState === "pending")) {
5401
+ if ((options.client.mode === "static" || configuredClient !== null || initialGrant !== void 0) && session !== null && (session.tokens !== void 0 || session.refreshState === "pending")) {
5402
5402
  const configured = configuredClient;
5403
5403
  if (configured === null || configured.clientId !== session.client.clientId || configured.clientSecret !== session.client.clientSecret)
5404
5404
  throw new Error("Stored session belongs to a different OAuth client; use separate persistence or explicitly reset it");
@@ -8481,6 +8481,7 @@ var JsonRpcMessageLayer = class {
8481
8481
  rejectAbort = reject;
8482
8482
  });
8483
8483
  const cancel = () => {
8484
+ clearTimeout(deadline);
8484
8485
  if (currentRequestId !== void 0) this.cancelRequest(currentRequestId, controller.signal.reason);
8485
8486
  rejectAbort(controller.signal.reason);
8486
8487
  };
@@ -8492,6 +8493,15 @@ var JsonRpcMessageLayer = class {
8492
8493
  currentRequestId = id;
8493
8494
  onRequestId?.(id);
8494
8495
  } };
8496
+ const deadline = timeoutMs === null ? void 0 : setTimeout(() => {
8497
+ let reason = new Error(`JSON-RPC request "${method}" timed out after ${timeoutMs}ms`);
8498
+ try {
8499
+ if (currentRequestId !== void 0) options.onTimeout?.(currentRequestId);
8500
+ } catch (error) {
8501
+ reason = error;
8502
+ }
8503
+ controller.abort(reason);
8504
+ }, timeoutMs);
8495
8505
  if (callerSignal?.aborted) forwardAbort();
8496
8506
  const work = (async () => {
8497
8507
  let retryParams = originalParams;
@@ -8564,6 +8574,7 @@ var JsonRpcMessageLayer = class {
8564
8574
  throw new McpError(ERROR_INTERNAL, "Unreachable MCP retry state");
8565
8575
  })();
8566
8576
  return Promise.race([work, aborted]).finally(() => {
8577
+ clearTimeout(deadline);
8567
8578
  callerSignal?.removeEventListener("abort", forwardAbort);
8568
8579
  controller.signal.removeEventListener("abort", cancel);
8569
8580
  this.exchangeControllers.delete(controller);
@@ -8575,8 +8586,6 @@ var JsonRpcMessageLayer = class {
8575
8586
  }
8576
8587
  const id = this.nextRequestId;
8577
8588
  this.nextRequestId += 1;
8578
- const timeoutMs = options.timeoutMs === null ? null : options.timeoutMs ?? this.requestTimeoutMs;
8579
- if (timeoutMs !== null) validateRequestTimer(timeoutMs, "timeoutMs");
8580
8589
  if (options.onRequestId !== void 0) {
8581
8590
  options.onRequestId(id);
8582
8591
  }
@@ -8599,16 +8608,10 @@ var JsonRpcMessageLayer = class {
8599
8608
  message.params = params;
8600
8609
  }
8601
8610
  return new Promise((resolve, reject) => {
8602
- const timeout = timeoutMs === null ? void 0 : setTimeout(() => {
8603
- this.pendingRequests.delete(id);
8604
- options.onTimeout?.(id);
8605
- reject(new Error(`JSON-RPC request "${method}" timed out after ${timeoutMs}ms`));
8606
- }, timeoutMs);
8607
- this.pendingRequests.set(id, { resolve, reject, timeout });
8611
+ this.pendingRequests.set(id, { resolve, reject });
8608
8612
  try {
8609
8613
  this.output.write(serializeJsonRpcMessage(message));
8610
8614
  } catch (error) {
8611
- clearTimeout(timeout);
8612
8615
  this.pendingRequests.delete(id);
8613
8616
  reject(error);
8614
8617
  }
@@ -8620,7 +8623,6 @@ var JsonRpcMessageLayer = class {
8620
8623
  return false;
8621
8624
  }
8622
8625
  this.pendingRequests.delete(requestId);
8623
- clearTimeout(pending.timeout);
8624
8626
  pending.reject(reason);
8625
8627
  return true;
8626
8628
  }
@@ -8631,7 +8633,6 @@ var JsonRpcMessageLayer = class {
8631
8633
  this.disposedError = reason;
8632
8634
  for (const controller of this.exchangeControllers) controller.abort(reason);
8633
8635
  for (const pending of this.pendingRequests.values()) {
8634
- clearTimeout(pending.timeout);
8635
8636
  pending.reject(reason);
8636
8637
  }
8637
8638
  this.pendingRequests.clear();
@@ -8769,7 +8770,6 @@ var JsonRpcMessageLayer = class {
8769
8770
  return;
8770
8771
  }
8771
8772
  this.pendingRequests.delete(parsed.message.id);
8772
- clearTimeout(pending.timeout);
8773
8773
  if ("result" in parsed.message) {
8774
8774
  pending.resolve(parsed.message.result);
8775
8775
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",