@mablhq/mabl-cli 2.72.15 → 2.72.26
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/browserEngines/firefoxBrowserEngine.js +8 -0
- package/browserLauncher/index.js +3 -3
- package/commands/mcp/mcp_cmds/start.js +25 -29
- package/commands/mcp/mcp_cmds/tools/common.js +1 -61
- package/commands/mcp/mcp_cmds/tools/getWorkspaces.js +51 -0
- package/commands/mcp/mcp_cmds/tools/index.js +4 -0
- package/commands/mcp/mcp_cmds/tools/switchWorkspace.js +42 -0
- package/execution/index.js +2 -2
- package/mablscript/MablStepV2.js +0 -3
- package/mablscript/mobile/steps/stepUtil.js +2 -2
- package/mablscript/steps/EchoStep.js +3 -4
- package/mablscript/steps/IfConditionStep.js +3 -1
- package/package.json +4 -3
- package/providers/cliConfigProvider.js +2 -2
- package/proxy/index.js +1 -1
- package/upload/index.js +1 -1
|
@@ -11,9 +11,9 @@ const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
|
11
11
|
const tools_1 = __importDefault(require("./tools"));
|
|
12
12
|
const constants_1 = require("../../constants");
|
|
13
13
|
const createMablTestForCurrentWork_1 = require("./prompts/createMablTestForCurrentWork");
|
|
14
|
-
const common_1 = require("./tools/common");
|
|
15
14
|
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
16
15
|
const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
|
|
16
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
17
17
|
exports.command = 'start [options]';
|
|
18
18
|
exports.describe = 'Start the MCP server';
|
|
19
19
|
exports.builder = (yargs) => {
|
|
@@ -48,31 +48,18 @@ async function startServer(parsed) {
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, () => ({
|
|
51
|
-
tools: tools_1.default.map((tool) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
})),
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
name: tool.schema.name,
|
|
69
|
-
description: tool.schema.description,
|
|
70
|
-
inputSchema,
|
|
71
|
-
...(tool.schema.outputSchema
|
|
72
|
-
? { outputSchema: (0, common_1.zodSchemaToOpenApiSchema)(tool.schema.outputSchema) }
|
|
73
|
-
: {}),
|
|
74
|
-
};
|
|
75
|
-
}),
|
|
51
|
+
tools: tools_1.default.map((tool) => ({
|
|
52
|
+
name: tool.schema.name,
|
|
53
|
+
description: tool.schema.description,
|
|
54
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema.inputSchema, {
|
|
55
|
+
strictUnions: true,
|
|
56
|
+
}),
|
|
57
|
+
outputSchema: tool.schema.outputSchema
|
|
58
|
+
? (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema.outputSchema, {
|
|
59
|
+
strictUnions: true,
|
|
60
|
+
})
|
|
61
|
+
: undefined,
|
|
62
|
+
})),
|
|
76
63
|
}));
|
|
77
64
|
server.setRequestHandler(types_js_1.ListPromptsRequestSchema, () => ({
|
|
78
65
|
prompts: [createMablTestForCurrentWork_1.createMablTestPrompt],
|
|
@@ -87,7 +74,6 @@ async function startServer(parsed) {
|
|
|
87
74
|
throw new Error(`Unknown prompt: ${name}`);
|
|
88
75
|
});
|
|
89
76
|
let mablApiClient;
|
|
90
|
-
let workspaceId;
|
|
91
77
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
92
78
|
const { name } = request.params;
|
|
93
79
|
const tool = tools_1.default.find((t) => t.schema.name === name);
|
|
@@ -126,6 +112,7 @@ async function startServer(parsed) {
|
|
|
126
112
|
},
|
|
127
113
|
],
|
|
128
114
|
};
|
|
115
|
+
let workspaceId;
|
|
129
116
|
try {
|
|
130
117
|
workspaceId = await getWorkspaceId(parsed[constants_1.CommandArgWorkspaceId], parsed[constants_1.CommandArgApiKey], mablApiClient);
|
|
131
118
|
if (!workspaceId) {
|
|
@@ -138,6 +125,8 @@ async function startServer(parsed) {
|
|
|
138
125
|
const result = await tool.handle(args, mablApiClient, server, workspaceId);
|
|
139
126
|
return {
|
|
140
127
|
content: result.content,
|
|
128
|
+
structuredContent: result.structuredContent,
|
|
129
|
+
isError: result.isError,
|
|
141
130
|
};
|
|
142
131
|
}
|
|
143
132
|
catch (error) {
|
|
@@ -153,7 +142,14 @@ async function getWorkspaceId(workspaceId, apiKey, mablApiClient) {
|
|
|
153
142
|
return workspaceId;
|
|
154
143
|
}
|
|
155
144
|
if (apiKey) {
|
|
156
|
-
|
|
145
|
+
const apiKeyDetails = await mablApiClient.getApiKeyDetails();
|
|
146
|
+
return apiKeyDetails.workspace_id;
|
|
147
|
+
}
|
|
148
|
+
const currentWorkspace = await cliConfigProvider_1.CliConfigProvider.getWorkspace();
|
|
149
|
+
if (currentWorkspace?.id) {
|
|
150
|
+
return currentWorkspace.id;
|
|
157
151
|
}
|
|
158
|
-
|
|
152
|
+
await mablApiClient.getSelf();
|
|
153
|
+
const workspace = await cliConfigProvider_1.CliConfigProvider.getWorkspace();
|
|
154
|
+
return workspace?.id;
|
|
159
155
|
}
|
|
@@ -1,74 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stringToToolResult = stringToToolResult;
|
|
4
|
-
exports.zodSchemaToOpenApiSchema = zodSchemaToOpenApiSchema;
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
4
|
function stringToToolResult(value, isError = false) {
|
|
7
5
|
return {
|
|
8
6
|
content: [
|
|
9
7
|
{
|
|
10
8
|
type: 'text',
|
|
11
9
|
text: value,
|
|
12
|
-
isError,
|
|
13
10
|
},
|
|
14
11
|
],
|
|
12
|
+
isError,
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
|
-
function zodSchemaToOpenApiSchema(schema) {
|
|
18
|
-
if (schema instanceof zod_1.z.ZodArray) {
|
|
19
|
-
const element = schema.element;
|
|
20
|
-
if (element instanceof zod_1.z.ZodObject) {
|
|
21
|
-
const itemShape = element.shape;
|
|
22
|
-
return {
|
|
23
|
-
type: 'array',
|
|
24
|
-
items: {
|
|
25
|
-
type: 'object',
|
|
26
|
-
properties: Object.fromEntries(Object.entries(itemShape).map(([key, value]) => {
|
|
27
|
-
const description = value._def.description;
|
|
28
|
-
return [
|
|
29
|
-
key,
|
|
30
|
-
{
|
|
31
|
-
type: (() => {
|
|
32
|
-
if (value instanceof zod_1.z.ZodString) {
|
|
33
|
-
return 'string';
|
|
34
|
-
}
|
|
35
|
-
if (value instanceof zod_1.z.ZodNumber) {
|
|
36
|
-
return 'number';
|
|
37
|
-
}
|
|
38
|
-
if (value instanceof zod_1.z.ZodBoolean) {
|
|
39
|
-
return 'boolean';
|
|
40
|
-
}
|
|
41
|
-
if (value instanceof zod_1.z.ZodArray) {
|
|
42
|
-
return 'array';
|
|
43
|
-
}
|
|
44
|
-
if (value instanceof zod_1.z.ZodObject) {
|
|
45
|
-
return 'object';
|
|
46
|
-
}
|
|
47
|
-
return 'string';
|
|
48
|
-
})(),
|
|
49
|
-
description: description || '',
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
})),
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else if (schema instanceof zod_1.z.ZodObject) {
|
|
58
|
-
const shape = schema.shape;
|
|
59
|
-
return {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: Object.fromEntries(Object.entries(shape).map(([key, value]) => {
|
|
62
|
-
const description = value._def.description;
|
|
63
|
-
return [
|
|
64
|
-
key,
|
|
65
|
-
{
|
|
66
|
-
type: 'string',
|
|
67
|
-
description: description || '',
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
})),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mcpMablTool_1 = require("./mcpMablTool");
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const getWorkspaces = (0, mcpMablTool_1.defineTool)({
|
|
6
|
+
schema: {
|
|
7
|
+
name: 'get-workspaces',
|
|
8
|
+
title: 'Get all available workspaces',
|
|
9
|
+
description: 'Get all workspaces that the user has access to',
|
|
10
|
+
inputSchema: zod_1.z.object({
|
|
11
|
+
limit: zod_1.z
|
|
12
|
+
.number()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('The maximum number of workspaces to return (default: 50)'),
|
|
15
|
+
}),
|
|
16
|
+
outputSchema: zod_1.z.object({
|
|
17
|
+
workspaces: zod_1.z.array(zod_1.z.object({
|
|
18
|
+
id: zod_1.z.string().describe('The workspace ID'),
|
|
19
|
+
name: zod_1.z.string().describe('The workspace name'),
|
|
20
|
+
})),
|
|
21
|
+
currentWorkspaceId: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.describe('The currently active workspace ID'),
|
|
24
|
+
}),
|
|
25
|
+
type: 'readOnly',
|
|
26
|
+
},
|
|
27
|
+
handle: async (args, mablApiClient, _server, workspaceId) => {
|
|
28
|
+
const limit = args.limit || 50;
|
|
29
|
+
const workspaces = await mablApiClient.getWorkspaces(limit);
|
|
30
|
+
const workspaceList = workspaces.map((workspace) => ({
|
|
31
|
+
id: workspace.id,
|
|
32
|
+
name: workspace.name,
|
|
33
|
+
}));
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: 'text',
|
|
38
|
+
text: JSON.stringify({
|
|
39
|
+
workspaces: workspaceList,
|
|
40
|
+
currentWorkspaceId: workspaceId,
|
|
41
|
+
}, undefined, 2),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
structuredContent: {
|
|
45
|
+
workspaces: workspaceList,
|
|
46
|
+
currentWorkspaceId: workspaceId,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
exports.default = [getWorkspaces];
|
|
@@ -16,6 +16,8 @@ const createTest_1 = __importDefault(require("./createTest"));
|
|
|
16
16
|
const getPlans_1 = __importDefault(require("./getPlans"));
|
|
17
17
|
const getPlanRunResult_1 = __importDefault(require("./getPlanRunResult"));
|
|
18
18
|
const getLatestPlanRuns_1 = __importDefault(require("./getLatestPlanRuns"));
|
|
19
|
+
const getWorkspaces_1 = __importDefault(require("./getWorkspaces"));
|
|
20
|
+
const switchWorkspace_1 = __importDefault(require("./switchWorkspace"));
|
|
19
21
|
exports.default = [
|
|
20
22
|
...getApplications_1.default,
|
|
21
23
|
...getCredentials_1.default,
|
|
@@ -30,4 +32,6 @@ exports.default = [
|
|
|
30
32
|
...createTest_1.default,
|
|
31
33
|
...getPlanRunResult_1.default,
|
|
32
34
|
...getLatestPlanRuns_1.default,
|
|
35
|
+
...getWorkspaces_1.default,
|
|
36
|
+
...switchWorkspace_1.default,
|
|
33
37
|
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cliConfigProvider_1 = require("../../../../providers/cliConfigProvider");
|
|
4
|
+
const mcpMablTool_1 = require("./mcpMablTool");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const switchWorkspace = (0, mcpMablTool_1.defineTool)({
|
|
7
|
+
schema: {
|
|
8
|
+
name: 'switch-workspace',
|
|
9
|
+
title: 'Switch the current workspace',
|
|
10
|
+
description: 'Switch to a different workspace by providing a workspace ID',
|
|
11
|
+
inputSchema: zod_1.z.object({
|
|
12
|
+
workspaceId: zod_1.z.string().describe('The ID of the workspace to switch to'),
|
|
13
|
+
}),
|
|
14
|
+
type: 'destructive',
|
|
15
|
+
},
|
|
16
|
+
handle: async (args, mablApiClient, _server, _currentWorkspaceId) => {
|
|
17
|
+
const { workspaceId: newWorkspaceId } = args;
|
|
18
|
+
try {
|
|
19
|
+
const workspace = await mablApiClient.getWorkspace(newWorkspaceId);
|
|
20
|
+
await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: `Successfully switched workspace to "${workspace.name}" (${newWorkspaceId})`,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: 'text',
|
|
35
|
+
text: `Failed to switch workspace: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
exports.default = [switchWorkspace];
|