mcp-ts-template 3.0.0 → 3.0.2

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +42 -27
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  <div align="center">
9
9
 
10
- [![Version](https://img.shields.io/badge/Version-3.0.0-blue.svg?style=flat-square)](./CHANGELOG.md) [![MCP Spec](https://img.shields.io/badge/MCP%20Spec-2025--11--25-8A2BE2.svg?style=flat-square)](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-11-25/changelog.mdx) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.27.1-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE)
10
+ [![Version](https://img.shields.io/badge/Version-3.0.2-blue.svg?style=flat-square)](./CHANGELOG.md) [![MCP Spec](https://img.shields.io/badge/MCP%20Spec-2025--11--25-8A2BE2.svg?style=flat-square)](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-11-25/changelog.mdx) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.27.1-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE)
11
11
 
12
12
  [![Status](https://img.shields.io/badge/Status-Stable-brightgreen.svg?style=flat-square)](https://github.com/cyanheads/mcp-ts-template/issues) [![TypeScript](https://img.shields.io/badge/TypeScript-^5.9.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.2-blueviolet.svg?style=flat-square)](https://bun.sh/) [![Code Coverage](https://img.shields.io/badge/Coverage-86.30%25-brightgreen.svg?style=flat-square)](./coverage/index.html)
13
13
 
package/dist/index.js CHANGED
@@ -144586,7 +144586,7 @@ config(en_default());
144586
144586
  // package.json
144587
144587
  var package_default = {
144588
144588
  name: "mcp-ts-template",
144589
- version: "3.0.0",
144589
+ version: "3.0.2",
144590
144590
  mcpName: "io.github.cyanheads/mcp-ts-template",
144591
144591
  description: "TypeScript template for MCP servers with declarative tools/resources, pluggable auth, multi-backend storage, OpenTelemetry observability, and Cloudflare Workers support.",
144592
144592
  main: "dist/index.js",
@@ -144889,7 +144889,12 @@ var ConfigSchema = exports_external.object({
144889
144889
  oauthJwksCooldownMs: exports_external.coerce.number().default(300000),
144890
144890
  oauthJwksTimeoutMs: exports_external.coerce.number().default(5000),
144891
144891
  mcpServerResourceIdentifier: exports_external.string().url().optional(),
144892
- devMcpAuthBypass: exports_external.coerce.boolean().default(false),
144892
+ devMcpAuthBypass: exports_external.preprocess((val) => {
144893
+ if (val === undefined || val === null || val === "")
144894
+ return false;
144895
+ const str = String(val).toLowerCase().trim();
144896
+ return str === "true" || str === "1";
144897
+ }, exports_external.boolean()).default(false),
144893
144898
  devMcpClientId: exports_external.string().optional(),
144894
144899
  devMcpScopes: exports_external.array(exports_external.string()).optional(),
144895
144900
  openrouterAppUrl: exports_external.string().default("http://localhost:3000"),
@@ -152566,7 +152571,8 @@ async function fetchWithTimeout(url2, timeoutMs, context, options) {
152566
152571
  fetchInit.redirect = "manual";
152567
152572
  }
152568
152573
  const controller = new AbortController;
152569
- const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
152574
+ const timeoutSentinel = "FETCH_TIMEOUT";
152575
+ const timeoutId = setTimeout(() => controller.abort(timeoutSentinel), timeoutMs);
152570
152576
  if (externalSignal) {
152571
152577
  if (externalSignal.aborted) {
152572
152578
  controller.abort(externalSignal.reason);
@@ -152622,14 +152628,26 @@ async function fetchWithTimeout(url2, timeoutMs, context, options) {
152622
152628
  }
152623
152629
  } catch (error49) {
152624
152630
  if (error49 instanceof Error && (error49.name === "TimeoutError" || error49.name === "AbortError")) {
152625
- logger.error(`${operationDescription} timed out after ${timeoutMs}ms.`, {
152631
+ const isTimeout = error49.name === "TimeoutError" || controller.signal.reason === timeoutSentinel;
152632
+ if (isTimeout) {
152633
+ logger.error(`${operationDescription} timed out after ${timeoutMs}ms.`, {
152634
+ ...context,
152635
+ errorSource: "FetchTimeout"
152636
+ });
152637
+ throw new McpError(-32004 /* Timeout */, `${operationDescription} timed out.`, {
152638
+ requestId: context.requestId,
152639
+ operation: context.operation,
152640
+ errorSource: "FetchTimeout"
152641
+ });
152642
+ }
152643
+ logger.info(`${operationDescription} aborted by caller.`, {
152626
152644
  ...context,
152627
- errorSource: "FetchTimeout"
152645
+ errorSource: "FetchAborted"
152628
152646
  });
152629
- throw new McpError(-32004 /* Timeout */, `${operationDescription} timed out.`, {
152647
+ throw new McpError(-32603 /* InternalError */, `${operationDescription} was aborted.`, {
152630
152648
  requestId: context.requestId,
152631
152649
  operation: context.operation,
152632
- errorSource: "FetchTimeout"
152650
+ errorSource: "FetchAborted"
152633
152651
  });
152634
152652
  }
152635
152653
  const errorMessage = error49 instanceof Error ? error49.message : String(error49);
@@ -178639,32 +178657,29 @@ function createHttpApp(serverFactory, parentContext) {
178639
178657
  const handleRpc = async () => {
178640
178658
  const server2 = await serverFactory();
178641
178659
  await server2.connect(transport);
178642
- try {
178643
- const response = await transport.handleRequest(c);
178644
- if (response && config2.mcpSessionMode === "stateful") {
178645
- response.headers.set("Mcp-Session-Id", sessionId);
178646
- logger.debug("Added Mcp-Session-Id header to response", {
178647
- ...transportContext,
178648
- sessionId
178649
- });
178650
- }
178651
- if (response) {
178652
- return response;
178653
- }
178654
- return c.body(null, 204);
178655
- } finally {
178656
- await server2.close().catch((closeErr) => {
178657
- logger.debug("Failed to close per-request server", {
178658
- ...transportContext,
178659
- sessionId,
178660
- error: closeErr instanceof Error ? closeErr.message : String(closeErr)
178661
- });
178660
+ const response = await transport.handleRequest(c);
178661
+ if (response && config2.mcpSessionMode === "stateful") {
178662
+ response.headers.set("Mcp-Session-Id", sessionId);
178663
+ logger.debug("Added Mcp-Session-Id header to response", {
178664
+ ...transportContext,
178665
+ sessionId
178662
178666
  });
178663
178667
  }
178668
+ if (response) {
178669
+ return response;
178670
+ }
178671
+ return c.body(null, 204);
178664
178672
  };
178665
178673
  try {
178666
178674
  return await handleRpc();
178667
178675
  } catch (err) {
178676
+ await transport.close?.().catch((closeErr) => {
178677
+ logger.debug("Failed to close transport after error", {
178678
+ ...transportContext,
178679
+ sessionId,
178680
+ error: closeErr instanceof Error ? closeErr.message : String(closeErr)
178681
+ });
178682
+ });
178668
178683
  throw err instanceof Error ? err : new Error(String(err));
178669
178684
  }
178670
178685
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ts-template",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "mcpName": "io.github.cyanheads/mcp-ts-template",
5
5
  "description": "TypeScript template for MCP servers with declarative tools/resources, pluggable auth, multi-backend storage, OpenTelemetry observability, and Cloudflare Workers support.",
6
6
  "main": "dist/index.js",