@paretools/shared 0.14.2 → 0.16.0
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/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
package/dist/server.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export interface CreateServerOptions {
|
|
|
21
21
|
* Creates an MCP server with the standard Pare boilerplate:
|
|
22
22
|
* instantiates McpServer, registers tools via callback, connects StdioServerTransport.
|
|
23
23
|
*
|
|
24
|
+
* Installs global error handlers so that uncaught exceptions and unhandled
|
|
25
|
+
* rejections are written to stderr before the process exits — making "Connection
|
|
26
|
+
* closed" failures diagnosable instead of silent.
|
|
27
|
+
*
|
|
24
28
|
* @returns The connected McpServer instance (for testing or advanced use).
|
|
25
29
|
*/
|
|
26
30
|
export declare function createServer(options: CreateServerOptions): Promise<McpServer>;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI9E,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC;CAC3E;AA0BD
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI9E,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC;CAC3E;AA0BD;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+BnF"}
|
package/dist/server.js
CHANGED
|
@@ -30,10 +30,18 @@ function applyStrictInputSchemas(server) {
|
|
|
30
30
|
* Creates an MCP server with the standard Pare boilerplate:
|
|
31
31
|
* instantiates McpServer, registers tools via callback, connects StdioServerTransport.
|
|
32
32
|
*
|
|
33
|
+
* Installs global error handlers so that uncaught exceptions and unhandled
|
|
34
|
+
* rejections are written to stderr before the process exits — making "Connection
|
|
35
|
+
* closed" failures diagnosable instead of silent.
|
|
36
|
+
*
|
|
33
37
|
* @returns The connected McpServer instance (for testing or advanced use).
|
|
34
38
|
*/
|
|
35
39
|
export async function createServer(options) {
|
|
36
40
|
const { name, version, instructions, registerTools } = options;
|
|
41
|
+
// Install global error handlers so startup/runtime crashes are visible on
|
|
42
|
+
// stderr instead of silently killing the process (which MCP clients report
|
|
43
|
+
// as "Connection closed" with no diagnostic info).
|
|
44
|
+
installGlobalErrorHandlers(name);
|
|
37
45
|
const server = new McpServer({ name, version }, { instructions });
|
|
38
46
|
applyStrictInputSchemas(server);
|
|
39
47
|
const lazy = isLazyEnabled();
|
|
@@ -53,4 +61,29 @@ export async function createServer(options) {
|
|
|
53
61
|
await server.connect(transport);
|
|
54
62
|
return server;
|
|
55
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Installs process-level error handlers that write to stderr before exiting.
|
|
66
|
+
*
|
|
67
|
+
* Without these, an uncaught exception or unhandled rejection during server
|
|
68
|
+
* startup (e.g., a broken import, a Zod schema conversion failure, or a
|
|
69
|
+
* missing dependency) causes a silent exit. MCP clients then report
|
|
70
|
+
* "Connection closed" with no useful diagnostic information.
|
|
71
|
+
*
|
|
72
|
+
* These handlers are installed once per process and are idempotent.
|
|
73
|
+
*/
|
|
74
|
+
let globalHandlersInstalled = false;
|
|
75
|
+
function installGlobalErrorHandlers(serverName) {
|
|
76
|
+
if (globalHandlersInstalled)
|
|
77
|
+
return;
|
|
78
|
+
globalHandlersInstalled = true;
|
|
79
|
+
process.on("uncaughtException", (err) => {
|
|
80
|
+
process.stderr.write(`[${serverName}] Fatal uncaught exception: ${err.stack ?? err.message}\n`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
});
|
|
83
|
+
process.on("unhandledRejection", (reason) => {
|
|
84
|
+
const msg = reason instanceof Error ? (reason.stack ?? reason.message) : String(reason);
|
|
85
|
+
process.stderr.write(`[${serverName}] Fatal unhandled rejection: ${msg}\n`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
56
89
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,SAAS,EACT,0BAA0B,EAC1B,QAAQ,EACR,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAwB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAA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,gCAAgC,GAAG,IAAI,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paretools/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Shared utilities for Pare MCP servers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^25.4.0",
|
|
48
48
|
"typescript": "^5.7.0",
|
|
49
|
-
"vitest": "^4.
|
|
49
|
+
"vitest": "^4.1.1",
|
|
50
50
|
"@paretools/tsconfig": "0.0.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|