@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.
@@ -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
- // Debug logging wrapper dedup řeší API server (Serializable transakce)
99
+ // Dedup cacheklíč 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
- const start = Date.now();
111
- try {
112
- const result = await originalHandler(params, extra);
113
- debugLog(name, (params ?? {}), result.isError ? "error" : "ok", Date.now() - start);
114
- return result;
115
- }
116
- catch (err) {
117
- debugLog(name, (params ?? {}), "error", Date.now() - start);
118
- throw err;
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-system/tickr-mcp",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "MCP server for Tickr project management — 56 tools + setup CLI wizard",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",