@k-system/tickr-mcp 1.2.0 → 1.3.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/debug-logger.d.ts +1 -1
- package/dist/server.js +34 -12
- package/package.json +1 -1
package/dist/debug-logger.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare function isDebugEnabled(): boolean;
|
|
|
7
7
|
* Pokud debug není zapnutý, funkce je no-op.
|
|
8
8
|
* Pokud zápis selže, tiše ignoruje — debug log nesmí způsobit crash.
|
|
9
9
|
*/
|
|
10
|
-
export declare function debugLog(toolName: string, params: Record<string, unknown>, responseStatus: "ok" | "error", durationMs: number): void;
|
|
10
|
+
export declare function debugLog(toolName: string, params: Record<string, unknown>, responseStatus: "ok" | "error" | "dedup-hit", durationMs: number): void;
|
|
11
11
|
//# sourceMappingURL=debug-logger.d.ts.map
|
package/dist/server.js
CHANGED
|
@@ -96,27 +96,49 @@ export async function startServer() {
|
|
|
96
96
|
name: "tickr",
|
|
97
97
|
version: "0.1.5",
|
|
98
98
|
});
|
|
99
|
-
//
|
|
99
|
+
// Dedup cache — klíč je requestId z MCP SDK (JSON-RPC request ID)
|
|
100
|
+
// Druhý duplicitní call čeká na výsledek prvního místo opakovaného API volání
|
|
101
|
+
const pendingOps = new Map();
|
|
102
|
+
// Debug logging + dedup wrapper
|
|
100
103
|
{
|
|
101
104
|
const debug = isDebugEnabled();
|
|
102
105
|
const originalTool = server.tool.bind(server);
|
|
103
106
|
const wrappedTool = function (...args) {
|
|
104
|
-
if (!debug)
|
|
105
|
-
return originalTool.apply(server, args);
|
|
106
107
|
const handlerIndex = args.length - 1;
|
|
107
108
|
const name = args[0];
|
|
108
109
|
const originalHandler = args[handlerIndex];
|
|
109
110
|
args[handlerIndex] = async (params, extra) => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
// Dedup klíč: requestId z MCP SDK, fallback na tool name + params hash
|
|
112
|
+
const requestId = extra?.requestId?.toString() ??
|
|
113
|
+
name + ":" + JSON.stringify(params);
|
|
114
|
+
const cached = pendingOps.get(requestId);
|
|
115
|
+
if (cached) {
|
|
116
|
+
if (debug) {
|
|
117
|
+
debugLog(name, (params ?? {}), "dedup-hit", 0);
|
|
118
|
+
}
|
|
119
|
+
return cached;
|
|
119
120
|
}
|
|
121
|
+
const start = Date.now();
|
|
122
|
+
const promise = (async () => {
|
|
123
|
+
try {
|
|
124
|
+
const result = await originalHandler(params, extra);
|
|
125
|
+
if (debug) {
|
|
126
|
+
debugLog(name, (params ?? {}), result.isError ? "error" : "ok", Date.now() - start);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
if (debug) {
|
|
132
|
+
debugLog(name, (params ?? {}), "error", Date.now() - start);
|
|
133
|
+
}
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
})();
|
|
137
|
+
pendingOps.set(requestId, promise);
|
|
138
|
+
promise.finally(() => {
|
|
139
|
+
setTimeout(() => pendingOps.delete(requestId), 10_000);
|
|
140
|
+
});
|
|
141
|
+
return promise;
|
|
120
142
|
};
|
|
121
143
|
return originalTool.apply(server, args);
|
|
122
144
|
};
|