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.
- package/README.md +1 -1
- package/dist/index.js +42 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<div align="center">
|
|
9
9
|
|
|
10
|
-
[](./CHANGELOG.md) [](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-11-25/changelog.mdx) [](https://modelcontextprotocol.io/) [](./LICENSE)
|
|
11
11
|
|
|
12
12
|
[](https://github.com/cyanheads/mcp-ts-template/issues) [](https://www.typescriptlang.org/) [](https://bun.sh/) [](./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.
|
|
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.
|
|
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
|
|
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
|
-
|
|
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: "
|
|
152645
|
+
errorSource: "FetchAborted"
|
|
152628
152646
|
});
|
|
152629
|
-
throw new McpError(-
|
|
152647
|
+
throw new McpError(-32603 /* InternalError */, `${operationDescription} was aborted.`, {
|
|
152630
152648
|
requestId: context.requestId,
|
|
152631
152649
|
operation: context.operation,
|
|
152632
|
-
errorSource: "
|
|
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
|
-
|
|
178643
|
-
|
|
178644
|
-
|
|
178645
|
-
|
|
178646
|
-
|
|
178647
|
-
|
|
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.
|
|
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",
|