@rainfall-devkit/sdk 0.2.1 → 0.2.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/chunk-6FXRLPLR.mjs +436 -0
- package/dist/chunk-CC4O7GSQ.mjs +978 -0
- package/dist/chunk-CQ5TV7CQ.mjs +989 -0
- package/dist/chunk-GPKQUVAV.mjs +987 -0
- package/dist/chunk-KOCCGNEQ.mjs +269 -0
- package/dist/chunk-LJQEO3CY.mjs +150 -0
- package/dist/chunk-NCQVOLS4.mjs +269 -0
- package/dist/chunk-S7MOQCV4.mjs +137 -0
- package/dist/chunk-XHPFY5MH.mjs +132 -0
- package/dist/cli/index.js +1009 -54
- package/dist/cli/index.mjs +244 -24
- package/dist/daemon/index.d.mts +3 -3
- package/dist/daemon/index.d.ts +3 -3
- package/dist/daemon/index.js +411 -129
- package/dist/daemon/index.mjs +2 -1
- package/dist/display-KKJPO6UA.mjs +14 -0
- package/dist/errors-CY6HW2I5.mjs +24 -0
- package/dist/index.d.mts +66 -4
- package/dist/index.d.ts +66 -4
- package/dist/index.js +903 -124
- package/dist/index.mjs +18 -6
- package/dist/listeners-BBNBsJCk.d.ts +372 -0
- package/dist/listeners-CMUKjEkb.d.mts +372 -0
- package/dist/listeners-CadPNUHd.d.ts +372 -0
- package/dist/listeners-Ckdj6D8T.d.mts +372 -0
- package/dist/mcp.d.mts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +405 -101
- package/dist/mcp.mjs +4 -2
- package/dist/param-parser-JVKB5FQK.mjs +12 -0
- package/dist/param-parser-PAKCNDBX.mjs +136 -0
- package/dist/sdk-Cl5Qzt4I.d.mts +1165 -0
- package/dist/sdk-Cl5Qzt4I.d.ts +1165 -0
- package/dist/sdk-DQKNbBce.d.mts +1162 -0
- package/dist/sdk-DQKNbBce.d.ts +1162 -0
- package/package.json +2 -2
package/dist/mcp.js
CHANGED
|
@@ -3,6 +3,9 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __esm = (fn, res) => function __init() {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
};
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,113 +20,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
20
|
};
|
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
22
|
|
|
20
|
-
//
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
24
|
+
var init_cjs_shims = __esm({
|
|
25
|
+
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
26
|
+
"use strict";
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// src/errors.ts
|
|
31
|
+
var errors_exports = {};
|
|
32
|
+
__export(errors_exports, {
|
|
23
33
|
AuthenticationError: () => AuthenticationError,
|
|
24
34
|
NetworkError: () => NetworkError,
|
|
25
35
|
NotFoundError: () => NotFoundError,
|
|
26
|
-
Rainfall: () => Rainfall,
|
|
27
36
|
RainfallError: () => RainfallError,
|
|
28
37
|
RateLimitError: () => RateLimitError,
|
|
29
38
|
ServerError: () => ServerError,
|
|
30
39
|
TimeoutError: () => TimeoutError,
|
|
31
40
|
ToolNotFoundError: () => ToolNotFoundError,
|
|
32
41
|
ValidationError: () => ValidationError,
|
|
33
|
-
createRainfallMCPServer: () => createRainfallMCPServer,
|
|
34
42
|
parseErrorResponse: () => parseErrorResponse
|
|
35
43
|
});
|
|
36
|
-
module.exports = __toCommonJS(mcp_exports);
|
|
37
|
-
|
|
38
|
-
// src/errors.ts
|
|
39
|
-
var RainfallError = class _RainfallError extends Error {
|
|
40
|
-
constructor(message, code, statusCode, details) {
|
|
41
|
-
super(message);
|
|
42
|
-
this.code = code;
|
|
43
|
-
this.statusCode = statusCode;
|
|
44
|
-
this.details = details;
|
|
45
|
-
this.name = "RainfallError";
|
|
46
|
-
Object.setPrototypeOf(this, _RainfallError.prototype);
|
|
47
|
-
}
|
|
48
|
-
toJSON() {
|
|
49
|
-
return {
|
|
50
|
-
name: this.name,
|
|
51
|
-
code: this.code,
|
|
52
|
-
message: this.message,
|
|
53
|
-
statusCode: this.statusCode,
|
|
54
|
-
details: this.details
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var AuthenticationError = class _AuthenticationError extends RainfallError {
|
|
59
|
-
constructor(message = "Invalid API key", details) {
|
|
60
|
-
super(message, "AUTHENTICATION_ERROR", 401, details);
|
|
61
|
-
this.name = "AuthenticationError";
|
|
62
|
-
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var RateLimitError = class _RateLimitError extends RainfallError {
|
|
66
|
-
retryAfter;
|
|
67
|
-
limit;
|
|
68
|
-
remaining;
|
|
69
|
-
resetAt;
|
|
70
|
-
constructor(message = "Rate limit exceeded", retryAfter = 60, limit = 0, remaining = 0, resetAt) {
|
|
71
|
-
super(message, "RATE_LIMIT_ERROR", 429, { retryAfter, limit, remaining });
|
|
72
|
-
this.name = "RateLimitError";
|
|
73
|
-
this.retryAfter = retryAfter;
|
|
74
|
-
this.limit = limit;
|
|
75
|
-
this.remaining = remaining;
|
|
76
|
-
this.resetAt = resetAt || new Date(Date.now() + retryAfter * 1e3);
|
|
77
|
-
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var ValidationError = class _ValidationError extends RainfallError {
|
|
81
|
-
constructor(message, details) {
|
|
82
|
-
super(message, "VALIDATION_ERROR", 400, details);
|
|
83
|
-
this.name = "ValidationError";
|
|
84
|
-
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var NotFoundError = class _NotFoundError extends RainfallError {
|
|
88
|
-
constructor(resource, identifier) {
|
|
89
|
-
super(
|
|
90
|
-
`${resource}${identifier ? ` '${identifier}'` : ""} not found`,
|
|
91
|
-
"NOT_FOUND_ERROR",
|
|
92
|
-
404,
|
|
93
|
-
{ resource, identifier }
|
|
94
|
-
);
|
|
95
|
-
this.name = "NotFoundError";
|
|
96
|
-
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
var ServerError = class _ServerError extends RainfallError {
|
|
100
|
-
constructor(message = "Internal server error", statusCode = 500) {
|
|
101
|
-
super(message, "SERVER_ERROR", statusCode);
|
|
102
|
-
this.name = "ServerError";
|
|
103
|
-
Object.setPrototypeOf(this, _ServerError.prototype);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var TimeoutError = class _TimeoutError extends RainfallError {
|
|
107
|
-
constructor(timeoutMs) {
|
|
108
|
-
super(`Request timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", 408);
|
|
109
|
-
this.name = "TimeoutError";
|
|
110
|
-
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var NetworkError = class _NetworkError extends RainfallError {
|
|
114
|
-
constructor(message = "Network error", details) {
|
|
115
|
-
super(message, "NETWORK_ERROR", void 0, details);
|
|
116
|
-
this.name = "NetworkError";
|
|
117
|
-
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
var ToolNotFoundError = class _ToolNotFoundError extends RainfallError {
|
|
121
|
-
constructor(toolId) {
|
|
122
|
-
super(`Tool '${toolId}' not found`, "TOOL_NOT_FOUND", 404, { toolId });
|
|
123
|
-
this.name = "ToolNotFoundError";
|
|
124
|
-
Object.setPrototypeOf(this, _ToolNotFoundError.prototype);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
44
|
function parseErrorResponse(response, data) {
|
|
128
45
|
const statusCode = response.status;
|
|
129
46
|
if (statusCode === 429) {
|
|
@@ -172,6 +89,287 @@ function parseErrorResponse(response, data) {
|
|
|
172
89
|
);
|
|
173
90
|
}
|
|
174
91
|
}
|
|
92
|
+
var RainfallError, AuthenticationError, RateLimitError, ValidationError, NotFoundError, ServerError, TimeoutError, NetworkError, ToolNotFoundError;
|
|
93
|
+
var init_errors = __esm({
|
|
94
|
+
"src/errors.ts"() {
|
|
95
|
+
"use strict";
|
|
96
|
+
init_cjs_shims();
|
|
97
|
+
RainfallError = class _RainfallError extends Error {
|
|
98
|
+
constructor(message, code, statusCode, details) {
|
|
99
|
+
super(message);
|
|
100
|
+
this.code = code;
|
|
101
|
+
this.statusCode = statusCode;
|
|
102
|
+
this.details = details;
|
|
103
|
+
this.name = "RainfallError";
|
|
104
|
+
Object.setPrototypeOf(this, _RainfallError.prototype);
|
|
105
|
+
}
|
|
106
|
+
toJSON() {
|
|
107
|
+
return {
|
|
108
|
+
name: this.name,
|
|
109
|
+
code: this.code,
|
|
110
|
+
message: this.message,
|
|
111
|
+
statusCode: this.statusCode,
|
|
112
|
+
details: this.details
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
AuthenticationError = class _AuthenticationError extends RainfallError {
|
|
117
|
+
constructor(message = "Invalid API key", details) {
|
|
118
|
+
super(message, "AUTHENTICATION_ERROR", 401, details);
|
|
119
|
+
this.name = "AuthenticationError";
|
|
120
|
+
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
RateLimitError = class _RateLimitError extends RainfallError {
|
|
124
|
+
retryAfter;
|
|
125
|
+
limit;
|
|
126
|
+
remaining;
|
|
127
|
+
resetAt;
|
|
128
|
+
constructor(message = "Rate limit exceeded", retryAfter = 60, limit = 0, remaining = 0, resetAt) {
|
|
129
|
+
super(message, "RATE_LIMIT_ERROR", 429, { retryAfter, limit, remaining });
|
|
130
|
+
this.name = "RateLimitError";
|
|
131
|
+
this.retryAfter = retryAfter;
|
|
132
|
+
this.limit = limit;
|
|
133
|
+
this.remaining = remaining;
|
|
134
|
+
this.resetAt = resetAt || new Date(Date.now() + retryAfter * 1e3);
|
|
135
|
+
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
ValidationError = class _ValidationError extends RainfallError {
|
|
139
|
+
constructor(message, details) {
|
|
140
|
+
super(message, "VALIDATION_ERROR", 400, details);
|
|
141
|
+
this.name = "ValidationError";
|
|
142
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
NotFoundError = class _NotFoundError extends RainfallError {
|
|
146
|
+
constructor(resource, identifier) {
|
|
147
|
+
super(
|
|
148
|
+
`${resource}${identifier ? ` '${identifier}'` : ""} not found`,
|
|
149
|
+
"NOT_FOUND_ERROR",
|
|
150
|
+
404,
|
|
151
|
+
{ resource, identifier }
|
|
152
|
+
);
|
|
153
|
+
this.name = "NotFoundError";
|
|
154
|
+
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
ServerError = class _ServerError extends RainfallError {
|
|
158
|
+
constructor(message = "Internal server error", statusCode = 500) {
|
|
159
|
+
super(message, "SERVER_ERROR", statusCode);
|
|
160
|
+
this.name = "ServerError";
|
|
161
|
+
Object.setPrototypeOf(this, _ServerError.prototype);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
TimeoutError = class _TimeoutError extends RainfallError {
|
|
165
|
+
constructor(timeoutMs) {
|
|
166
|
+
super(`Request timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", 408);
|
|
167
|
+
this.name = "TimeoutError";
|
|
168
|
+
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
NetworkError = class _NetworkError extends RainfallError {
|
|
172
|
+
constructor(message = "Network error", details) {
|
|
173
|
+
super(message, "NETWORK_ERROR", void 0, details);
|
|
174
|
+
this.name = "NetworkError";
|
|
175
|
+
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
ToolNotFoundError = class _ToolNotFoundError extends RainfallError {
|
|
179
|
+
constructor(toolId) {
|
|
180
|
+
super(`Tool '${toolId}' not found`, "TOOL_NOT_FOUND", 404, { toolId });
|
|
181
|
+
this.name = "ToolNotFoundError";
|
|
182
|
+
Object.setPrototypeOf(this, _ToolNotFoundError.prototype);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// src/mcp.ts
|
|
189
|
+
var mcp_exports = {};
|
|
190
|
+
__export(mcp_exports, {
|
|
191
|
+
AuthenticationError: () => AuthenticationError,
|
|
192
|
+
NetworkError: () => NetworkError,
|
|
193
|
+
NotFoundError: () => NotFoundError,
|
|
194
|
+
Rainfall: () => Rainfall,
|
|
195
|
+
RainfallError: () => RainfallError,
|
|
196
|
+
RateLimitError: () => RateLimitError,
|
|
197
|
+
ServerError: () => ServerError,
|
|
198
|
+
TimeoutError: () => TimeoutError,
|
|
199
|
+
ToolNotFoundError: () => ToolNotFoundError,
|
|
200
|
+
ValidationError: () => ValidationError,
|
|
201
|
+
createRainfallMCPServer: () => createRainfallMCPServer,
|
|
202
|
+
parseErrorResponse: () => parseErrorResponse
|
|
203
|
+
});
|
|
204
|
+
module.exports = __toCommonJS(mcp_exports);
|
|
205
|
+
init_cjs_shims();
|
|
206
|
+
|
|
207
|
+
// src/sdk.ts
|
|
208
|
+
init_cjs_shims();
|
|
209
|
+
|
|
210
|
+
// src/client.ts
|
|
211
|
+
init_cjs_shims();
|
|
212
|
+
init_errors();
|
|
213
|
+
|
|
214
|
+
// src/validation.ts
|
|
215
|
+
init_cjs_shims();
|
|
216
|
+
init_errors();
|
|
217
|
+
var schemaCache = /* @__PURE__ */ new Map();
|
|
218
|
+
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
219
|
+
async function fetchToolSchema(client, toolId) {
|
|
220
|
+
const cached = schemaCache.get(toolId);
|
|
221
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
222
|
+
return cached.schema;
|
|
223
|
+
}
|
|
224
|
+
const response = await client.request(
|
|
225
|
+
`/olympic/subscribers/me/nodes/${toolId}/params`
|
|
226
|
+
);
|
|
227
|
+
if (!response.success || !response.params) {
|
|
228
|
+
throw new ValidationError(`Failed to fetch schema for tool '${toolId}'`);
|
|
229
|
+
}
|
|
230
|
+
schemaCache.set(toolId, { schema: response.params, timestamp: Date.now() });
|
|
231
|
+
return response.params;
|
|
232
|
+
}
|
|
233
|
+
function validateParams(schema, params, toolId) {
|
|
234
|
+
const errors = [];
|
|
235
|
+
const parameters = schema.parameters || {};
|
|
236
|
+
for (const [key, paramSchema] of Object.entries(parameters)) {
|
|
237
|
+
if (paramSchema.optional !== true && !(key in (params || {}))) {
|
|
238
|
+
errors.push({
|
|
239
|
+
path: key,
|
|
240
|
+
message: `Missing required parameter '${key}'`,
|
|
241
|
+
expected: paramSchema.type
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (params) {
|
|
246
|
+
for (const [key, value] of Object.entries(params)) {
|
|
247
|
+
const paramSchema = parameters[key];
|
|
248
|
+
if (!paramSchema) {
|
|
249
|
+
errors.push({
|
|
250
|
+
path: key,
|
|
251
|
+
message: `Unknown parameter '${key}'`,
|
|
252
|
+
received: value
|
|
253
|
+
});
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const typeError = validateType(key, value, paramSchema);
|
|
257
|
+
if (typeError) {
|
|
258
|
+
errors.push(typeError);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
valid: errors.length === 0,
|
|
264
|
+
errors
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function validateType(path, value, schema) {
|
|
268
|
+
if (value === null || value === void 0) {
|
|
269
|
+
if (schema.optional === true) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
path,
|
|
274
|
+
message: `Parameter '${path}' is required but received ${value}`,
|
|
275
|
+
received: value,
|
|
276
|
+
expected: schema.type
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const expectedType = schema.type;
|
|
280
|
+
const actualType = getJsType(value);
|
|
281
|
+
switch (expectedType) {
|
|
282
|
+
case "string":
|
|
283
|
+
if (typeof value !== "string") {
|
|
284
|
+
return {
|
|
285
|
+
path,
|
|
286
|
+
message: `Parameter '${path}' must be a string, received ${actualType}`,
|
|
287
|
+
received: value,
|
|
288
|
+
expected: "string"
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
case "number":
|
|
293
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
294
|
+
return {
|
|
295
|
+
path,
|
|
296
|
+
message: `Parameter '${path}' must be a number, received ${actualType}`,
|
|
297
|
+
received: value,
|
|
298
|
+
expected: "number"
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
case "boolean":
|
|
303
|
+
if (typeof value !== "boolean") {
|
|
304
|
+
return {
|
|
305
|
+
path,
|
|
306
|
+
message: `Parameter '${path}' must be a boolean, received ${actualType}`,
|
|
307
|
+
received: value,
|
|
308
|
+
expected: "boolean"
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
case "array":
|
|
313
|
+
if (!Array.isArray(value)) {
|
|
314
|
+
return {
|
|
315
|
+
path,
|
|
316
|
+
message: `Parameter '${path}' must be an array, received ${actualType}`,
|
|
317
|
+
received: value,
|
|
318
|
+
expected: "array"
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
if (schema.items) {
|
|
322
|
+
for (let i = 0; i < value.length; i++) {
|
|
323
|
+
const itemError = validateType(`${path}[${i}]`, value[i], schema.items);
|
|
324
|
+
if (itemError) {
|
|
325
|
+
return itemError;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
break;
|
|
330
|
+
case "object":
|
|
331
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
332
|
+
return {
|
|
333
|
+
path,
|
|
334
|
+
message: `Parameter '${path}' must be an object, received ${actualType}`,
|
|
335
|
+
received: value,
|
|
336
|
+
expected: "object"
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
if (schema.properties) {
|
|
340
|
+
const objValue = value;
|
|
341
|
+
for (const [propKey, propSchema] of Object.entries(schema.properties)) {
|
|
342
|
+
if (objValue[propKey] !== void 0) {
|
|
343
|
+
const propError = validateType(`${path}.${propKey}`, objValue[propKey], propSchema);
|
|
344
|
+
if (propError) {
|
|
345
|
+
return propError;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
default:
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
function getJsType(value) {
|
|
357
|
+
if (value === null) return "null";
|
|
358
|
+
if (Array.isArray(value)) return "array";
|
|
359
|
+
return typeof value;
|
|
360
|
+
}
|
|
361
|
+
function formatValidationErrors(result) {
|
|
362
|
+
if (result.valid) return "No validation errors";
|
|
363
|
+
const lines = result.errors.map((err) => {
|
|
364
|
+
let line = ` - ${err.message}`;
|
|
365
|
+
if (err.received !== void 0) {
|
|
366
|
+
line += ` (received: ${JSON.stringify(err.received).slice(0, 50)})`;
|
|
367
|
+
}
|
|
368
|
+
return line;
|
|
369
|
+
});
|
|
370
|
+
return `Validation failed with ${result.errors.length} error(s):
|
|
371
|
+
${lines.join("\n")}`;
|
|
372
|
+
}
|
|
175
373
|
|
|
176
374
|
// src/client.ts
|
|
177
375
|
var DEFAULT_BASE_URL = "https://olympic-api.pragma-digital.org/v1";
|
|
@@ -184,6 +382,7 @@ var RainfallClient = class {
|
|
|
184
382
|
defaultTimeout;
|
|
185
383
|
defaultRetries;
|
|
186
384
|
defaultRetryDelay;
|
|
385
|
+
disableValidation;
|
|
187
386
|
lastRateLimitInfo;
|
|
188
387
|
subscriberId;
|
|
189
388
|
constructor(config) {
|
|
@@ -192,6 +391,7 @@ var RainfallClient = class {
|
|
|
192
391
|
this.defaultTimeout = config.timeout || DEFAULT_TIMEOUT;
|
|
193
392
|
this.defaultRetries = config.retries ?? DEFAULT_RETRIES;
|
|
194
393
|
this.defaultRetryDelay = config.retryDelay || DEFAULT_RETRY_DELAY;
|
|
394
|
+
this.disableValidation = config.disableValidation ?? false;
|
|
195
395
|
}
|
|
196
396
|
/**
|
|
197
397
|
* Get the last rate limit info from the API
|
|
@@ -274,15 +474,68 @@ var RainfallClient = class {
|
|
|
274
474
|
}
|
|
275
475
|
/**
|
|
276
476
|
* Execute a tool/node by ID
|
|
477
|
+
*
|
|
478
|
+
* @param toolId - The ID of the tool/node to execute
|
|
479
|
+
* @param params - Parameters to pass to the tool
|
|
480
|
+
* @param options - Request options including skipValidation to bypass param validation
|
|
277
481
|
*/
|
|
278
482
|
async executeTool(toolId, params, options) {
|
|
483
|
+
if (!this.disableValidation && !options?.skipValidation) {
|
|
484
|
+
const validation = await this.validateToolParams(toolId, params);
|
|
485
|
+
if (!validation.valid) {
|
|
486
|
+
const { ValidationError: ValidationError2 } = await Promise.resolve().then(() => (init_errors(), errors_exports));
|
|
487
|
+
throw new ValidationError2(
|
|
488
|
+
`Parameter validation failed for tool '${toolId}': ${formatValidationErrors(validation)}`,
|
|
489
|
+
{ toolId, errors: validation.errors }
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
279
493
|
const subscriberId = await this.ensureSubscriberId();
|
|
280
494
|
const response = await this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}`, {
|
|
281
495
|
method: "POST",
|
|
282
496
|
body: params || {}
|
|
283
497
|
}, options);
|
|
498
|
+
if (response.success === false) {
|
|
499
|
+
const errorMessage = typeof response.error === "string" ? response.error : JSON.stringify(response.error);
|
|
500
|
+
throw new RainfallError(
|
|
501
|
+
`Tool execution failed: ${errorMessage}`,
|
|
502
|
+
"TOOL_EXECUTION_ERROR",
|
|
503
|
+
400,
|
|
504
|
+
{ toolId, error: response.error }
|
|
505
|
+
);
|
|
506
|
+
}
|
|
284
507
|
return response.result;
|
|
285
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Validate parameters for a tool without executing it
|
|
511
|
+
* Fetches the tool schema and validates the provided params
|
|
512
|
+
*
|
|
513
|
+
* @param toolId - The ID of the tool to validate params for
|
|
514
|
+
* @param params - Parameters to validate
|
|
515
|
+
* @returns Validation result with detailed error information
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* const result = await client.validateToolParams('finviz-quotes', { tickers: ['AAPL'] });
|
|
520
|
+
* if (!result.valid) {
|
|
521
|
+
* console.log('Validation errors:', result.errors);
|
|
522
|
+
* }
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
async validateToolParams(toolId, params) {
|
|
526
|
+
try {
|
|
527
|
+
const schema = await fetchToolSchema(this, toolId);
|
|
528
|
+
return validateParams(schema, params, toolId);
|
|
529
|
+
} catch (error) {
|
|
530
|
+
if (error instanceof RainfallError && error.statusCode === 404) {
|
|
531
|
+
return {
|
|
532
|
+
valid: false,
|
|
533
|
+
errors: [{ path: toolId, message: `Tool '${toolId}' not found` }]
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
return { valid: true, errors: [] };
|
|
537
|
+
}
|
|
538
|
+
}
|
|
286
539
|
/**
|
|
287
540
|
* List all available tools
|
|
288
541
|
*/
|
|
@@ -305,11 +558,20 @@ var RainfallClient = class {
|
|
|
305
558
|
}
|
|
306
559
|
/**
|
|
307
560
|
* Get tool schema/parameters
|
|
561
|
+
*
|
|
562
|
+
* @param toolId - The ID of the tool to get schema for
|
|
563
|
+
* @returns Tool schema including parameters and output definitions
|
|
308
564
|
*/
|
|
309
565
|
async getToolSchema(toolId) {
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
566
|
+
const schema = await fetchToolSchema(this, toolId);
|
|
567
|
+
return {
|
|
568
|
+
name: schema.name,
|
|
569
|
+
description: schema.description,
|
|
570
|
+
category: schema.category,
|
|
571
|
+
parameters: schema.parameters,
|
|
572
|
+
output: schema.output,
|
|
573
|
+
metadata: schema.metadata || {}
|
|
574
|
+
};
|
|
313
575
|
}
|
|
314
576
|
/**
|
|
315
577
|
* Get subscriber info
|
|
@@ -394,6 +656,7 @@ var RainfallClient = class {
|
|
|
394
656
|
};
|
|
395
657
|
|
|
396
658
|
// src/namespaces/integrations.ts
|
|
659
|
+
init_cjs_shims();
|
|
397
660
|
function createIntegrations(client) {
|
|
398
661
|
return new IntegrationsNamespace(client);
|
|
399
662
|
}
|
|
@@ -506,6 +769,7 @@ var IntegrationsNamespace = class {
|
|
|
506
769
|
};
|
|
507
770
|
|
|
508
771
|
// src/namespaces/memory.ts
|
|
772
|
+
init_cjs_shims();
|
|
509
773
|
function createMemory(client) {
|
|
510
774
|
return {
|
|
511
775
|
create: (params) => client.executeTool("memory-create", params),
|
|
@@ -518,6 +782,7 @@ function createMemory(client) {
|
|
|
518
782
|
}
|
|
519
783
|
|
|
520
784
|
// src/namespaces/articles.ts
|
|
785
|
+
init_cjs_shims();
|
|
521
786
|
function createArticles(client) {
|
|
522
787
|
return {
|
|
523
788
|
search: (params) => client.executeTool("article-search", params),
|
|
@@ -532,6 +797,7 @@ function createArticles(client) {
|
|
|
532
797
|
}
|
|
533
798
|
|
|
534
799
|
// src/namespaces/web.ts
|
|
800
|
+
init_cjs_shims();
|
|
535
801
|
function createWeb(client) {
|
|
536
802
|
return {
|
|
537
803
|
search: {
|
|
@@ -545,6 +811,7 @@ function createWeb(client) {
|
|
|
545
811
|
}
|
|
546
812
|
|
|
547
813
|
// src/namespaces/ai.ts
|
|
814
|
+
init_cjs_shims();
|
|
548
815
|
function createAI(client) {
|
|
549
816
|
return {
|
|
550
817
|
embeddings: {
|
|
@@ -570,6 +837,7 @@ function createAI(client) {
|
|
|
570
837
|
}
|
|
571
838
|
|
|
572
839
|
// src/namespaces/data.ts
|
|
840
|
+
init_cjs_shims();
|
|
573
841
|
function createData(client) {
|
|
574
842
|
return {
|
|
575
843
|
csv: {
|
|
@@ -591,6 +859,7 @@ function createData(client) {
|
|
|
591
859
|
}
|
|
592
860
|
|
|
593
861
|
// src/namespaces/utils.ts
|
|
862
|
+
init_cjs_shims();
|
|
594
863
|
function createUtils(client) {
|
|
595
864
|
return {
|
|
596
865
|
mermaid: (params) => client.executeTool("mermaid-diagram-generator", { mermaid: params.diagram }),
|
|
@@ -829,9 +1098,40 @@ var Rainfall = class {
|
|
|
829
1098
|
}
|
|
830
1099
|
/**
|
|
831
1100
|
* Execute any tool by ID (low-level access)
|
|
1101
|
+
*
|
|
1102
|
+
* @param toolId - The ID of the tool to execute
|
|
1103
|
+
* @param params - Parameters to pass to the tool
|
|
1104
|
+
* @param options - Execution options including skipValidation to bypass param validation
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* ```typescript
|
|
1108
|
+
* // Execute with validation (default)
|
|
1109
|
+
* const result = await rainfall.executeTool('finviz-quotes', { tickers: ['AAPL'] });
|
|
1110
|
+
*
|
|
1111
|
+
* // Execute without validation
|
|
1112
|
+
* const result = await rainfall.executeTool('finviz-quotes', { tickers: ['AAPL'] }, { skipValidation: true });
|
|
1113
|
+
* ```
|
|
832
1114
|
*/
|
|
833
|
-
async executeTool(toolId, params) {
|
|
834
|
-
return this.client.executeTool(toolId, params);
|
|
1115
|
+
async executeTool(toolId, params, options) {
|
|
1116
|
+
return this.client.executeTool(toolId, params, options);
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Validate parameters for a tool without executing it
|
|
1120
|
+
*
|
|
1121
|
+
* @param toolId - The ID of the tool to validate params for
|
|
1122
|
+
* @param params - Parameters to validate
|
|
1123
|
+
* @returns Validation result with detailed error information
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* ```typescript
|
|
1127
|
+
* const result = await rainfall.validateToolParams('finviz-quotes', { tickers: ['AAPL'] });
|
|
1128
|
+
* if (!result.valid) {
|
|
1129
|
+
* console.log('Validation errors:', result.errors);
|
|
1130
|
+
* }
|
|
1131
|
+
* ```
|
|
1132
|
+
*/
|
|
1133
|
+
async validateToolParams(toolId, params) {
|
|
1134
|
+
return this.client.validateToolParams(toolId, params);
|
|
835
1135
|
}
|
|
836
1136
|
/**
|
|
837
1137
|
* Get current subscriber info and usage
|
|
@@ -890,7 +1190,11 @@ var Rainfall = class {
|
|
|
890
1190
|
}
|
|
891
1191
|
};
|
|
892
1192
|
|
|
1193
|
+
// src/types.ts
|
|
1194
|
+
init_cjs_shims();
|
|
1195
|
+
|
|
893
1196
|
// src/mcp.ts
|
|
1197
|
+
init_errors();
|
|
894
1198
|
function createRainfallMCPServer(config) {
|
|
895
1199
|
const rainfall = new Rainfall(config);
|
|
896
1200
|
const serverName = config.name || "rainfall-mcp-server";
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Rainfall
|
|
3
|
+
} from "./chunk-CQ5TV7CQ.mjs";
|
|
1
4
|
import {
|
|
2
5
|
AuthenticationError,
|
|
3
6
|
NetworkError,
|
|
4
7
|
NotFoundError,
|
|
5
|
-
Rainfall,
|
|
6
8
|
RainfallError,
|
|
7
9
|
RateLimitError,
|
|
8
10
|
ServerError,
|
|
@@ -10,7 +12,7 @@ import {
|
|
|
10
12
|
ToolNotFoundError,
|
|
11
13
|
ValidationError,
|
|
12
14
|
parseErrorResponse
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LJQEO3CY.mjs";
|
|
14
16
|
|
|
15
17
|
// src/mcp.ts
|
|
16
18
|
function createRainfallMCPServer(config) {
|