@testingbot/mcp-server 1.0.0 → 1.0.1
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/README.md +2 -3
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +18 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/constants.d.ts +32 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +32 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/error.d.ts +14 -0
- package/dist/lib/error.d.ts.map +1 -0
- package/dist/lib/error.js +27 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/get-auth.d.ts +6 -0
- package/dist/lib/get-auth.d.ts.map +1 -0
- package/dist/lib/get-auth.js +7 -0
- package/dist/lib/get-auth.js.map +1 -0
- package/dist/lib/logger.d.ts +4 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +51 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/types.d.ts +64 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +12 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +40 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/server-factory.d.ts +19 -0
- package/dist/server-factory.d.ts.map +1 -0
- package/dist/server-factory.js +98 -0
- package/dist/server-factory.js.map +1 -0
- package/dist/tools/browsers.d.ts +3 -0
- package/dist/tools/browsers.d.ts.map +1 -0
- package/dist/tools/browsers.js +73 -0
- package/dist/tools/browsers.js.map +1 -0
- package/dist/tools/builds.d.ts +3 -0
- package/dist/tools/builds.d.ts.map +1 -0
- package/dist/tools/builds.js +115 -0
- package/dist/tools/builds.js.map +1 -0
- package/dist/tools/cdp.d.ts +3 -0
- package/dist/tools/cdp.d.ts.map +1 -0
- package/dist/tools/cdp.js +78 -0
- package/dist/tools/cdp.js.map +1 -0
- package/dist/tools/live.d.ts +3 -0
- package/dist/tools/live.d.ts.map +1 -0
- package/dist/tools/live.js +221 -0
- package/dist/tools/live.js.map +1 -0
- package/dist/tools/screenshots.d.ts +3 -0
- package/dist/tools/screenshots.d.ts.map +1 -0
- package/dist/tools/screenshots.js +132 -0
- package/dist/tools/screenshots.js.map +1 -0
- package/dist/tools/storage.d.ts +3 -0
- package/dist/tools/storage.d.ts.map +1 -0
- package/dist/tools/storage.js +114 -0
- package/dist/tools/storage.js.map +1 -0
- package/dist/tools/team.d.ts +3 -0
- package/dist/tools/team.d.ts.map +1 -0
- package/dist/tools/team.js +171 -0
- package/dist/tools/team.js.map +1 -0
- package/dist/tools/tests.d.ts +3 -0
- package/dist/tools/tests.d.ts.map +1 -0
- package/dist/tools/tests.js +307 -0
- package/dist/tools/tests.js.map +1 -0
- package/dist/tools/tunnels.d.ts +3 -0
- package/dist/tools/tunnels.d.ts.map +1 -0
- package/dist/tools/tunnels.js +74 -0
- package/dist/tools/tunnels.js.map +1 -0
- package/dist/tools/user.d.ts +3 -0
- package/dist/tools/user.d.ts.map +1 -0
- package/dist/tools/user.js +65 -0
- package/dist/tools/user.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handleMCPError, sanitizeSessionId } from "../lib/utils.js";
|
|
3
|
+
import logger from "../lib/logger.js";
|
|
4
|
+
export default function addTestTools(server, testingBotApi, _config) {
|
|
5
|
+
const tools = {};
|
|
6
|
+
const testStatus = function (statusId) {
|
|
7
|
+
switch (statusId) {
|
|
8
|
+
case 1:
|
|
9
|
+
return "Passed";
|
|
10
|
+
case 0:
|
|
11
|
+
return "Failed";
|
|
12
|
+
case 2:
|
|
13
|
+
return "Unknown";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const testUrl = function (test) {
|
|
17
|
+
return `https://testingbot.com/members/tests/${test.session_id}`;
|
|
18
|
+
};
|
|
19
|
+
tools.getTests = server.tool("getTests", "Retrieve a list of recent tests with optional pagination. Returns test details including status, browser, platform, video and duration.", {
|
|
20
|
+
offset: z
|
|
21
|
+
.union([z.number(), z.string().transform(Number)])
|
|
22
|
+
.pipe(z.number().min(0))
|
|
23
|
+
.optional()
|
|
24
|
+
.default(0)
|
|
25
|
+
.describe("Offset for pagination (default: 0)"),
|
|
26
|
+
limit: z
|
|
27
|
+
.union([z.number(), z.string().transform(Number)])
|
|
28
|
+
.pipe(z.number().min(1).max(100))
|
|
29
|
+
.optional()
|
|
30
|
+
.default(10)
|
|
31
|
+
.describe("Number of tests to retrieve (default: 10, max: 100)"),
|
|
32
|
+
}, async (args) => {
|
|
33
|
+
try {
|
|
34
|
+
const offset = Number(args.offset ?? 0);
|
|
35
|
+
const limit = Number(args.limit ?? 10);
|
|
36
|
+
logger.info({ offset, limit }, "Fetching tests");
|
|
37
|
+
const response = await testingBotApi.getTests(offset, limit);
|
|
38
|
+
const tests = response?.data || [];
|
|
39
|
+
const meta = response?.meta || {};
|
|
40
|
+
logger.info({
|
|
41
|
+
count: tests.length,
|
|
42
|
+
offset,
|
|
43
|
+
limit,
|
|
44
|
+
meta,
|
|
45
|
+
}, "Tests fetched successfully");
|
|
46
|
+
let formattedOutput = `## Recent Tests (showing ${limit} from offset ${offset})\n\n`;
|
|
47
|
+
if (tests.length > 0) {
|
|
48
|
+
tests.forEach((test) => {
|
|
49
|
+
formattedOutput += `### Test ${test.session_id}\n`;
|
|
50
|
+
if (test.name) {
|
|
51
|
+
formattedOutput += `- **Name**: ${test.name}\n`;
|
|
52
|
+
}
|
|
53
|
+
// Status and success
|
|
54
|
+
if (test.status_id !== undefined) {
|
|
55
|
+
formattedOutput += `- **Status**: ${testStatus(test.status_id)}\n`;
|
|
56
|
+
}
|
|
57
|
+
else if (test.success !== undefined) {
|
|
58
|
+
formattedOutput += `- **Success**: ${test.success ? "Yes" : "No"}\n`;
|
|
59
|
+
}
|
|
60
|
+
if (test.state) {
|
|
61
|
+
formattedOutput += `- **State**: ${test.state}\n`;
|
|
62
|
+
}
|
|
63
|
+
// Browser and platform
|
|
64
|
+
const browser = test.browser || test.browser_version
|
|
65
|
+
? `${test.browser || ""}${test.browser_version || test.version || ""}`.trim()
|
|
66
|
+
: test.browser || "";
|
|
67
|
+
if (browser) {
|
|
68
|
+
formattedOutput += `- **Browser**: ${browser}\n`;
|
|
69
|
+
}
|
|
70
|
+
const platform = test.os || test.platform || test.platform_name;
|
|
71
|
+
if (platform) {
|
|
72
|
+
formattedOutput += `- **Platform**: ${platform}\n`;
|
|
73
|
+
}
|
|
74
|
+
// Timing
|
|
75
|
+
if (test.duration) {
|
|
76
|
+
formattedOutput += `- **Duration**: ${test.duration}s\n`;
|
|
77
|
+
}
|
|
78
|
+
if (test.created_at) {
|
|
79
|
+
formattedOutput += `- **Created**: ${test.created_at}\n`;
|
|
80
|
+
}
|
|
81
|
+
if (test.completed_at) {
|
|
82
|
+
formattedOutput += `- **Completed**: ${test.completed_at}\n`;
|
|
83
|
+
}
|
|
84
|
+
// Media
|
|
85
|
+
if (test.video) {
|
|
86
|
+
formattedOutput += `- **Video**: ${test.video}\n`;
|
|
87
|
+
}
|
|
88
|
+
// Build and extra
|
|
89
|
+
if (test.build) {
|
|
90
|
+
formattedOutput += `- **Build**: ${test.build}\n`;
|
|
91
|
+
}
|
|
92
|
+
if (test.extra) {
|
|
93
|
+
formattedOutput += `- **Extra**: ${test.extra}\n`;
|
|
94
|
+
}
|
|
95
|
+
formattedOutput += `- **URL**: ${testUrl(test)}\n`;
|
|
96
|
+
formattedOutput += "\n";
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
formattedOutput += "No tests found.\n";
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
content: [
|
|
104
|
+
{
|
|
105
|
+
type: "text",
|
|
106
|
+
text: formattedOutput,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
logger.error(error);
|
|
113
|
+
return handleMCPError("getTests", error);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
tools.getTestDetails = server.tool("getTestDetails", "Get detailed information about a specific test by session ID. Includes logs, screenshots, video URLs, and execution metadata.", {
|
|
117
|
+
sessionId: z.string().describe("The session ID of the test"),
|
|
118
|
+
}, async (args) => {
|
|
119
|
+
try {
|
|
120
|
+
const sessionId = sanitizeSessionId(args.sessionId);
|
|
121
|
+
logger.info({ sessionId }, "Fetching test details");
|
|
122
|
+
const test = await testingBotApi.getTestDetails(sessionId);
|
|
123
|
+
let formattedOutput = `## Test Details: ${sessionId}\n\n`;
|
|
124
|
+
if (test.name) {
|
|
125
|
+
formattedOutput += `- **Name**: ${test.name}\n`;
|
|
126
|
+
}
|
|
127
|
+
// Status and success
|
|
128
|
+
if (test.status_id !== undefined) {
|
|
129
|
+
formattedOutput += `- **Status**: ${testStatus(test.status_id)}\n`;
|
|
130
|
+
}
|
|
131
|
+
else if (test.success !== undefined) {
|
|
132
|
+
formattedOutput += `- **Success**: ${test.success ? "Yes" : "No"}\n`;
|
|
133
|
+
}
|
|
134
|
+
if (test.state) {
|
|
135
|
+
formattedOutput += `- **State**: ${test.state}\n`;
|
|
136
|
+
}
|
|
137
|
+
if (test.status_message) {
|
|
138
|
+
formattedOutput += `- **Status Message**: ${test.status_message}\n`;
|
|
139
|
+
}
|
|
140
|
+
// Browser and platform
|
|
141
|
+
const browser = test.browser || test.browser_version
|
|
142
|
+
? `${test.browser || ""}${test.browser_version || test.version || ""}`.trim()
|
|
143
|
+
: test.browser || "";
|
|
144
|
+
if (browser) {
|
|
145
|
+
formattedOutput += `- **Browser**: ${browser}\n`;
|
|
146
|
+
}
|
|
147
|
+
const platform = test.os || test.platform || test.platform_name;
|
|
148
|
+
if (platform) {
|
|
149
|
+
formattedOutput += `- **Platform**: ${platform}\n`;
|
|
150
|
+
}
|
|
151
|
+
if (test.device_name) {
|
|
152
|
+
formattedOutput += `- **Device**: ${test.device_name}\n`;
|
|
153
|
+
}
|
|
154
|
+
// Test type and execution
|
|
155
|
+
if (test.type) {
|
|
156
|
+
formattedOutput += `- **Type**: ${test.type}\n`;
|
|
157
|
+
}
|
|
158
|
+
// Timing
|
|
159
|
+
if (test.duration) {
|
|
160
|
+
formattedOutput += `- **Duration**: ${test.duration}s\n`;
|
|
161
|
+
}
|
|
162
|
+
if (test.created_at) {
|
|
163
|
+
formattedOutput += `- **Created**: ${test.created_at}\n`;
|
|
164
|
+
}
|
|
165
|
+
if (test.completed_at) {
|
|
166
|
+
formattedOutput += `- **Completed**: ${test.completed_at}\n`;
|
|
167
|
+
}
|
|
168
|
+
// Media
|
|
169
|
+
if (test.video) {
|
|
170
|
+
formattedOutput += `- **Video**: ${test.video}\n`;
|
|
171
|
+
}
|
|
172
|
+
if (test.thumbs && Array.isArray(test.thumbs) && test.thumbs.length > 0) {
|
|
173
|
+
formattedOutput += `- **Screenshots**: ${test.thumbs.length} available\n`;
|
|
174
|
+
}
|
|
175
|
+
// Logs
|
|
176
|
+
if (test.logs && typeof test.logs === "object") {
|
|
177
|
+
formattedOutput += `\n### Logs\n`;
|
|
178
|
+
if (test.logs.selenium) {
|
|
179
|
+
formattedOutput += `- **Selenium Log**: ${test.logs.selenium}\n`;
|
|
180
|
+
}
|
|
181
|
+
if (test.logs.browser) {
|
|
182
|
+
formattedOutput += `- **Browser Log**: ${test.logs.browser}\n`;
|
|
183
|
+
}
|
|
184
|
+
if (test.logs.chrome) {
|
|
185
|
+
formattedOutput += `- **Chrome Log**: ${test.logs.chrome}\n`;
|
|
186
|
+
}
|
|
187
|
+
if (test.logs.vm) {
|
|
188
|
+
formattedOutput += `- **VM Log**: ${test.logs.vm}\n`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Build and metadata
|
|
192
|
+
if (test.build) {
|
|
193
|
+
formattedOutput += `\n- **Build**: ${test.build}\n`;
|
|
194
|
+
}
|
|
195
|
+
if (test.extra) {
|
|
196
|
+
formattedOutput += `- **Extra**: ${test.extra}\n`;
|
|
197
|
+
}
|
|
198
|
+
// Test steps
|
|
199
|
+
if (test.steps && Array.isArray(test.steps) && test.steps.length > 0) {
|
|
200
|
+
formattedOutput += `\n### Test Steps (${test.steps.length} steps)\n`;
|
|
201
|
+
test.steps.forEach((step, index) => {
|
|
202
|
+
formattedOutput += `\n**Step ${index + 1}**: ${step.command}\n`;
|
|
203
|
+
if (step.arguments) {
|
|
204
|
+
formattedOutput += `- Arguments: ${step.arguments}\n`;
|
|
205
|
+
}
|
|
206
|
+
if (step.response) {
|
|
207
|
+
const responseText = step.response.substring(0, 100);
|
|
208
|
+
formattedOutput += `- Response: ${responseText}${step.response.length > 100 ? "..." : ""}\n`;
|
|
209
|
+
}
|
|
210
|
+
if (step.time) {
|
|
211
|
+
formattedOutput += `- Time: ${new Date(step.time).toISOString()}\n`;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
formattedOutput += `\n- **Test URL**: ${testUrl(test)}\n`;
|
|
216
|
+
if (test.assets_available) {
|
|
217
|
+
formattedOutput += `- **Assets**: Available\n`;
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: "text",
|
|
223
|
+
text: formattedOutput,
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
return handleMCPError("getTestDetails", error);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
tools.updateTest = server.tool("updateTest", "Update test metadata such as name, status (passed/failed), and other attributes. Useful for marking tests after execution.", {
|
|
233
|
+
sessionId: z.string().describe("The session ID of the test to update"),
|
|
234
|
+
name: z.string().optional().describe("New name for the test"),
|
|
235
|
+
status: z.enum(["passed", "failed"]).optional().describe("Mark test as passed or failed"),
|
|
236
|
+
build: z.string().optional().describe("Build identifier"),
|
|
237
|
+
extra: z.string().optional().describe("Additional metadata (JSON string)"),
|
|
238
|
+
}, async (args) => {
|
|
239
|
+
try {
|
|
240
|
+
const sessionId = sanitizeSessionId(args.sessionId);
|
|
241
|
+
logger.info({ sessionId, updates: args }, "Updating test");
|
|
242
|
+
const updateData = {};
|
|
243
|
+
if (args.name)
|
|
244
|
+
updateData.name = args.name;
|
|
245
|
+
if (args.status)
|
|
246
|
+
updateData["test[success]"] = args.status === "passed" ? "1" : "0";
|
|
247
|
+
if (args.build)
|
|
248
|
+
updateData.build = args.build;
|
|
249
|
+
if (args.extra)
|
|
250
|
+
updateData.extra = args.extra;
|
|
251
|
+
await testingBotApi.updateTest(updateData, sessionId);
|
|
252
|
+
return {
|
|
253
|
+
content: [
|
|
254
|
+
{
|
|
255
|
+
type: "text",
|
|
256
|
+
text: `Test ${sessionId} updated successfully.`,
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
return handleMCPError("updateTest", error);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
tools.deleteTest = server.tool("deleteTest", "Delete a test by session ID. This permanently removes the test and its associated data.", {
|
|
266
|
+
sessionId: z.string().describe("The session ID of the test to delete"),
|
|
267
|
+
}, async (args) => {
|
|
268
|
+
try {
|
|
269
|
+
const sessionId = sanitizeSessionId(args.sessionId);
|
|
270
|
+
logger.info({ sessionId }, "Deleting test");
|
|
271
|
+
await testingBotApi.deleteTest(sessionId);
|
|
272
|
+
return {
|
|
273
|
+
content: [
|
|
274
|
+
{
|
|
275
|
+
type: "text",
|
|
276
|
+
text: `Test ${sessionId} deleted successfully.`,
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
return handleMCPError("deleteTest", error);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
tools.stopTest = server.tool("stopTest", "Stop a running test by session ID. This terminates the test execution immediately.", {
|
|
286
|
+
sessionId: z.string().describe("The session ID of the test to stop"),
|
|
287
|
+
}, async (args) => {
|
|
288
|
+
try {
|
|
289
|
+
const sessionId = sanitizeSessionId(args.sessionId);
|
|
290
|
+
logger.info({ sessionId }, "Stopping test");
|
|
291
|
+
await testingBotApi.stopTest(sessionId);
|
|
292
|
+
return {
|
|
293
|
+
content: [
|
|
294
|
+
{
|
|
295
|
+
type: "text",
|
|
296
|
+
text: `Test ${sessionId} stopped successfully.`,
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
return handleMCPError("stopTest", error);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return tools;
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests.js","sourceRoot":"","sources":["../../src/tools/tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAW,EAAE,aAAkB,EAAE,OAAyB;IAC7F,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,UAAU,QAAgB;QAC3C,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,CAAC;gBACJ,OAAO,QAAQ,CAAC;YAClB,KAAK,CAAC;gBACJ,OAAO,QAAQ,CAAC;YAClB,KAAK,CAAC;gBACJ,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,UAAU,IAAS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CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,CACF,CAAC;IAEF,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAC1B,UAAU,EACV,oFAAoF,EACpF;QACE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;KACrE,EACD,KAAK,EAAE,IAA2B,EAAE,EAAE;QACpC,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,eAAe,CAAC,CAAC;YAE5C,MAAM,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAExC,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ,SAAS,wBAAwB;qBAChD;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnels.d.ts","sourceRoot":"","sources":["../../src/tools/tunnels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,gBAAgB,uBAyFhG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handleMCPError } from "../lib/utils.js";
|
|
3
|
+
import logger from "../lib/logger.js";
|
|
4
|
+
export default function addTunnelTools(server, testingBotApi, _config) {
|
|
5
|
+
const tools = {};
|
|
6
|
+
tools.getTunnelList = server.tool("getTunnelList", "Get a list of all active TestingBot tunnels. Tunnels allow you to test websites behind firewalls or on your local machine.", {}, async () => {
|
|
7
|
+
try {
|
|
8
|
+
logger.info("Fetching tunnel list");
|
|
9
|
+
const tunnels = await testingBotApi.getTunnelList();
|
|
10
|
+
let formattedOutput = `## Active Tunnels\n\n`;
|
|
11
|
+
if (Array.isArray(tunnels) && tunnels.length > 0) {
|
|
12
|
+
tunnels.forEach((tunnel) => {
|
|
13
|
+
formattedOutput += `### Tunnel ${tunnel.id}\n`;
|
|
14
|
+
formattedOutput += `- **ID**: ${tunnel.id}\n`;
|
|
15
|
+
if (tunnel.status) {
|
|
16
|
+
formattedOutput += `- **Status**: ${tunnel.status}\n`;
|
|
17
|
+
}
|
|
18
|
+
if (tunnel.version) {
|
|
19
|
+
formattedOutput += `- **Version**: ${tunnel.version}\n`;
|
|
20
|
+
}
|
|
21
|
+
if (tunnel.created_at) {
|
|
22
|
+
formattedOutput += `- **Created**: ${tunnel.created_at}\n`;
|
|
23
|
+
}
|
|
24
|
+
if (tunnel.ip) {
|
|
25
|
+
formattedOutput += `- **IP Address**: ${tunnel.ip}\n`;
|
|
26
|
+
}
|
|
27
|
+
if (tunnel.last_heartbeat) {
|
|
28
|
+
formattedOutput += `- **Last Heartbeat**: ${tunnel.last_heartbeat}\n`;
|
|
29
|
+
}
|
|
30
|
+
formattedOutput += "\n";
|
|
31
|
+
});
|
|
32
|
+
formattedOutput += `\n**Total**: ${tunnels.length} active tunnel${tunnels.length === 1 ? "" : "s"}\n`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
formattedOutput += "No active tunnels found.\n\n";
|
|
36
|
+
formattedOutput += "To start a tunnel, download and run the TestingBot Tunnel:\n";
|
|
37
|
+
formattedOutput += "https://testingbot.com/support/other/tunnel\n";
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: formattedOutput,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return handleMCPError("getTunnelList", error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
tools.deleteTunnel = server.tool("deleteTunnel", "Delete an active TestingBot tunnel by its ID. This will terminate the tunnel connection.", {
|
|
53
|
+
tunnelId: z.union([z.number(), z.string()]).describe("The tunnel ID to delete"),
|
|
54
|
+
}, async (args) => {
|
|
55
|
+
try {
|
|
56
|
+
const tunnelId = args.tunnelId;
|
|
57
|
+
logger.info({ tunnelId }, "Deleting tunnel");
|
|
58
|
+
await testingBotApi.deleteTunnel(tunnelId);
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
text: `Tunnel ${tunnelId} deleted successfully.`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return handleMCPError("deleteTunnel", error);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return tools;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=tunnels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnels.js","sourceRoot":"","sources":["../../src/tools/tunnels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,MAAW,EAAE,aAAkB,EAAE,OAAyB;IAC/F,MAAM,KAAK,GAAwB,EAAE,CAAC;IAEtC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,IAAI,CAC/B,eAAe,EACf,4HAA4H,EAC5H,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAA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MAAM,iBAAiB,CAAC;AAInD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,gBAAgB,uBA2E9F"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handleMCPError } from "../lib/utils.js";
|
|
3
|
+
import logger from "../lib/logger.js";
|
|
4
|
+
export default function addUserTools(server, testingBotApi, _config) {
|
|
5
|
+
const tools = {};
|
|
6
|
+
tools.getUserInfo = server.tool("getUserInfo", "Get current user account information including minutes used, plan details, and account status.", {}, async () => {
|
|
7
|
+
try {
|
|
8
|
+
logger.info("Fetching user info");
|
|
9
|
+
const userInfo = await testingBotApi.getUserInfo();
|
|
10
|
+
let formattedOutput = "## User Information\n\n";
|
|
11
|
+
formattedOutput += `- **Name**: ${userInfo.first_name} ${userInfo.last_name}\n`;
|
|
12
|
+
formattedOutput += `- **Email**: ${userInfo.email}\n`;
|
|
13
|
+
if (userInfo.minutes_used !== undefined) {
|
|
14
|
+
formattedOutput += `- **Minutes Used**: ${userInfo.minutes_used}\n`;
|
|
15
|
+
}
|
|
16
|
+
if (userInfo.minutes_limit !== undefined) {
|
|
17
|
+
formattedOutput += `- **Minutes Limit**: ${userInfo.minutes_limit}\n`;
|
|
18
|
+
}
|
|
19
|
+
if (userInfo.plan !== undefined) {
|
|
20
|
+
formattedOutput += `- **Plan**: ${userInfo.plan}\n`;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: formattedOutput,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return handleMCPError("getUserInfo", error);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
tools.updateUserInfo = server.tool("updateUserInfo", "Update user account information such as name, email, or other profile details.", {
|
|
36
|
+
firstName: z.string().optional().describe("First name"),
|
|
37
|
+
lastName: z.string().optional().describe("Last name"),
|
|
38
|
+
email: z.string().email().optional().describe("Email address"),
|
|
39
|
+
}, async (args) => {
|
|
40
|
+
try {
|
|
41
|
+
logger.info({ updates: args }, "Updating user info");
|
|
42
|
+
const updateData = {};
|
|
43
|
+
if (args.firstName)
|
|
44
|
+
updateData.first_name = args.firstName;
|
|
45
|
+
if (args.lastName)
|
|
46
|
+
updateData.last_name = args.lastName;
|
|
47
|
+
if (args.email)
|
|
48
|
+
updateData.email = args.email;
|
|
49
|
+
await testingBotApi.updateUserInfo(updateData);
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: "text",
|
|
54
|
+
text: "User information updated successfully.",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return handleMCPError("updateUserInfo", error);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return tools;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/tools/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAW,EAAE,aAAkB,EAAE,OAAyB;IAC7F,MAAM,KAAK,GAAwB,EAAE,CAAC;IAEtC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAC7B,aAAa,EACb,gGAAgG,EAChG,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAElC,MAAM,QAAQ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