@regle/mcp-server 1.14.7-beta.1 → 1.14.7-beta.3
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/regle-mcp-server.js +487 -23
- package/package.json +4 -2
package/dist/regle-mcp-server.js
CHANGED
|
@@ -1,7 +1,378 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
5
|
import { z } from "zod";
|
|
6
|
+
import "posthog-node";
|
|
7
|
+
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
10
|
+
|
|
11
|
+
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
12
|
+
module.exports = {
|
|
13
|
+
"name": "dotenv",
|
|
14
|
+
"version": "17.2.3",
|
|
15
|
+
"description": "Loads environment variables from .env file",
|
|
16
|
+
"main": "lib/main.js",
|
|
17
|
+
"types": "lib/main.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./lib/main.d.ts",
|
|
21
|
+
"require": "./lib/main.js",
|
|
22
|
+
"default": "./lib/main.js"
|
|
23
|
+
},
|
|
24
|
+
"./config": "./config.js",
|
|
25
|
+
"./config.js": "./config.js",
|
|
26
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
27
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
28
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
29
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
34
|
+
"lint": "standard",
|
|
35
|
+
"pretest": "npm run lint && npm run dts-check",
|
|
36
|
+
"test": "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
37
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
38
|
+
"prerelease": "npm test",
|
|
39
|
+
"release": "standard-version"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git://github.com/motdotla/dotenv.git"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/motdotla/dotenv#readme",
|
|
46
|
+
"funding": "https://dotenvx.com",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"dotenv",
|
|
49
|
+
"env",
|
|
50
|
+
".env",
|
|
51
|
+
"environment",
|
|
52
|
+
"variables",
|
|
53
|
+
"config",
|
|
54
|
+
"settings"
|
|
55
|
+
],
|
|
56
|
+
"readmeFilename": "README.md",
|
|
57
|
+
"license": "BSD-2-Clause",
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^18.11.3",
|
|
60
|
+
"decache": "^4.6.2",
|
|
61
|
+
"sinon": "^14.0.1",
|
|
62
|
+
"standard": "^17.0.0",
|
|
63
|
+
"standard-version": "^9.5.0",
|
|
64
|
+
"tap": "^19.2.0",
|
|
65
|
+
"typescript": "^4.8.4"
|
|
66
|
+
},
|
|
67
|
+
"engines": { "node": ">=12" },
|
|
68
|
+
"browser": { "fs": false }
|
|
69
|
+
};
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
73
|
+
const fs = __require("fs");
|
|
74
|
+
const path = __require("path");
|
|
75
|
+
const os = __require("os");
|
|
76
|
+
const crypto = __require("crypto");
|
|
77
|
+
const version$1 = require_package().version;
|
|
78
|
+
const TIPS = [
|
|
79
|
+
"🔐 encrypt with Dotenvx: https://dotenvx.com",
|
|
80
|
+
"🔐 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
81
|
+
"🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
82
|
+
"📡 add observability to secrets: https://dotenvx.com/ops",
|
|
83
|
+
"👥 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
84
|
+
"🗂️ backup and recover secrets: https://dotenvx.com/ops",
|
|
85
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
86
|
+
"🔄 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
87
|
+
"🔑 add access controls to secrets: https://dotenvx.com/ops",
|
|
88
|
+
"🛠️ run anywhere with `dotenvx run -- yourcommand`",
|
|
89
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
90
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
91
|
+
"⚙️ override existing env vars with { override: true }",
|
|
92
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
93
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
94
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
95
|
+
];
|
|
96
|
+
function _getRandomTip() {
|
|
97
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
98
|
+
}
|
|
99
|
+
function parseBoolean(value) {
|
|
100
|
+
if (typeof value === "string") return ![
|
|
101
|
+
"false",
|
|
102
|
+
"0",
|
|
103
|
+
"no",
|
|
104
|
+
"off",
|
|
105
|
+
""
|
|
106
|
+
].includes(value.toLowerCase());
|
|
107
|
+
return Boolean(value);
|
|
108
|
+
}
|
|
109
|
+
function supportsAnsi() {
|
|
110
|
+
return process.stdout.isTTY;
|
|
111
|
+
}
|
|
112
|
+
function dim(text) {
|
|
113
|
+
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text;
|
|
114
|
+
}
|
|
115
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
116
|
+
function parse(src) {
|
|
117
|
+
const obj = {};
|
|
118
|
+
let lines = src.toString();
|
|
119
|
+
lines = lines.replace(/\r\n?/gm, "\n");
|
|
120
|
+
let match;
|
|
121
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
122
|
+
const key = match[1];
|
|
123
|
+
let value = match[2] || "";
|
|
124
|
+
value = value.trim();
|
|
125
|
+
const maybeQuote = value[0];
|
|
126
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
127
|
+
if (maybeQuote === "\"") {
|
|
128
|
+
value = value.replace(/\\n/g, "\n");
|
|
129
|
+
value = value.replace(/\\r/g, "\r");
|
|
130
|
+
}
|
|
131
|
+
obj[key] = value;
|
|
132
|
+
}
|
|
133
|
+
return obj;
|
|
134
|
+
}
|
|
135
|
+
function _parseVault(options$1) {
|
|
136
|
+
options$1 = options$1 || {};
|
|
137
|
+
const vaultPath = _vaultPath(options$1);
|
|
138
|
+
options$1.path = vaultPath;
|
|
139
|
+
const result = DotenvModule.configDotenv(options$1);
|
|
140
|
+
if (!result.parsed) {
|
|
141
|
+
const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
142
|
+
err.code = "MISSING_DATA";
|
|
143
|
+
throw err;
|
|
144
|
+
}
|
|
145
|
+
const keys = _dotenvKey(options$1).split(",");
|
|
146
|
+
const length = keys.length;
|
|
147
|
+
let decrypted;
|
|
148
|
+
for (let i = 0; i < length; i++) try {
|
|
149
|
+
const attrs = _instructions(result, keys[i].trim());
|
|
150
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
151
|
+
break;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (i + 1 >= length) throw error;
|
|
154
|
+
}
|
|
155
|
+
return DotenvModule.parse(decrypted);
|
|
156
|
+
}
|
|
157
|
+
function _warn(message) {
|
|
158
|
+
console.error(`[dotenv@${version$1}][WARN] ${message}`);
|
|
159
|
+
}
|
|
160
|
+
function _debug(message) {
|
|
161
|
+
console.log(`[dotenv@${version$1}][DEBUG] ${message}`);
|
|
162
|
+
}
|
|
163
|
+
function _log(message) {
|
|
164
|
+
console.log(`[dotenv@${version$1}] ${message}`);
|
|
165
|
+
}
|
|
166
|
+
function _dotenvKey(options$1) {
|
|
167
|
+
if (options$1 && options$1.DOTENV_KEY && options$1.DOTENV_KEY.length > 0) return options$1.DOTENV_KEY;
|
|
168
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
|
|
169
|
+
return "";
|
|
170
|
+
}
|
|
171
|
+
function _instructions(result, dotenvKey) {
|
|
172
|
+
let uri;
|
|
173
|
+
try {
|
|
174
|
+
uri = new URL(dotenvKey);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
177
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
178
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
const key = uri.password;
|
|
184
|
+
if (!key) {
|
|
185
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
186
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
187
|
+
throw err;
|
|
188
|
+
}
|
|
189
|
+
const environment = uri.searchParams.get("environment");
|
|
190
|
+
if (!environment) {
|
|
191
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
192
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
195
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
196
|
+
const ciphertext = result.parsed[environmentKey];
|
|
197
|
+
if (!ciphertext) {
|
|
198
|
+
const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
199
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
200
|
+
throw err;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
ciphertext,
|
|
204
|
+
key
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function _vaultPath(options$1) {
|
|
208
|
+
let possibleVaultPath = null;
|
|
209
|
+
if (options$1 && options$1.path && options$1.path.length > 0) if (Array.isArray(options$1.path)) {
|
|
210
|
+
for (const filepath of options$1.path) if (fs.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
211
|
+
} else possibleVaultPath = options$1.path.endsWith(".vault") ? options$1.path : `${options$1.path}.vault`;
|
|
212
|
+
else possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
213
|
+
if (fs.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
function _resolveHome(envPath) {
|
|
217
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
218
|
+
}
|
|
219
|
+
function _configVault(options$1) {
|
|
220
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options$1 && options$1.debug);
|
|
221
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options$1 && options$1.quiet);
|
|
222
|
+
if (debug || !quiet) _log("Loading env from encrypted .env.vault");
|
|
223
|
+
const parsed = DotenvModule._parseVault(options$1);
|
|
224
|
+
let processEnv = process.env;
|
|
225
|
+
if (options$1 && options$1.processEnv != null) processEnv = options$1.processEnv;
|
|
226
|
+
DotenvModule.populate(processEnv, parsed, options$1);
|
|
227
|
+
return { parsed };
|
|
228
|
+
}
|
|
229
|
+
function configDotenv(options$1) {
|
|
230
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
231
|
+
let encoding = "utf8";
|
|
232
|
+
let processEnv = process.env;
|
|
233
|
+
if (options$1 && options$1.processEnv != null) processEnv = options$1.processEnv;
|
|
234
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options$1 && options$1.debug);
|
|
235
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options$1 && options$1.quiet);
|
|
236
|
+
if (options$1 && options$1.encoding) encoding = options$1.encoding;
|
|
237
|
+
else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
|
|
238
|
+
let optionPaths = [dotenvPath];
|
|
239
|
+
if (options$1 && options$1.path) if (!Array.isArray(options$1.path)) optionPaths = [_resolveHome(options$1.path)];
|
|
240
|
+
else {
|
|
241
|
+
optionPaths = [];
|
|
242
|
+
for (const filepath of options$1.path) optionPaths.push(_resolveHome(filepath));
|
|
243
|
+
}
|
|
244
|
+
let lastError;
|
|
245
|
+
const parsedAll = {};
|
|
246
|
+
for (const path$1 of optionPaths) try {
|
|
247
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path$1, { encoding }));
|
|
248
|
+
DotenvModule.populate(parsedAll, parsed, options$1);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
if (debug) _debug(`Failed to load ${path$1} ${e.message}`);
|
|
251
|
+
lastError = e;
|
|
252
|
+
}
|
|
253
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options$1);
|
|
254
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
255
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
256
|
+
if (debug || !quiet) {
|
|
257
|
+
const keysCount = Object.keys(populated).length;
|
|
258
|
+
const shortPaths = [];
|
|
259
|
+
for (const filePath of optionPaths) try {
|
|
260
|
+
const relative = path.relative(process.cwd(), filePath);
|
|
261
|
+
shortPaths.push(relative);
|
|
262
|
+
} catch (e) {
|
|
263
|
+
if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
|
|
264
|
+
lastError = e;
|
|
265
|
+
}
|
|
266
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
267
|
+
}
|
|
268
|
+
if (lastError) return {
|
|
269
|
+
parsed: parsedAll,
|
|
270
|
+
error: lastError
|
|
271
|
+
};
|
|
272
|
+
else return { parsed: parsedAll };
|
|
273
|
+
}
|
|
274
|
+
function config(options$1) {
|
|
275
|
+
if (_dotenvKey(options$1).length === 0) return DotenvModule.configDotenv(options$1);
|
|
276
|
+
const vaultPath = _vaultPath(options$1);
|
|
277
|
+
if (!vaultPath) {
|
|
278
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
279
|
+
return DotenvModule.configDotenv(options$1);
|
|
280
|
+
}
|
|
281
|
+
return DotenvModule._configVault(options$1);
|
|
282
|
+
}
|
|
283
|
+
function decrypt(encrypted, keyStr) {
|
|
284
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
285
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
286
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
287
|
+
const authTag = ciphertext.subarray(-16);
|
|
288
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
289
|
+
try {
|
|
290
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
291
|
+
aesgcm.setAuthTag(authTag);
|
|
292
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
293
|
+
} catch (error) {
|
|
294
|
+
const isRange = error instanceof RangeError;
|
|
295
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
296
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
297
|
+
if (isRange || invalidKeyLength) {
|
|
298
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
299
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
300
|
+
throw err;
|
|
301
|
+
} else if (decryptionFailed) {
|
|
302
|
+
const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
303
|
+
err.code = "DECRYPTION_FAILED";
|
|
304
|
+
throw err;
|
|
305
|
+
} else throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function populate(processEnv, parsed, options$1 = {}) {
|
|
309
|
+
const debug = Boolean(options$1 && options$1.debug);
|
|
310
|
+
const override = Boolean(options$1 && options$1.override);
|
|
311
|
+
const populated = {};
|
|
312
|
+
if (typeof parsed !== "object") {
|
|
313
|
+
const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
314
|
+
err.code = "OBJECT_REQUIRED";
|
|
315
|
+
throw err;
|
|
316
|
+
}
|
|
317
|
+
for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
318
|
+
if (override === true) {
|
|
319
|
+
processEnv[key] = parsed[key];
|
|
320
|
+
populated[key] = parsed[key];
|
|
321
|
+
}
|
|
322
|
+
if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
|
|
323
|
+
else _debug(`"${key}" is already defined and was NOT overwritten`);
|
|
324
|
+
} else {
|
|
325
|
+
processEnv[key] = parsed[key];
|
|
326
|
+
populated[key] = parsed[key];
|
|
327
|
+
}
|
|
328
|
+
return populated;
|
|
329
|
+
}
|
|
330
|
+
const DotenvModule = {
|
|
331
|
+
configDotenv,
|
|
332
|
+
_configVault,
|
|
333
|
+
_parseVault,
|
|
334
|
+
config,
|
|
335
|
+
decrypt,
|
|
336
|
+
parse,
|
|
337
|
+
populate
|
|
338
|
+
};
|
|
339
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
340
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
341
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
342
|
+
module.exports.config = DotenvModule.config;
|
|
343
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
344
|
+
module.exports.parse = DotenvModule.parse;
|
|
345
|
+
module.exports.populate = DotenvModule.populate;
|
|
346
|
+
module.exports = DotenvModule;
|
|
347
|
+
}));
|
|
348
|
+
|
|
349
|
+
var require_env_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
350
|
+
const options = {};
|
|
351
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
352
|
+
if (process.env.DOTENV_CONFIG_PATH != null) options.path = process.env.DOTENV_CONFIG_PATH;
|
|
353
|
+
if (process.env.DOTENV_CONFIG_QUIET != null) options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
|
354
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
355
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
356
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
357
|
+
module.exports = options;
|
|
358
|
+
}));
|
|
359
|
+
|
|
360
|
+
var require_cli_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
361
|
+
const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
362
|
+
module.exports = function optionMatcher(args) {
|
|
363
|
+
const options$1 = args.reduce(function(acc, cur) {
|
|
364
|
+
const matches = cur.match(re);
|
|
365
|
+
if (matches) acc[matches[1]] = matches[2];
|
|
366
|
+
return acc;
|
|
367
|
+
}, {});
|
|
368
|
+
if (!("quiet" in options$1)) options$1.quiet = "true";
|
|
369
|
+
return options$1;
|
|
370
|
+
};
|
|
371
|
+
}));
|
|
372
|
+
|
|
373
|
+
(function() {
|
|
374
|
+
require_main().config(Object.assign({}, require_env_options(), require_cli_options()(process.argv)));
|
|
375
|
+
})();
|
|
5
376
|
|
|
6
377
|
var docs_data_default = {
|
|
7
378
|
docs: [
|
|
@@ -1663,7 +2034,15 @@ function searchApi(query) {
|
|
|
1663
2034
|
return results;
|
|
1664
2035
|
}
|
|
1665
2036
|
|
|
1666
|
-
var version = "1.14.7-beta.
|
|
2037
|
+
var version = "1.14.7-beta.3";
|
|
2038
|
+
|
|
2039
|
+
function trackServerConnected(params) {}
|
|
2040
|
+
function trackToolCall(params) {}
|
|
2041
|
+
function trackSearchQuery(params) {}
|
|
2042
|
+
function trackDocAccessed(params) {}
|
|
2043
|
+
function trackRuleLookup(params) {}
|
|
2044
|
+
function trackHelperLookup(params) {}
|
|
2045
|
+
async function shutdown() {}
|
|
1667
2046
|
|
|
1668
2047
|
function jsonResponse(data$1) {
|
|
1669
2048
|
return { content: [{
|
|
@@ -1687,7 +2066,38 @@ const server = new McpServer({
|
|
|
1687
2066
|
title: "Regle MCP Server",
|
|
1688
2067
|
websiteUrl: "https://reglejs.dev"
|
|
1689
2068
|
});
|
|
1690
|
-
|
|
2069
|
+
function getClientInfo() {
|
|
2070
|
+
const clientInfo = server.server.getClientVersion();
|
|
2071
|
+
return {
|
|
2072
|
+
clientName: clientInfo?.name,
|
|
2073
|
+
clientVersion: clientInfo?.version
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2076
|
+
function registerTrackedTool(name, config$1, handler) {
|
|
2077
|
+
server.registerTool(name, config$1, async (args) => {
|
|
2078
|
+
const clientInfo = getClientInfo();
|
|
2079
|
+
try {
|
|
2080
|
+
const result = await handler(args, clientInfo);
|
|
2081
|
+
const isError = "isError" in result && result.isError === true;
|
|
2082
|
+
/* @__PURE__ */ trackToolCall({
|
|
2083
|
+
toolName: name,
|
|
2084
|
+
success: !isError,
|
|
2085
|
+
...clientInfo,
|
|
2086
|
+
...isError && { errorMessage: JSON.stringify(result.content) }
|
|
2087
|
+
});
|
|
2088
|
+
return result;
|
|
2089
|
+
} catch (error) {
|
|
2090
|
+
/* @__PURE__ */ trackToolCall({
|
|
2091
|
+
toolName: name,
|
|
2092
|
+
success: false,
|
|
2093
|
+
...clientInfo,
|
|
2094
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
2095
|
+
});
|
|
2096
|
+
return Promise.reject(error);
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
registerTrackedTool("regle-list-documentation", {
|
|
1691
2101
|
title: "List all available Regle documentation pages",
|
|
1692
2102
|
inputSchema: z.object({ category: z.string().optional().describe("Filter by category (e.g., \"rules\", \"core-concepts\", \"introduction\")") })
|
|
1693
2103
|
}, async ({ category }) => {
|
|
@@ -1702,15 +2112,20 @@ server.registerTool("regle-list-documentation", {
|
|
|
1702
2112
|
}))
|
|
1703
2113
|
});
|
|
1704
2114
|
});
|
|
1705
|
-
|
|
2115
|
+
registerTrackedTool("regle-get-documentation", {
|
|
1706
2116
|
title: "Get the full content of a specific Regle documentation page",
|
|
1707
2117
|
inputSchema: z.object({ id: z.string().describe("The documentation page ID (e.g., \"core-concepts-rules-built-in-rules\")") })
|
|
1708
|
-
}, async ({ id }) => {
|
|
2118
|
+
}, async ({ id }, clientInfo) => {
|
|
1709
2119
|
const doc = getDocById(id);
|
|
1710
2120
|
if (!doc) return errorResponse("Documentation page not found", {
|
|
1711
2121
|
requestedId: id,
|
|
1712
2122
|
availableIds: docs.map((d) => d.id)
|
|
1713
2123
|
});
|
|
2124
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
2125
|
+
...clientInfo,
|
|
2126
|
+
docId: doc.id,
|
|
2127
|
+
docCategory: doc.category
|
|
2128
|
+
});
|
|
1714
2129
|
return jsonResponse({
|
|
1715
2130
|
id: doc.id,
|
|
1716
2131
|
title: doc.title,
|
|
@@ -1719,12 +2134,17 @@ server.registerTool("regle-get-documentation", {
|
|
|
1719
2134
|
content: doc.content
|
|
1720
2135
|
});
|
|
1721
2136
|
});
|
|
1722
|
-
|
|
2137
|
+
registerTrackedTool("regle-get-usage-guide", {
|
|
1723
2138
|
title: "Get a comprehensive guide on how to use the useRegle composable",
|
|
1724
2139
|
inputSchema: z.object({})
|
|
1725
|
-
}, async () => {
|
|
2140
|
+
}, async (_args, clientInfo) => {
|
|
1726
2141
|
const doc = getDocById("core-concepts-index");
|
|
1727
2142
|
if (!doc) return errorResponse("useRegle guide not found");
|
|
2143
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
2144
|
+
...clientInfo,
|
|
2145
|
+
docId: doc.id,
|
|
2146
|
+
docCategory: doc.category
|
|
2147
|
+
});
|
|
1728
2148
|
return jsonResponse({
|
|
1729
2149
|
id: doc.id,
|
|
1730
2150
|
title: doc.title,
|
|
@@ -1732,12 +2152,17 @@ server.registerTool("regle-get-usage-guide", {
|
|
|
1732
2152
|
content: doc.content
|
|
1733
2153
|
});
|
|
1734
2154
|
});
|
|
1735
|
-
|
|
2155
|
+
registerTrackedTool("regle-get-vuelidate-migration-guide", {
|
|
1736
2156
|
title: "Get a guide on how to migrate from Vuelidate to Regle",
|
|
1737
2157
|
inputSchema: z.object({})
|
|
1738
|
-
}, async () => {
|
|
2158
|
+
}, async (_args, clientInfo) => {
|
|
1739
2159
|
const doc = getDocById("introduction-migrate-from-vuelidate");
|
|
1740
2160
|
if (!doc) return errorResponse("Vuelidate migration guide not found");
|
|
2161
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
2162
|
+
...clientInfo,
|
|
2163
|
+
docId: doc.id,
|
|
2164
|
+
docCategory: doc.category
|
|
2165
|
+
});
|
|
1741
2166
|
return jsonResponse({
|
|
1742
2167
|
id: doc.id,
|
|
1743
2168
|
title: doc.title,
|
|
@@ -1746,14 +2171,20 @@ server.registerTool("regle-get-vuelidate-migration-guide", {
|
|
|
1746
2171
|
});
|
|
1747
2172
|
});
|
|
1748
2173
|
const categories = getCategories();
|
|
1749
|
-
|
|
2174
|
+
registerTrackedTool("regle-search-documentation", {
|
|
1750
2175
|
title: "Search Regle documentation for specific topics, rules, or concepts",
|
|
1751
2176
|
inputSchema: z.object({
|
|
1752
2177
|
query: z.string().describe("Search query (e.g., \"required\", \"async validation\", \"useRegle\")"),
|
|
1753
2178
|
limit: z.number().optional().default(5).describe("Maximum number of results to return")
|
|
1754
2179
|
})
|
|
1755
|
-
}, async ({ query, limit }) => {
|
|
2180
|
+
}, async ({ query, limit }, clientInfo) => {
|
|
1756
2181
|
const results = searchDocs(query).slice(0, limit);
|
|
2182
|
+
/* @__PURE__ */ trackSearchQuery({
|
|
2183
|
+
...clientInfo,
|
|
2184
|
+
query,
|
|
2185
|
+
resultCount: results.length,
|
|
2186
|
+
toolName: "regle-search-documentation"
|
|
2187
|
+
});
|
|
1757
2188
|
if (results.length === 0) return jsonResponse({
|
|
1758
2189
|
query,
|
|
1759
2190
|
resultCount: 0,
|
|
@@ -1772,10 +2203,10 @@ server.registerTool("regle-search-documentation", {
|
|
|
1772
2203
|
results: formattedResults
|
|
1773
2204
|
});
|
|
1774
2205
|
});
|
|
1775
|
-
|
|
2206
|
+
registerTrackedTool("regle-list-rules", {
|
|
1776
2207
|
title: "Get a quick reference of all built-in validation rules in Regle",
|
|
1777
2208
|
inputSchema: z.object({})
|
|
1778
|
-
}, async () => {
|
|
2209
|
+
}, async (_args, _clientInfo) => {
|
|
1779
2210
|
const rules = getRulesFromDocs();
|
|
1780
2211
|
if (rules.length === 0) return errorResponse("Built-in rules documentation not found");
|
|
1781
2212
|
return jsonResponse({
|
|
@@ -1799,11 +2230,16 @@ const { r$ } = useRegle(
|
|
|
1799
2230
|
fullDocId: "core-concepts-rules-built-in-rules"
|
|
1800
2231
|
});
|
|
1801
2232
|
});
|
|
1802
|
-
|
|
2233
|
+
registerTrackedTool("regle-get-rule-reference", {
|
|
1803
2234
|
title: "Get details about a specific built-in validation rule",
|
|
1804
2235
|
inputSchema: z.object({ name: z.string().describe("The rule name (e.g., \"required\", \"email\", \"minLength\")") })
|
|
1805
|
-
}, async ({ name }) => {
|
|
2236
|
+
}, async ({ name }, clientInfo) => {
|
|
1806
2237
|
const rule = getApiByName(name);
|
|
2238
|
+
/* @__PURE__ */ trackRuleLookup({
|
|
2239
|
+
...clientInfo,
|
|
2240
|
+
ruleName: name,
|
|
2241
|
+
found: !!rule
|
|
2242
|
+
});
|
|
1807
2243
|
if (!rule) {
|
|
1808
2244
|
const allRules = getRulesFromDocs();
|
|
1809
2245
|
return errorResponse(`Rule "${name}" not found`, { availableRules: allRules.map((r) => r.name) });
|
|
@@ -1816,12 +2252,17 @@ server.registerTool("regle-get-rule-reference", {
|
|
|
1816
2252
|
fullDocId: "core-concepts-rules-built-in-rules"
|
|
1817
2253
|
});
|
|
1818
2254
|
});
|
|
1819
|
-
|
|
2255
|
+
registerTrackedTool("regle-list-validation-properties", {
|
|
1820
2256
|
title: "Get documentation on all validation properties available on r$ and field objects",
|
|
1821
2257
|
inputSchema: z.object({})
|
|
1822
|
-
}, async () => {
|
|
2258
|
+
}, async (_args, clientInfo) => {
|
|
1823
2259
|
const doc = getDocById("core-concepts-validation-properties");
|
|
1824
2260
|
if (!doc) return errorResponse("Validation properties documentation not found");
|
|
2261
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
2262
|
+
...clientInfo,
|
|
2263
|
+
docId: doc.id,
|
|
2264
|
+
docCategory: doc.category
|
|
2265
|
+
});
|
|
1825
2266
|
return jsonResponse({
|
|
1826
2267
|
id: doc.id,
|
|
1827
2268
|
title: doc.title,
|
|
@@ -1829,10 +2270,10 @@ server.registerTool("regle-list-validation-properties", {
|
|
|
1829
2270
|
content: doc.content
|
|
1830
2271
|
});
|
|
1831
2272
|
});
|
|
1832
|
-
|
|
2273
|
+
registerTrackedTool("regle-list-helpers", {
|
|
1833
2274
|
title: "Get a reference of all validation helper utilities available in Regle",
|
|
1834
2275
|
inputSchema: z.object({})
|
|
1835
|
-
}, async () => {
|
|
2276
|
+
}, async (_args, _clientInfo) => {
|
|
1836
2277
|
const helpers = getHelpersFromDocs();
|
|
1837
2278
|
if (helpers.length === 0) return errorResponse("Validation helpers documentation not found");
|
|
1838
2279
|
const guards = helpers.filter((h) => h.category === "guard");
|
|
@@ -1875,11 +2316,16 @@ const rule = createRule({
|
|
|
1875
2316
|
fullDocId: "core-concepts-rules-validations-helpers"
|
|
1876
2317
|
});
|
|
1877
2318
|
});
|
|
1878
|
-
|
|
2319
|
+
registerTrackedTool("regle-get-helper-reference", {
|
|
1879
2320
|
title: "Get details about a specific validation helper utility",
|
|
1880
2321
|
inputSchema: z.object({ name: z.string().describe("The helper name (e.g., \"isFilled\", \"getSize\", \"toNumber\")") })
|
|
1881
|
-
}, async ({ name }) => {
|
|
2322
|
+
}, async ({ name }, clientInfo) => {
|
|
1882
2323
|
const helper = getApiByName(name);
|
|
2324
|
+
/* @__PURE__ */ trackHelperLookup({
|
|
2325
|
+
...clientInfo,
|
|
2326
|
+
helperName: name,
|
|
2327
|
+
found: !!helper
|
|
2328
|
+
});
|
|
1883
2329
|
if (!helper) {
|
|
1884
2330
|
const allHelpers = getHelpersFromDocs();
|
|
1885
2331
|
return errorResponse(`Helper "${name}" not found`, { availableHelpers: allHelpers.map((h) => h.name) });
|
|
@@ -1894,14 +2340,14 @@ server.registerTool("regle-get-helper-reference", {
|
|
|
1894
2340
|
});
|
|
1895
2341
|
});
|
|
1896
2342
|
const apiPackages = getApiPackages();
|
|
1897
|
-
|
|
2343
|
+
registerTrackedTool("regle-get-api-reference", {
|
|
1898
2344
|
title: "Get API reference for Regle packages with full metadata (parameters, return types, examples)",
|
|
1899
2345
|
inputSchema: z.object({
|
|
1900
2346
|
package: z.string().optional().describe("Package name (e.g., \"@regle/core\", \"@regle/rules\", \"@regle/schemas\", \"@regle/nuxt\")"),
|
|
1901
2347
|
name: z.string().optional().describe("Specific function/export name to look up (e.g., \"useRegle\", \"required\")"),
|
|
1902
2348
|
search: z.string().optional().describe("Search query to find exports by name or description")
|
|
1903
2349
|
})
|
|
1904
|
-
}, async ({ package: packageName, name, search }) => {
|
|
2350
|
+
}, async ({ package: packageName, name, search }, clientInfo) => {
|
|
1905
2351
|
if (name) {
|
|
1906
2352
|
const apiItem = getApiByName(name, packageName);
|
|
1907
2353
|
if (!apiItem) return errorResponse(`API export "${name}" not found`, { availablePackages: apiPackages });
|
|
@@ -1917,6 +2363,12 @@ server.registerTool("regle-get-api-reference", {
|
|
|
1917
2363
|
}
|
|
1918
2364
|
if (search) {
|
|
1919
2365
|
const results = searchApi(search);
|
|
2366
|
+
/* @__PURE__ */ trackSearchQuery({
|
|
2367
|
+
...clientInfo,
|
|
2368
|
+
query: search,
|
|
2369
|
+
resultCount: results.length,
|
|
2370
|
+
toolName: "regle-get-api-reference"
|
|
2371
|
+
});
|
|
1920
2372
|
return jsonResponse({
|
|
1921
2373
|
query: search,
|
|
1922
2374
|
resultCount: results.length,
|
|
@@ -1955,10 +2407,22 @@ server.registerTool("regle-get-api-reference", {
|
|
|
1955
2407
|
async function main() {
|
|
1956
2408
|
const transport = new StdioServerTransport();
|
|
1957
2409
|
await server.connect(transport);
|
|
2410
|
+
const clientInfo = server.server.getClientVersion();
|
|
2411
|
+
/* @__PURE__ */ trackServerConnected({
|
|
2412
|
+
clientName: clientInfo?.name,
|
|
2413
|
+
clientVersion: clientInfo?.version
|
|
2414
|
+
});
|
|
1958
2415
|
console.error("Regle MCP Server running on stdio");
|
|
1959
2416
|
}
|
|
1960
|
-
|
|
2417
|
+
async function gracefulShutdown() {
|
|
2418
|
+
await /* @__PURE__ */ shutdown();
|
|
2419
|
+
process.exit(0);
|
|
2420
|
+
}
|
|
2421
|
+
process.on("SIGINT", gracefulShutdown);
|
|
2422
|
+
process.on("SIGTERM", gracefulShutdown);
|
|
2423
|
+
main().catch(async (error) => {
|
|
1961
2424
|
console.error("Failed to start server:", error);
|
|
2425
|
+
await /* @__PURE__ */ shutdown();
|
|
1962
2426
|
process.exit(1);
|
|
1963
2427
|
});
|
|
1964
2428
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/mcp-server",
|
|
3
|
-
"version": "1.14.7-beta.
|
|
3
|
+
"version": "1.14.7-beta.3",
|
|
4
4
|
"description": "MCP Server for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@modelcontextprotocol/sdk": "1.24.3",
|
|
7
|
+
"posthog-node": "5.17.4",
|
|
7
8
|
"zod": "4.1.13"
|
|
8
9
|
},
|
|
9
10
|
"devDependencies": {
|
|
10
11
|
"@types/node": "22.19.1",
|
|
11
12
|
"tsdown": "0.16.8",
|
|
12
13
|
"tsx": "4.21.0",
|
|
13
|
-
"typescript": "5.9.3"
|
|
14
|
+
"typescript": "5.9.3",
|
|
15
|
+
"dotenv": "17.2.3"
|
|
14
16
|
},
|
|
15
17
|
"type": "module",
|
|
16
18
|
"exports": {
|