@testingbot/mcp-server 1.0.0 → 1.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.
Files changed (98) hide show
  1. package/README.md +114 -7
  2. package/dist/config.d.ts +3 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +31 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +49 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/lib/constants.d.ts +32 -0
  11. package/dist/lib/constants.d.ts.map +1 -0
  12. package/dist/lib/constants.js +32 -0
  13. package/dist/lib/constants.js.map +1 -0
  14. package/dist/lib/credentials.d.ts +19 -0
  15. package/dist/lib/credentials.d.ts.map +1 -0
  16. package/dist/lib/credentials.js +128 -0
  17. package/dist/lib/credentials.js.map +1 -0
  18. package/dist/lib/error.d.ts +14 -0
  19. package/dist/lib/error.d.ts.map +1 -0
  20. package/dist/lib/error.js +27 -0
  21. package/dist/lib/error.js.map +1 -0
  22. package/dist/lib/get-auth.d.ts +6 -0
  23. package/dist/lib/get-auth.d.ts.map +1 -0
  24. package/dist/lib/get-auth.js +7 -0
  25. package/dist/lib/get-auth.js.map +1 -0
  26. package/dist/lib/logger.d.ts +4 -0
  27. package/dist/lib/logger.d.ts.map +1 -0
  28. package/dist/lib/logger.js +77 -0
  29. package/dist/lib/logger.js.map +1 -0
  30. package/dist/lib/types.d.ts +70 -0
  31. package/dist/lib/types.d.ts.map +1 -0
  32. package/dist/lib/types.js +2 -0
  33. package/dist/lib/types.js.map +1 -0
  34. package/dist/lib/utils.d.ts +12 -0
  35. package/dist/lib/utils.d.ts.map +1 -0
  36. package/dist/lib/utils.js +40 -0
  37. package/dist/lib/utils.js.map +1 -0
  38. package/dist/server-factory.d.ts +33 -0
  39. package/dist/server-factory.d.ts.map +1 -0
  40. package/dist/server-factory.js +224 -0
  41. package/dist/server-factory.js.map +1 -0
  42. package/dist/silence-wdio.d.ts +2 -0
  43. package/dist/silence-wdio.d.ts.map +1 -0
  44. package/dist/silence-wdio.js +17 -0
  45. package/dist/silence-wdio.js.map +1 -0
  46. package/dist/tools/auth.d.ts +43 -0
  47. package/dist/tools/auth.d.ts.map +1 -0
  48. package/dist/tools/auth.js +571 -0
  49. package/dist/tools/auth.js.map +1 -0
  50. package/dist/tools/browsers.d.ts +3 -0
  51. package/dist/tools/browsers.d.ts.map +1 -0
  52. package/dist/tools/browsers.js +74 -0
  53. package/dist/tools/browsers.js.map +1 -0
  54. package/dist/tools/builds.d.ts +3 -0
  55. package/dist/tools/builds.d.ts.map +1 -0
  56. package/dist/tools/builds.js +115 -0
  57. package/dist/tools/builds.js.map +1 -0
  58. package/dist/tools/cdp.d.ts +3 -0
  59. package/dist/tools/cdp.d.ts.map +1 -0
  60. package/dist/tools/cdp.js +78 -0
  61. package/dist/tools/cdp.js.map +1 -0
  62. package/dist/tools/live.d.ts +3 -0
  63. package/dist/tools/live.d.ts.map +1 -0
  64. package/dist/tools/live.js +221 -0
  65. package/dist/tools/live.js.map +1 -0
  66. package/dist/tools/logs.d.ts +3 -0
  67. package/dist/tools/logs.d.ts.map +1 -0
  68. package/dist/tools/logs.js +135 -0
  69. package/dist/tools/logs.js.map +1 -0
  70. package/dist/tools/project.d.ts +16 -0
  71. package/dist/tools/project.d.ts.map +1 -0
  72. package/dist/tools/project.js +457 -0
  73. package/dist/tools/project.js.map +1 -0
  74. package/dist/tools/screenshots.d.ts +3 -0
  75. package/dist/tools/screenshots.d.ts.map +1 -0
  76. package/dist/tools/screenshots.js +132 -0
  77. package/dist/tools/screenshots.js.map +1 -0
  78. package/dist/tools/storage.d.ts +3 -0
  79. package/dist/tools/storage.d.ts.map +1 -0
  80. package/dist/tools/storage.js +200 -0
  81. package/dist/tools/storage.js.map +1 -0
  82. package/dist/tools/team.d.ts +3 -0
  83. package/dist/tools/team.d.ts.map +1 -0
  84. package/dist/tools/team.js +171 -0
  85. package/dist/tools/team.js.map +1 -0
  86. package/dist/tools/tests.d.ts +3 -0
  87. package/dist/tools/tests.d.ts.map +1 -0
  88. package/dist/tools/tests.js +309 -0
  89. package/dist/tools/tests.js.map +1 -0
  90. package/dist/tools/tunnels.d.ts +3 -0
  91. package/dist/tools/tunnels.d.ts.map +1 -0
  92. package/dist/tools/tunnels.js +74 -0
  93. package/dist/tools/tunnels.js.map +1 -0
  94. package/dist/tools/user.d.ts +3 -0
  95. package/dist/tools/user.d.ts.map +1 -0
  96. package/dist/tools/user.js +83 -0
  97. package/dist/tools/user.js.map +1 -0
  98. package/package.json +10 -3
@@ -0,0 +1,77 @@
1
+ import pino from "pino";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ import fs from "fs";
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ // Check if debug logging is enabled via environment variable
8
+ const debugToFile = process.env.TESTINGBOT_DEBUG === "true";
9
+ const isDevMode = process.env.NODE_ENV === "development" || process.argv.includes("--dev");
10
+ const logLevel = process.env.LOG_LEVEL || (isDevMode || debugToFile ? "info" : "error");
11
+ // Create logs directory if it doesn't exist and debug is enabled
12
+ let logFilePath;
13
+ if (debugToFile) {
14
+ const logsDir = path.join(__dirname, "../../logs");
15
+ if (!fs.existsSync(logsDir)) {
16
+ fs.mkdirSync(logsDir, { recursive: true });
17
+ }
18
+ logFilePath = path.join(logsDir, `debug.log`);
19
+ }
20
+ // Redact known credential / sensitive fields from any logged object.
21
+ const redactPaths = [
22
+ "*.api_key",
23
+ "*.api_secret",
24
+ "*.apiKey",
25
+ "*.apiSecret",
26
+ "*.password",
27
+ "*.authorization",
28
+ "*.Authorization",
29
+ "options.api_key",
30
+ "options.api_secret",
31
+ "args.localFilePath",
32
+ "args.remoteUrl",
33
+ "args.extra",
34
+ "headers.authorization",
35
+ ];
36
+ // MCP servers communicate over stdio — stdout is reserved for JSON-RPC framing.
37
+ // All log output MUST go to stderr (fd 2) or a file; never to stdout.
38
+ const logger = (() => {
39
+ const base = { level: logLevel, redact: { paths: redactPaths, censor: "[redacted]" } };
40
+ if (debugToFile && logFilePath) {
41
+ return pino({
42
+ ...base,
43
+ transport: {
44
+ target: "pino-pretty",
45
+ options: {
46
+ colorize: false,
47
+ translateTime: "yyyy-mm-dd HH:MM:ss",
48
+ ignore: "pid,hostname",
49
+ destination: logFilePath,
50
+ mkdir: true,
51
+ },
52
+ },
53
+ });
54
+ }
55
+ if (isDevMode) {
56
+ return pino({
57
+ ...base,
58
+ transport: {
59
+ target: "pino-pretty",
60
+ options: {
61
+ colorize: true,
62
+ translateTime: "HH:MM:ss Z",
63
+ ignore: "pid,hostname",
64
+ destination: 2,
65
+ },
66
+ },
67
+ });
68
+ }
69
+ // Production: raw JSON straight to stderr — never stdout.
70
+ return pino(base, pino.destination(2));
71
+ })();
72
+ if (debugToFile && logFilePath) {
73
+ // Log to stderr so it appears in Claude Desktop logs
74
+ console.error(`🐛 Debug logging enabled: ${logFilePath}`);
75
+ }
76
+ export default logger;
77
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,MAAM,CAAC;AAC5D,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAA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;oBACtB,WAAW,EAAE,WAAW;oBACxB,KAAK,EAAE,IAAI;iBACZ;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;YACV,GAAG,IAAI;YACP,SAAS,EAAE;gBACT,MAAM,EAAE,aAAa;gBACrB,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI;oBACd,aAAa,EAAE,YAAY;oBAC3B,MAAM,EAAE,cAAc;oBACtB,WAAW,EAAE,CAAC;iBACf;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,0DAA0D;IAC1D,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC,EAAE,CAAC;AAEL,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;IAC/B,qDAAqD;IACrD,OAAO,CAAC,KAAK,CAAC,6BAA6B,WAAW,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,70 @@
1
+ export type TestingBotConfig = {
2
+ "testingbot-key": string;
3
+ "testingbot-secret": string;
4
+ };
5
+ export interface TestingBotOptions {
6
+ api_key?: string;
7
+ api_secret?: string;
8
+ debug?: boolean;
9
+ }
10
+ export interface Browser {
11
+ browserName: string;
12
+ version?: string;
13
+ platform?: string;
14
+ os?: string;
15
+ }
16
+ export interface Device {
17
+ id: string;
18
+ name: string;
19
+ platform: string;
20
+ version: string;
21
+ available: boolean;
22
+ }
23
+ export interface Test {
24
+ session_id: string;
25
+ status: string;
26
+ browser: string;
27
+ version: string;
28
+ platform: string;
29
+ duration: number;
30
+ created_at: string;
31
+ [key: string]: any;
32
+ }
33
+ export interface Build {
34
+ id: number;
35
+ name: string;
36
+ tests: number;
37
+ created_at: string;
38
+ [key: string]: any;
39
+ }
40
+ export interface UserInfo {
41
+ first_name?: string;
42
+ last_name?: string;
43
+ email?: string;
44
+ plan?: string;
45
+ company?: string;
46
+ country?: string;
47
+ seconds?: number;
48
+ max_concurrent?: number;
49
+ max_concurrent_mobile?: number;
50
+ [key: string]: any;
51
+ }
52
+ export interface Screenshot {
53
+ id: string;
54
+ url: string;
55
+ screenshots: Array<{
56
+ browser: string;
57
+ version: string;
58
+ os: string;
59
+ image_url: string;
60
+ thumb_url: string;
61
+ }>;
62
+ [key: string]: any;
63
+ }
64
+ export interface StorageFile {
65
+ app_url: string;
66
+ name: string;
67
+ size: number;
68
+ uploaded_at: string;
69
+ }
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,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@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ export declare function sanitizeSessionId(sessionId: string): string;
2
+ export declare function formatError(error: unknown): string;
3
+ export declare function handleMCPError(toolName: string, error: unknown): {
4
+ content: Array<{
5
+ type: string;
6
+ text: string;
7
+ }>;
8
+ isError: boolean;
9
+ };
10
+ export declare function validateUrl(url: string): boolean;
11
+ export declare function sleep(ms: number): Promise<void>;
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKlD;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACb;IACD,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC;CAClB,CAkBA;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOhD;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
@@ -0,0 +1,40 @@
1
+ import logger from "./logger.js";
2
+ export function sanitizeSessionId(sessionId) {
3
+ return sessionId.replace(/[^a-zA-Z0-9-_]/g, "");
4
+ }
5
+ export function formatError(error) {
6
+ if (error instanceof Error) {
7
+ return error.message;
8
+ }
9
+ return String(error);
10
+ }
11
+ export function handleMCPError(toolName, error) {
12
+ const errorMessage = formatError(error);
13
+ logger.error({ tool: toolName, error: errorMessage }, "Tool execution failed");
14
+ const readableToolName = toolName
15
+ .replace(/([A-Z])/g, " $1")
16
+ .toLowerCase()
17
+ .trim();
18
+ return {
19
+ content: [
20
+ {
21
+ type: "text",
22
+ text: `Failed to ${readableToolName}: ${errorMessage}. Please check your credentials and try again.`,
23
+ },
24
+ ],
25
+ isError: true,
26
+ };
27
+ }
28
+ export function validateUrl(url) {
29
+ try {
30
+ new URL(url);
31
+ return true;
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ }
37
+ export function sleep(ms) {
38
+ return new Promise((resolve) => setTimeout(resolve, ms));
39
+ }
40
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,QAAgB,EAChB,KAAc;IAKd,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,uBAAuB,CAAC,CAAC;IAE/E,MAAM,gBAAgB,GAAG,QAAQ;SAC9B,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,WAAW,EAAE;SACb,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,aAAa,gBAAgB,KAAK,YAAY,gDAAgD;aACrG;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { Server as McpServer } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { TestingBotConfig } from "./lib/types.js";
3
+ export declare class TestingBotMcpServer {
4
+ server: McpServer;
5
+ tools: Record<string, any>;
6
+ private testingBotApi;
7
+ private config;
8
+ private automation;
9
+ private closing;
10
+ constructor(testingBotApi: any, config: TestingBotConfig);
11
+ private setupHandlers;
12
+ handleToolCall(toolName: string, toolArgs: any): Promise<any>;
13
+ private hasCredentials;
14
+ reinitializeAfterLogin(): Promise<void>;
15
+ private registerLocalTools;
16
+ /**
17
+ * Async tool registration. Currently this spawns the appium-mcp child
18
+ * process bundled with @testingbot/automation-mcp and proxies its full
19
+ * mobile tool surface onto this server. Must complete before the MCP
20
+ * client requests its first tools/list.
21
+ */
22
+ private registerAutomationTools;
23
+ tool(name: string, description: string, schema: any, handler: (args: any) => Promise<any>): {
24
+ name: string;
25
+ description: string;
26
+ schema: any;
27
+ handler: (args: any) => Promise<any>;
28
+ };
29
+ preflight(): Promise<void>;
30
+ run(): Promise<void>;
31
+ close(): Promise<void>;
32
+ }
33
+ //# sourceMappingURL=server-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-factory.d.ts","sourceRoot":"","sources":["../src/server-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAGhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAsBlD,qBAAa,mBAAmB;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IACvC,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,OAAO,CAAS;gBAEZ,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,gBAAgB;IAsBxD,OAAO,CAAC,aAAa;IA+BR,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAyB1E,OAAO,CAAC,cAAc;IAST,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAkCpD,OAAO,CAAC,kBAAkB;IAyB1B;;;;;OAKG;YACW,uBAAuB;IAM9B,IAAI,CACT,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;;;;wBAApB,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;;IAezB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B1B,GAAG;IAQH,KAAK;CAenB"}
@@ -0,0 +1,224 @@
1
+ import { Server as McpServer } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
4
+ import logger from "./lib/logger.js";
5
+ import { createRequire } from "module";
6
+ const require = createRequire(import.meta.url);
7
+ const packageJson = require("../package.json");
8
+ import addBrowserTools from "./tools/browsers.js";
9
+ import addTestTools from "./tools/tests.js";
10
+ import addBuildTools from "./tools/builds.js";
11
+ import addStorageTools from "./tools/storage.js";
12
+ import addScreenshotTools from "./tools/screenshots.js";
13
+ import addUserTools from "./tools/user.js";
14
+ import addLiveTools from "./tools/live.js";
15
+ import addTeamTools from "./tools/team.js";
16
+ import addCdpTools from "./tools/cdp.js";
17
+ import addTunnelTools from "./tools/tunnels.js";
18
+ import addLogTools from "./tools/logs.js";
19
+ import addProjectTools from "./tools/project.js";
20
+ import addAuthTools from "./tools/auth.js";
21
+ import { addAutomationTools } from "@testingbot/automation-mcp";
22
+ export class TestingBotMcpServer {
23
+ server;
24
+ tools = {};
25
+ testingBotApi;
26
+ config;
27
+ automation = null;
28
+ closing = false;
29
+ constructor(testingBotApi, config) {
30
+ this.testingBotApi = testingBotApi;
31
+ this.config = config;
32
+ this.server = new McpServer({
33
+ name: packageJson.name || "testingbot-mcp-server",
34
+ version: packageJson.version || "1.0.0",
35
+ }, {
36
+ capabilities: {
37
+ // listChanged lets us notify clients when tb_login re-registers
38
+ // credential-dependent (automation) tools after a successful login.
39
+ tools: { listChanged: true },
40
+ },
41
+ });
42
+ this.registerLocalTools();
43
+ this.setupHandlers();
44
+ }
45
+ setupHandlers() {
46
+ // Handle tools/list request
47
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => {
48
+ return {
49
+ tools: Object.values(this.tools).map((tool) => ({
50
+ name: tool.name,
51
+ description: tool.description,
52
+ // Proxied tools (e.g. appium-mcp) pre-stash a raw JSON Schema on the
53
+ // tool object. Honor it; otherwise serialize the Zod-style dict.
54
+ inputSchema: tool.inputSchema ?? {
55
+ type: "object",
56
+ properties: tool.schema,
57
+ required: Object.keys(tool.schema).filter((key) => !tool.schema[key].isOptional?.()),
58
+ },
59
+ })),
60
+ };
61
+ });
62
+ // Handle tools/call request
63
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
64
+ const toolName = request.params.name;
65
+ const toolArgs = request.params.arguments || {};
66
+ logger.info({ tool: toolName, args: toolArgs }, "Tool called");
67
+ return this.handleToolCall(toolName, toolArgs);
68
+ });
69
+ }
70
+ // Dispatch a single tool call, applying the degraded-mode credential gate.
71
+ // Extracted from the request handler so the gate is unit-testable.
72
+ async handleToolCall(toolName, toolArgs) {
73
+ const tool = this.tools[toolName];
74
+ if (!tool) {
75
+ throw new Error(`Tool not found: ${toolName}`);
76
+ }
77
+ // Degraded mode: with no credentials yet, every tool except the device-auth
78
+ // flow reports how to authenticate instead of failing with an opaque API
79
+ // error. Checked per-call so it clears the moment tb_login writes
80
+ // credentials (which mutates this.config) — no restart required.
81
+ if (toolName !== "tb_login" && !this.hasCredentials()) {
82
+ return {
83
+ content: [
84
+ {
85
+ type: "text",
86
+ text: "No TestingBot credentials configured. Run the tb_login tool to authenticate (no API key needed), or set TESTINGBOT_KEY and TESTINGBOT_SECRET.",
87
+ },
88
+ ],
89
+ isError: true,
90
+ };
91
+ }
92
+ return tool.handler(toolArgs);
93
+ }
94
+ hasCredentials() {
95
+ return Boolean(this.config["testingbot-key"] && this.config["testingbot-secret"]);
96
+ }
97
+ // Called by the tb_login tool after a successful login. Credential-dependent
98
+ // tools from @testingbot/automation-mcp bind their key/secret at registration,
99
+ // so they're stale (or, in degraded startup, absent). Re-register them with the
100
+ // now-valid credentials and tell the client the tool list changed. Best-effort:
101
+ // failures here must not break the login that just succeeded.
102
+ async reinitializeAfterLogin() {
103
+ if (this.closing)
104
+ return;
105
+ try {
106
+ // Spawn the new automation handle into a local FIRST so this.automation is
107
+ // never null mid-flight (which would let a concurrent close() skip shutting
108
+ // down the old child while a new one is being spawned → orphaned process).
109
+ const previous = this.automation;
110
+ const next = await addAutomationTools(this, this.testingBotApi, this.config);
111
+ // If the server began shutting down while we were spawning, don't install
112
+ // the new handle — tear it down so we don't leak its appium child.
113
+ if (this.closing) {
114
+ await next.shutdown();
115
+ return;
116
+ }
117
+ this.automation = next;
118
+ Object.assign(this.tools, next.tools);
119
+ if (previous)
120
+ await previous.shutdown();
121
+ try {
122
+ await this.server.sendToolListChanged();
123
+ }
124
+ catch {
125
+ // Client may not support list-changed notifications; harmless.
126
+ }
127
+ logger.info("Re-registered credential-dependent tools after login");
128
+ }
129
+ catch (error) {
130
+ logger.warn({ error: error instanceof Error ? error.message : String(error) }, "Failed to re-register automation tools after login; a client restart may be needed for them");
131
+ }
132
+ }
133
+ registerLocalTools() {
134
+ const toolAdders = [
135
+ addAuthTools,
136
+ addBrowserTools,
137
+ addTestTools,
138
+ addBuildTools,
139
+ addStorageTools,
140
+ addScreenshotTools,
141
+ addUserTools,
142
+ addLiveTools,
143
+ addTeamTools,
144
+ addCdpTools,
145
+ addTunnelTools,
146
+ addLogTools,
147
+ addProjectTools,
148
+ ];
149
+ toolAdders.forEach((adder) => {
150
+ const addedTools = adder(this, this.testingBotApi, this.config);
151
+ Object.assign(this.tools, addedTools);
152
+ });
153
+ logger.info({ toolCount: Object.keys(this.tools).length }, "Local tools registered");
154
+ }
155
+ /**
156
+ * Async tool registration. Currently this spawns the appium-mcp child
157
+ * process bundled with @testingbot/automation-mcp and proxies its full
158
+ * mobile tool surface onto this server. Must complete before the MCP
159
+ * client requests its first tools/list.
160
+ */
161
+ async registerAutomationTools() {
162
+ this.automation = await addAutomationTools(this, this.testingBotApi, this.config);
163
+ Object.assign(this.tools, this.automation.tools);
164
+ logger.info({ toolCount: Object.keys(this.tools).length }, "All tools registered");
165
+ }
166
+ tool(name, description, schema, handler) {
167
+ const tool = {
168
+ name,
169
+ description,
170
+ schema,
171
+ handler,
172
+ };
173
+ return tool;
174
+ }
175
+ // Validates the runtime environment and credentials before accepting MCP
176
+ // traffic. Throws on any blocking issue so the entry point can exit with a
177
+ // clear error instead of letting the first tool call fail mysteriously.
178
+ async preflight() {
179
+ const required = 18;
180
+ const major = Number(process.versions.node.split(".")[0]);
181
+ if (!Number.isFinite(major) || major < required) {
182
+ throw new Error(`Node.js ${required}+ is required; this process is running ${process.versions.node}. Upgrade Node (e.g. via nvm or https://nodejs.org) and re-run.`);
183
+ }
184
+ // No credentials yet: start anyway in degraded mode. The tb_login tool is
185
+ // always available, and every other tool reports "Run tb_login" until creds
186
+ // exist. This makes first-run self-healing instead of a hard crash.
187
+ if (!this.hasCredentials()) {
188
+ logger.warn("No TestingBot credentials configured — starting in degraded mode. Run the tb_login tool to authenticate, or set TESTINGBOT_KEY and TESTINGBOT_SECRET (or TB_KEY/TB_SECRET).");
189
+ return;
190
+ }
191
+ try {
192
+ await this.testingBotApi.getUserInfo();
193
+ logger.info("Credentials verified against TestingBot API");
194
+ }
195
+ catch (error) {
196
+ const message = error instanceof Error ? error.message : String(error);
197
+ throw new Error(`TestingBot credential check failed: ${message}. Verify TESTINGBOT_KEY / TESTINGBOT_SECRET in the MCP client config.`);
198
+ }
199
+ }
200
+ async run() {
201
+ await this.preflight();
202
+ await this.registerAutomationTools();
203
+ const transport = new StdioServerTransport();
204
+ await this.server.connect(transport);
205
+ logger.info("TestingBot MCP Server running on stdio");
206
+ }
207
+ async close() {
208
+ // Signal any in-flight reinitializeAfterLogin to abort before installing /
209
+ // spawning a new automation child, so we don't leak an orphaned process.
210
+ this.closing = true;
211
+ try {
212
+ // Close any live automation sessions first — they hold remote resources
213
+ // (TestingBot minutes) that we want released before the MCP transport drops.
214
+ if (this.automation) {
215
+ await this.automation.shutdown();
216
+ }
217
+ await this.server.close();
218
+ }
219
+ catch (error) {
220
+ logger.error({ error }, "Error while closing MCP server");
221
+ }
222
+ }
223
+ }
224
+ //# sourceMappingURL=server-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-factory.js","sourceRoot":"","sources":["../src/server-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEnG,OAAO,MAAM,MAAM,iBAAiB,CAA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+ export {};
2
+ //# sourceMappingURL=silence-wdio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"silence-wdio.d.ts","sourceRoot":"","sources":["../src/silence-wdio.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ // Side-effect module: silence @wdio/logger BEFORE the `webdriver` module loads.
2
+ //
3
+ // The `webdriver` package creates its logger at module-evaluation time
4
+ // (`var log = logger("webdriver")`), and @wdio/logger reads WDIO_LOG_LEVEL once,
5
+ // at that moment, then caches the logger. The default level is "info", which it
6
+ // writes to process.stdout — and for a stdio MCP server stdout is reserved for
7
+ // JSON-RPC framing, so those lines corrupt the protocol stream (the client throws
8
+ // "Unexpected non-whitespace character after JSON").
9
+ //
10
+ // ESM hoists `import` statements above top-level code, so setting this env var in
11
+ // the body of index.ts (even textually "above" the imports) runs too late —
12
+ // webdriver has already cached an info-level logger by then. Importing THIS module
13
+ // before any module that transitively imports `webdriver` guarantees the env var
14
+ // is in place in time. An operator can still override the level.
15
+ process.env.WDIO_LOG_LEVEL = process.env.WDIO_LOG_LEVEL || "silent";
16
+ export {};
17
+ //# sourceMappingURL=silence-wdio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"silence-wdio.js","sourceRoot":"","sources":["../src/silence-wdio.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,uEAAuE;AACvE,iFAAiF;AACjF,gFAAgF;AAChF,+EAA+E;AAC/E,kFAAkF;AAClF,qDAAqD;AACrD,EAAE;AACF,kFAAkF;AAClF,4EAA4E;AAC5E,mFAAmF;AACnF,iFAAiF;AACjF,iEAAiE;AACjE,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,QAAQ,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { createServer } from "node:http";
2
+ import { TestingBotConfig } from "../lib/types.js";
3
+ import { type DeviceCredentials } from "../lib/credentials.js";
4
+ export type PollResult = {
5
+ status: "approved";
6
+ creds: DeviceCredentials;
7
+ } | {
8
+ status: "denied";
9
+ } | {
10
+ status: "expired";
11
+ } | {
12
+ status: "pending";
13
+ intervalMs: number;
14
+ };
15
+ interface PollDeps {
16
+ sleep?: (ms: number) => Promise<void>;
17
+ now?: () => number;
18
+ fetchImpl?: typeof fetch;
19
+ }
20
+ export declare function pollDeviceToken(baseUrl: string, deviceCode: string, deadline: number, intervalMs: number, deps?: PollDeps): Promise<PollResult>;
21
+ export type LoopbackResult = {
22
+ status: "success";
23
+ clientKey: string;
24
+ clientSecret: string;
25
+ } | {
26
+ status: "denied";
27
+ message: string;
28
+ } | {
29
+ status: "timeout";
30
+ };
31
+ interface LoopbackHandle {
32
+ port: number;
33
+ result: Promise<LoopbackResult>;
34
+ close: () => void;
35
+ }
36
+ export declare function startLoopback(lifetimeMs: number, expectedState: string, createServerImpl?: typeof createServer): Promise<LoopbackHandle | null>;
37
+ interface AuthDeps {
38
+ openBrowser?: (url: string) => void;
39
+ createServer?: typeof createServer;
40
+ }
41
+ export default function addAuthTools(server: any, testingBotApi: any, config: TestingBotConfig, deps?: AuthDeps): Record<string, any>;
42
+ export {};
43
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAGpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAsHrF,MAAM,MAAM,UAAU,GAClB;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,GAChD;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MA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