@skyramp/mcp 0.0.3 → 0.0.4
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 +5 -3
- package/build/prompts/startTraceCollectionPrompts.js +1 -0
- package/build/prompts/testGenerationPrompt.js +2 -9
- package/build/services/TestGenerationService.js +96 -15
- package/build/tools/executeSkyrampTestTool.js +5 -3
- package/build/types/TestTypes.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,9 +83,11 @@ Add the following configuration. For more information, read the [Cursor MCP docu
|
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
[](https://cursor.com/install-mcp?name=skyramp-mcp&config=eyJjb21tYW5kIjoibnB4IC15IEBza3lyYW1wL21jcEBsYXRlc3QifQ==)
|
|
86
|
+
[](https://cursor.com/install-mcp?name=skyramp-mcp&config=eyJjb21tYW5kIjoibnB4IC15IEBza3lyYW1wL21jcEBsYXRlc3QifQ==)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
### Note: To pull latest changes restart the MCP server
|
|
89
|
+
|
|
90
|
+
### For Claude Desktop, you must set the `HOME` environment variable in your MCP server configuration
|
|
89
91
|
|
|
90
92
|
This is required because some tools expect a valid home directory for file operations. Set `HOME` to the path where you want Skyramp to generate and execute tests. For example:
|
|
91
93
|
|
|
@@ -118,7 +120,7 @@ On Windows, you might need to use this alternative configuration:
|
|
|
118
120
|
}
|
|
119
121
|
```
|
|
120
122
|
|
|
121
|
-
[](https://cursor.com/install-mcp?name=skyramp-mcp&config=eyJjb21tYW5kIjoiY21kIC9rIG5weCAteSBAc2t5cmFtcC9tY3BAbGF0ZXN0In0=)
|
|
123
|
+
[](https://cursor.com/install-mcp?name=skyramp-mcp&config=eyJjb21tYW5kIjoiY21kIC9rIG5weCAteSBAc2t5cmFtcC9tY3BAbGF0ZXN0In0=)
|
|
122
124
|
|
|
123
125
|
## Available tools
|
|
124
126
|
|
|
@@ -5,6 +5,7 @@ import { logger } from "../utils/logger.js";
|
|
|
5
5
|
const isDockerEnv = process.env.MCP_SERVER_RUNTIME === "docker";
|
|
6
6
|
logger.info("MCP server runtime environment", { isDockerEnv });
|
|
7
7
|
export function registerStartTraceCollectionPrompt(mcpServer) {
|
|
8
|
+
logger.info("registering start trace collection prompt");
|
|
8
9
|
mcpServer.prompt("skyramp_trace_prompt", "Skyramp trace collection prompt", {
|
|
9
10
|
include: z
|
|
10
11
|
.string()
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
// src/prompts/skyrampPrompt.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
2
|
import { logger } from "../utils/logger.js";
|
|
4
3
|
// read env variable and use it to set custom prompt
|
|
5
4
|
const isDockerEnv = process.env.MCP_SERVER_RUNTIME === "docker";
|
|
6
5
|
logger.info("MCP server runtime environment", { isDockerEnv });
|
|
7
6
|
export function registerTestGenerationPrompt(mcpServer) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
outputDir: z.string().optional(),
|
|
11
|
-
trace: z.string().optional().describe("MUST be absolute path"),
|
|
12
|
-
playwrightTrace: z.string().optional().describe("MUST be absolute path"),
|
|
13
|
-
schemaInput: z.string().optional().describe("MUST be absolute path"),
|
|
14
|
-
parameters: z.string().optional(),
|
|
15
|
-
}, ({ endpointURL, outputDir, trace, playwrightTrace, schemaInput, parameters, }) => ({
|
|
7
|
+
logger.info("test generation prompt");
|
|
8
|
+
mcpServer.prompt("skyramp_test_generation_prompt", "Skyramp test generation prompt", {}, () => ({
|
|
16
9
|
messages: [
|
|
17
10
|
{
|
|
18
11
|
role: "user",
|
|
@@ -18,30 +18,111 @@ export class TestGenerationService {
|
|
|
18
18
|
return apiAnalysisResult;
|
|
19
19
|
}
|
|
20
20
|
const result = await this.executeGeneration(generateOptions);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
let modularizedResultPrompt = `
|
|
22
|
+
**IMPORTANT: Now please modularize the code by**
|
|
23
|
+
|
|
24
|
+
1. Group related lines logically (e.g., login steps together) to improve readability.
|
|
25
|
+
2. Parameterize the test function(s) with meaningful parameters to make it more flexible. Preserve the original order of code lines within each function
|
|
26
|
+
3. Do not change or remove any existing lines of code, variable names, function names, or function structures.
|
|
27
|
+
4. Only extract reusable logical sections into helper functions or parameterized structures where applicable.
|
|
28
|
+
5. Do not create any new test cases but only helper functions.
|
|
29
|
+
6. Make sure the logic is same and the test works as expected.
|
|
30
|
+
7. Do not add any new logic or classes or any other files.
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
Please refactor the code with these modularization principles.
|
|
33
|
+
`;
|
|
34
|
+
let languageSteps = "";
|
|
35
|
+
switch (params.language) {
|
|
36
|
+
case "python":
|
|
37
|
+
// python steps
|
|
38
|
+
languageSteps += `
|
|
39
|
+
# Install skyramp dependency
|
|
40
|
+
pip3 install skyramp
|
|
41
|
+
`;
|
|
42
|
+
// e2e and ui tests
|
|
43
|
+
if (params.testType == "e2e" || params.testType == "ui") {
|
|
44
|
+
languageSteps += `
|
|
45
|
+
# Install playwright dependencies
|
|
46
|
+
pip3 install pytest-playwright
|
|
47
|
+
# Execute the test file
|
|
48
|
+
python3 -m pytest --browser chromium <test-file>.py
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
//framework pytest
|
|
52
|
+
languageSteps += `
|
|
53
|
+
# Install pytest dependency
|
|
54
|
+
pip3 install pytest
|
|
29
55
|
|
|
30
|
-
|
|
56
|
+
# Execution test file
|
|
57
|
+
python3 -m pytest <test-file>.py
|
|
58
|
+
`;
|
|
59
|
+
// robot framework
|
|
60
|
+
languageSteps += `
|
|
61
|
+
# Install robotframework dependency
|
|
62
|
+
pip3 install robotframework
|
|
31
63
|
|
|
32
|
-
|
|
64
|
+
# Execution of test file
|
|
65
|
+
python3 -m robot <robot-file>.robot
|
|
66
|
+
`;
|
|
67
|
+
break;
|
|
68
|
+
case "javascript":
|
|
69
|
+
languageSteps += `
|
|
70
|
+
# install dependencies for package.json
|
|
71
|
+
npm install @skyramp/skyramp @playwright/test
|
|
33
72
|
|
|
34
|
-
|
|
73
|
+
# Execution of test file
|
|
74
|
+
npx playwright test <test-file>.spec.js --reporter=list
|
|
75
|
+
`;
|
|
76
|
+
break;
|
|
77
|
+
case "typescript":
|
|
78
|
+
languageSteps += `
|
|
79
|
+
# install dependencies for package.json
|
|
80
|
+
npm install @skyramp/skyramp @playwright/test
|
|
35
81
|
|
|
36
|
-
|
|
82
|
+
# Execution of test file
|
|
83
|
+
npx playwright test <test-file>.spec.ts --reporter=list
|
|
84
|
+
`;
|
|
85
|
+
break;
|
|
86
|
+
case "java":
|
|
87
|
+
languageSteps += `
|
|
88
|
+
# Prerequisites
|
|
89
|
+
# Compile the test file
|
|
90
|
+
javac -cp "./lib/*" -d target <test-file>.java
|
|
37
91
|
|
|
38
|
-
|
|
92
|
+
# Execution of test file
|
|
93
|
+
JUNIT_PLATFORM_VER="1.9.3"
|
|
94
|
+
classpath="target:$(echo ./lib/*.jar | tr ' ' ':')"
|
|
95
|
+
java -jar "./lib/junit-platform-console-standalone-\${JUNIT_PLATFORM_VER}.jar" \\
|
|
96
|
+
--classpath "\$classpath" \\
|
|
97
|
+
--include-engine=junit-jupiter \\
|
|
98
|
+
--select-class=<test-file> \\
|
|
99
|
+
--reports-dir=target/test-results
|
|
100
|
+
`;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
let isError = false;
|
|
104
|
+
// check the result include 'Successfully generated/updated tests files:'
|
|
105
|
+
if (!result.includes("Successfully generated/updated tests files:")) {
|
|
106
|
+
isError = true;
|
|
107
|
+
}
|
|
108
|
+
const testType = this.getTestType();
|
|
109
|
+
const shouldModularize = testType == "ui" || testType == "e2e";
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
text: `${shouldModularize
|
|
115
|
+
? "Generated the test and WILL NOW MODULARIZE THE CODE USING THE FOLLOWING MODULARIZATION PRINCIPLES"
|
|
116
|
+
: "Generated the test and DO NOT MODULARIZE THE CODE"}
|
|
117
|
+
${result} ${shouldModularize ? modularizedResultPrompt : ""}
|
|
118
|
+
${languageSteps}
|
|
39
119
|
|
|
40
|
-
|
|
41
|
-
|
|
120
|
+
- Notify the user that they can also use **Execute with Skyramp** tool to run the test. If this is your first test you are trying to execute with Skyramp, it may take a little bit longer than usual.
|
|
121
|
+
- Before I can execute the test for you, I need to confirm the following information:
|
|
122
|
+
Authentication: Please provide me with your authentication token (by default we assume a Bearer Token). If you don't require any token for your service please just say: 'No token required'`,
|
|
42
123
|
},
|
|
43
124
|
],
|
|
44
|
-
isError:
|
|
125
|
+
isError: isError,
|
|
45
126
|
};
|
|
46
127
|
}
|
|
47
128
|
catch (error) {
|
|
@@ -13,7 +13,9 @@ const LANGUAGE_PATHS = {
|
|
|
13
13
|
export function registerExecuteSkyrampTestTool(server) {
|
|
14
14
|
server.registerTool("skyramp_execute_test", {
|
|
15
15
|
description: `Execute a Skyramp test to validate your application using isolated containerized environments.
|
|
16
|
-
|
|
16
|
+
IMPORTANT: Follow the instructions below to execute the test.
|
|
17
|
+
- Notify the user that the first time the tool is used, it will take some time to pull the image.
|
|
18
|
+
- Before I can execute the test for you, I need to confirm the following information:
|
|
17
19
|
Authentication: Please provide me with your authentication token (by default we assume a Bearer Token). If you don't require any token for your service please just say: 'No token required'`,
|
|
18
20
|
inputSchema: {
|
|
19
21
|
language: z
|
|
@@ -27,7 +29,7 @@ export function registerExecuteSkyrampTestTool(server) {
|
|
|
27
29
|
.describe("ALWAYS USE ABSOLUTE PATH to the test file to execute"),
|
|
28
30
|
token: z
|
|
29
31
|
.string()
|
|
30
|
-
.describe("Skyramp authentication token for test execution.
|
|
32
|
+
.describe("Skyramp authentication token for test execution. USE EMPTY STRING WHEN USER CONFIRMS 'No token required'"),
|
|
31
33
|
},
|
|
32
34
|
annotations: {
|
|
33
35
|
keywords: ["run test", "execute test"],
|
|
@@ -98,7 +100,7 @@ export function registerExecuteSkyrampTestTool(server) {
|
|
|
98
100
|
stream.end();
|
|
99
101
|
statusCode = result.StatusCode;
|
|
100
102
|
logger.debug("Docker container execution completed");
|
|
101
|
-
return container
|
|
103
|
+
return container;
|
|
102
104
|
})
|
|
103
105
|
.then(function (data) {
|
|
104
106
|
logger.debug("Docker container removed successfully");
|
package/build/types/TestTypes.js
CHANGED
|
@@ -73,7 +73,7 @@ export const baseTestSchema = {
|
|
|
73
73
|
method: z
|
|
74
74
|
.string()
|
|
75
75
|
.optional()
|
|
76
|
-
.describe("HTTP method to use (GET, POST, PUT, DELETE, etc.)"),
|
|
76
|
+
.describe("HTTP method to use (GET, POST, PUT, DELETE, etc.). DO NOT ASSUME METHOD IF NOT PROVIDED AND TRY TO DETECT THE METHOD FROM OPENAPI SCHEMA"),
|
|
77
77
|
apiSchema: z
|
|
78
78
|
.string()
|
|
79
79
|
.optional()
|
|
@@ -97,5 +97,5 @@ export const baseTestSchema = {
|
|
|
97
97
|
responseStatusCode: z
|
|
98
98
|
.string()
|
|
99
99
|
.optional()
|
|
100
|
-
.describe("Expected HTTP response status code (e.g., '200', '201', '404')"),
|
|
100
|
+
.describe("Expected HTTP response status code (e.g., '200', '201', '404'). DO NOT ASSUME STATUS CODE IF NOT PROVIDED AND TRY TO DETECT THE STATUS CODE FROM OPENAPI SCHEMA"),
|
|
101
101
|
};
|