mcp-ts-template 2.2.1 → 2.2.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 +38 -27
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<div align="center">
|
|
7
7
|
|
|
8
|
-
[](./CHANGELOG.md) [](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-06-18/changelog.mdx) [](https://modelcontextprotocol.io/) [](./LICENSE) [](https://github.com/cyanheads/mcp-ts-template/issues) [](https://www.typescriptlang.org/) [](https://bun.sh/) [](./coverage/lcov-report/)
|
|
9
9
|
|
|
10
10
|
</div>
|
|
11
11
|
|
package/dist/index.js
CHANGED
|
@@ -117330,7 +117330,7 @@ var package_default = {
|
|
|
117330
117330
|
inspector: "bunx mcp-inspector --config mcp.json --server mcp-ts-template",
|
|
117331
117331
|
"db:duckdb-example": "MCP_LOG_LEVEL=debug tsc && node dist/storage/duckdbExample.js",
|
|
117332
117332
|
test: "bun test --config vitest.config.ts",
|
|
117333
|
-
"test:coverage": "bun test --coverage
|
|
117333
|
+
"test:coverage": "bun test --coverage",
|
|
117334
117334
|
audit: "bun audit",
|
|
117335
117335
|
"audit:fix": "bun audit --fix",
|
|
117336
117336
|
"publish-mcp": "bun scripts/validate-mcp-publish-schema.ts"
|
|
@@ -117776,7 +117776,7 @@ async function shutdownOpenTelemetry() {
|
|
|
117776
117776
|
// src/index.ts
|
|
117777
117777
|
var import_reflect_metadata2 = __toESM(require_Reflect(), 1);
|
|
117778
117778
|
|
|
117779
|
-
// src/utils/internal/errorHandler.ts
|
|
117779
|
+
// src/utils/internal/error-handler/errorHandler.ts
|
|
117780
117780
|
var import_api3 = __toESM(require_src(), 1);
|
|
117781
117781
|
|
|
117782
117782
|
// src/utils/internal/logger.ts
|
|
@@ -118464,7 +118464,7 @@ class Logger {
|
|
|
118464
118464
|
}
|
|
118465
118465
|
var logger = Logger.getInstance();
|
|
118466
118466
|
|
|
118467
|
-
// src/utils/internal/
|
|
118467
|
+
// src/utils/internal/error-handler/mappings.ts
|
|
118468
118468
|
var ERROR_TYPE_MAPPINGS = {
|
|
118469
118469
|
SyntaxError: -32007 /* ValidationError */,
|
|
118470
118470
|
TypeError: -32007 /* ValidationError */,
|
|
@@ -118516,6 +118516,8 @@ var COMMON_ERROR_PATTERNS = [
|
|
|
118516
118516
|
errorCode: -32007 /* ValidationError */
|
|
118517
118517
|
}
|
|
118518
118518
|
];
|
|
118519
|
+
|
|
118520
|
+
// src/utils/internal/error-handler/helpers.ts
|
|
118519
118521
|
function createSafeRegex(pattern) {
|
|
118520
118522
|
if (pattern instanceof RegExp) {
|
|
118521
118523
|
let flags = pattern.flags.replace("g", "");
|
|
@@ -118542,23 +118544,23 @@ function getErrorName(error) {
|
|
|
118542
118544
|
return `${typeof error}Encountered`;
|
|
118543
118545
|
}
|
|
118544
118546
|
function getErrorMessage(error) {
|
|
118545
|
-
if (error instanceof Error) {
|
|
118546
|
-
if ("errors" in error && Array.isArray(error.errors)) {
|
|
118547
|
-
const inner = error.errors.map((e) => e instanceof Error ? e.message : String(e)).filter(Boolean).slice(0, 3).join("; ");
|
|
118548
|
-
return inner ? `${error.message}: ${inner}` : error.message;
|
|
118549
|
-
}
|
|
118550
|
-
return error.message;
|
|
118551
|
-
}
|
|
118552
|
-
if (error === null) {
|
|
118553
|
-
return "Null value encountered as error";
|
|
118554
|
-
}
|
|
118555
|
-
if (error === undefined) {
|
|
118556
|
-
return "Undefined value encountered as error";
|
|
118557
|
-
}
|
|
118558
|
-
if (typeof error === "string") {
|
|
118559
|
-
return error;
|
|
118560
|
-
}
|
|
118561
118547
|
try {
|
|
118548
|
+
if (error instanceof Error) {
|
|
118549
|
+
if ("errors" in error && Array.isArray(error.errors)) {
|
|
118550
|
+
const inner = error.errors.map((e) => e instanceof Error ? e.message : String(e)).filter(Boolean).slice(0, 3).join("; ");
|
|
118551
|
+
return inner ? `${error.message}: ${inner}` : error.message;
|
|
118552
|
+
}
|
|
118553
|
+
return error.message;
|
|
118554
|
+
}
|
|
118555
|
+
if (error === null) {
|
|
118556
|
+
return "Null value encountered as error";
|
|
118557
|
+
}
|
|
118558
|
+
if (error === undefined) {
|
|
118559
|
+
return "Undefined value encountered as error";
|
|
118560
|
+
}
|
|
118561
|
+
if (typeof error === "string") {
|
|
118562
|
+
return error;
|
|
118563
|
+
}
|
|
118562
118564
|
if (typeof error === "number" || typeof error === "boolean") {
|
|
118563
118565
|
return String(error);
|
|
118564
118566
|
}
|
|
@@ -118581,11 +118583,12 @@ function getErrorMessage(error) {
|
|
|
118581
118583
|
return error.toString();
|
|
118582
118584
|
}
|
|
118583
118585
|
return "[unrepresentable error]";
|
|
118584
|
-
} catch (
|
|
118585
|
-
return `Error converting error to string: ${
|
|
118586
|
+
} catch (conversionError) {
|
|
118587
|
+
return `Error converting error to string: ${conversionError instanceof Error ? conversionError.message : "Unknown conversion error"}`;
|
|
118586
118588
|
}
|
|
118587
118589
|
}
|
|
118588
118590
|
|
|
118591
|
+
// src/utils/internal/error-handler/errorHandler.ts
|
|
118589
118592
|
class ErrorHandler {
|
|
118590
118593
|
static determineErrorCode(error) {
|
|
118591
118594
|
if (error instanceof McpError) {
|
|
@@ -118733,12 +118736,14 @@ class ErrorHandler {
|
|
|
118733
118736
|
static async tryCatch(fn, options) {
|
|
118734
118737
|
try {
|
|
118735
118738
|
return await Promise.resolve(fn());
|
|
118736
|
-
} catch (
|
|
118737
|
-
throw ErrorHandler.handleError(
|
|
118739
|
+
} catch (caughtError) {
|
|
118740
|
+
throw ErrorHandler.handleError(caughtError, {
|
|
118741
|
+
...options,
|
|
118742
|
+
rethrow: true
|
|
118743
|
+
});
|
|
118738
118744
|
}
|
|
118739
118745
|
}
|
|
118740
118746
|
}
|
|
118741
|
-
|
|
118742
118747
|
// src/utils/internal/runtime.ts
|
|
118743
118748
|
var safeHas = (key) => {
|
|
118744
118749
|
try {
|
|
@@ -118784,15 +118789,20 @@ var ATTR_MCP_TOOL_MEMORY_HEAP_USED_DELTA = "mcp.tool.memory_heap_used_bytes.delt
|
|
|
118784
118789
|
|
|
118785
118790
|
// src/utils/internal/performance.ts
|
|
118786
118791
|
var performanceNow = () => Date.now();
|
|
118792
|
+
async function loadPerfHooks() {
|
|
118793
|
+
return import("perf_hooks");
|
|
118794
|
+
}
|
|
118787
118795
|
async function initializePerformance_Hrt() {
|
|
118788
118796
|
const globalWithPerf = globalThis;
|
|
118789
118797
|
if (typeof globalWithPerf.performance?.now === "function") {
|
|
118790
|
-
|
|
118798
|
+
const perf = globalWithPerf.performance;
|
|
118799
|
+
performanceNow = () => perf?.now() ?? Date.now();
|
|
118791
118800
|
} else {
|
|
118792
118801
|
try {
|
|
118793
|
-
const { performance: nodePerformance } = await
|
|
118802
|
+
const { performance: nodePerformance } = await loadPerfHooks();
|
|
118794
118803
|
performanceNow = () => nodePerformance.now();
|
|
118795
118804
|
} catch (_e) {
|
|
118805
|
+
performanceNow = () => Date.now();
|
|
118796
118806
|
logger.warning("Could not import perf_hooks, falling back to Date.now() for performance timing.");
|
|
118797
118807
|
}
|
|
118798
118808
|
}
|
|
@@ -118804,7 +118814,8 @@ var toBytes = (payload) => {
|
|
|
118804
118814
|
try {
|
|
118805
118815
|
const json = JSON.stringify(payload);
|
|
118806
118816
|
if (typeof Buffer !== "undefined" && typeof Buffer.byteLength === "function") {
|
|
118807
|
-
|
|
118817
|
+
const bytes = Buffer.byteLength(json, "utf8");
|
|
118818
|
+
return bytes;
|
|
118808
118819
|
}
|
|
118809
118820
|
if (typeof TextEncoder !== "undefined") {
|
|
118810
118821
|
return new TextEncoder().encode(json).length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ts-template",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"mcpName": "io.github.cyanheads/mcp-ts-template",
|
|
5
5
|
"description": "The definitive, production-grade template for building powerful and scalable Model Context Protocol (MCP) servers with TypeScript, featuring built-in observability (OpenTelemetry), declarative tooling, robust error handling, and a modular, DI-driven architecture.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"inspector": "bunx mcp-inspector --config mcp.json --server mcp-ts-template",
|
|
57
57
|
"db:duckdb-example": "MCP_LOG_LEVEL=debug tsc && node dist/storage/duckdbExample.js",
|
|
58
58
|
"test": "bun test --config vitest.config.ts",
|
|
59
|
-
"test:coverage": "bun test --coverage
|
|
59
|
+
"test:coverage": "bun test --coverage",
|
|
60
60
|
"audit": "bun audit",
|
|
61
61
|
"audit:fix": "bun audit --fix",
|
|
62
62
|
"publish-mcp": "bun scripts/validate-mcp-publish-schema.ts"
|