@tenonhq/dovetail-mcp 0.0.1 → 0.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/dist/server.js CHANGED
File without changes
@@ -5,6 +5,11 @@
5
5
  *
6
6
  * Fire-and-forget — handler latency must not depend on disk I/O, and a write
7
7
  * failure must never surface to the MCP client.
8
+ *
9
+ * Ring-buffered: file is trimmed to the most recent N entries (default 1000)
10
+ * every TRIM_CHECK_INTERVAL appends. Worst-case file size is
11
+ * MAX_ENTRIES + TRIM_CHECK_INTERVAL lines. Override the cap with
12
+ * SINC_MCP_TELEMETRY_MAX_ENTRIES; 0 or negative disables trimming.
8
13
  */
9
14
  export interface TelemetryEvent {
10
15
  ts: string;
package/dist/telemetry.js CHANGED
@@ -6,6 +6,11 @@
6
6
  *
7
7
  * Fire-and-forget — handler latency must not depend on disk I/O, and a write
8
8
  * failure must never surface to the MCP client.
9
+ *
10
+ * Ring-buffered: file is trimmed to the most recent N entries (default 1000)
11
+ * every TRIM_CHECK_INTERVAL appends. Worst-case file size is
12
+ * MAX_ENTRIES + TRIM_CHECK_INTERVAL lines. Override the cap with
13
+ * SINC_MCP_TELEMETRY_MAX_ENTRIES; 0 or negative disables trimming.
9
14
  */
10
15
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
16
  if (k2 === undefined) k2 = k;
@@ -51,8 +56,61 @@ const fs = __importStar(require("fs"));
51
56
  const os = __importStar(require("os"));
52
57
  const path = __importStar(require("path"));
53
58
  const redact_1 = require("./redact");
59
+ var DEFAULT_MAX_ENTRIES = 1000;
60
+ var TRIM_CHECK_INTERVAL = 50;
54
61
  var dirEnsured = false;
55
62
  var writeQueue = Promise.resolve();
63
+ var appendsSinceTrim = 0;
64
+ function getMaxEntries() {
65
+ var raw = process.env.SINC_MCP_TELEMETRY_MAX_ENTRIES;
66
+ if (raw === undefined || raw === "") {
67
+ return DEFAULT_MAX_ENTRIES;
68
+ }
69
+ var n = parseInt(raw, 10);
70
+ if (isNaN(n)) {
71
+ return DEFAULT_MAX_ENTRIES;
72
+ }
73
+ return n;
74
+ }
75
+ function getTrimInterval() {
76
+ var raw = process.env.SINC_MCP_TELEMETRY_TRIM_INTERVAL;
77
+ if (raw === undefined || raw === "") {
78
+ return TRIM_CHECK_INTERVAL;
79
+ }
80
+ var n = parseInt(raw, 10);
81
+ if (isNaN(n) || n < 1) {
82
+ return TRIM_CHECK_INTERVAL;
83
+ }
84
+ return n;
85
+ }
86
+ function maybeTrim(filePath) {
87
+ appendsSinceTrim++;
88
+ if (appendsSinceTrim < getTrimInterval()) {
89
+ return;
90
+ }
91
+ appendsSinceTrim = 0;
92
+ var max = getMaxEntries();
93
+ if (max <= 0) {
94
+ return;
95
+ }
96
+ try {
97
+ var content = fs.readFileSync(filePath, "utf8");
98
+ var lines = content.split("\n").filter(function (l) {
99
+ return l.length > 0;
100
+ });
101
+ if (lines.length <= max) {
102
+ return;
103
+ }
104
+ var trimmed = lines.slice(lines.length - max).join("\n") + "\n";
105
+ var tmp = filePath + ".tmp";
106
+ fs.writeFileSync(tmp, trimmed, { mode: 0o600 });
107
+ fs.renameSync(tmp, filePath);
108
+ }
109
+ catch {
110
+ // Best-effort: trimming is opportunistic. If it fails the file may grow
111
+ // by up to one TRIM_CHECK_INTERVAL beyond the cap before the next attempt.
112
+ }
113
+ }
56
114
  function getTelemetryPath() {
57
115
  if (process.env.SINC_MCP_TELEMETRY_PATH) {
58
116
  return process.env.SINC_MCP_TELEMETRY_PATH;
@@ -117,6 +175,7 @@ function recordEvent(event) {
117
175
  return;
118
176
  }
119
177
  fs.appendFile(filePath, line, function () {
178
+ maybeTrim(filePath);
120
179
  resolve();
121
180
  });
122
181
  });
@@ -155,6 +214,7 @@ async function withTelemetry(tool, args, fn) {
155
214
  function _resetForTests() {
156
215
  dirEnsured = false;
157
216
  writeQueue = Promise.resolve();
217
+ appendsSinceTrim = 0;
158
218
  }
159
219
  /**
160
220
  * Flush all pending writes. Test-only.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/dovetail-mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "MCP server exposing read-only ClickUp / Gmail / Calendar / ServiceNow tools backed by the Dovetail integration packages.",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {