@skyramp/mcp 0.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 +163 -0
- package/build/index.js +55 -0
- package/build/prompts/startTraceCollectionPrompts.js +54 -0
- package/build/prompts/stopTraceCollectionPrompts.js +113 -0
- package/build/prompts/testGenerationPrompt.js +374 -0
- package/build/services/TestGenerationService.js +138 -0
- package/build/tools/executeSkyrampTestTool.js +107 -0
- package/build/tools/generateContractRestTool.js +34 -0
- package/build/tools/generateE2ERestTool.js +34 -0
- package/build/tools/generateFuzzRestTool.js +32 -0
- package/build/tools/generateIntegrationRestTool.js +29 -0
- package/build/tools/generateLoadRestTool.js +61 -0
- package/build/tools/generateSmokeRestTool.js +23 -0
- package/build/tools/generateUIRestTool.js +37 -0
- package/build/tools/startTraceCollectionTool.js +79 -0
- package/build/tools/stopTraceCollectionTool.js +86 -0
- package/build/types/TestTypes.js +101 -0
- package/build/utils/analyze-openapi.js +25 -0
- package/build/utils/logger.js +38 -0
- package/build/utils/proxy-terminal.js +439 -0
- package/build/utils/utils.js +118 -0
- package/build/utils/utils.test.js +32 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# mcp
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This project implements an MCP (Model Context Protocol) server for Skyramp, providing prompt-driven guidance and automated test generation for REST APIs. The server is modular and extensible, supporting multiple test types and custom prompts.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Prompt-driven user guidance** for Skyramp test generation, following best practices.
|
|
10
|
+
- **Automated test generation tools** for:
|
|
11
|
+
- Smoke tests
|
|
12
|
+
- Fuzz tests
|
|
13
|
+
- Contract tests
|
|
14
|
+
- Load tests
|
|
15
|
+
- Integration tests
|
|
16
|
+
- UI tests (with Playwright support for browser automation)
|
|
17
|
+
- E2E tests (combining backend Skyramp trace collection and frontend UI automation using Playwright)
|
|
18
|
+
- **OpenAPI awareness**: Prompts can reference OpenAPI files found in your workspace.
|
|
19
|
+
|
|
20
|
+
## Development
|
|
21
|
+
|
|
22
|
+
1. **Install dependencies:**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. **Build the project:**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run build
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. **Start the MCP server:**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
node build/index.js
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
4. **Debug and inspect using Model Context Inspector:**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx @modelcontextprotocol/inspector node build/index.js
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
5. **Configure MCP server for cursor/vscode for local testing**
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"skyramp": {
|
|
52
|
+
"command": "node",
|
|
53
|
+
"args": [
|
|
54
|
+
"<absolute_path_of_project>/mcp/build/index.js"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Note:- this is just for local testing
|
|
62
|
+
|
|
63
|
+
## Setup
|
|
64
|
+
|
|
65
|
+
To run the MCP server using npx, use the following command:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx -y @skyramp/mcp@latest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage with Cursor, VScode or Claude Desktop
|
|
72
|
+
|
|
73
|
+
Add the following configuration. For more information, read the [Cursor MCP documentation](https://docs.cursor.com/context/model-context-protocol) or the [Claude Desktop MCP guide](https://modelcontextprotocol.io/quickstart/user).
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"skyramp-mcp": {
|
|
79
|
+
"command": "npx",
|
|
80
|
+
"args": ["-y", "@skyramp/mcp@latest"]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
[](https://cursor.com/install-mcp?name=skyramp-mcp&config=eyJjb21tYW5kIjoibnB4IC15IEBza3lyYW1wL21jcEBsYXRlc3QifQ==)
|
|
87
|
+
|
|
88
|
+
**For Claude Desktop, you must set the `HOME` environment variable in your MCP server configuration.**
|
|
89
|
+
|
|
90
|
+
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
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"skyramp-mcp": {
|
|
96
|
+
"command": "npx",
|
|
97
|
+
"args": ["-y", "@skyramp/mcp@latest"],
|
|
98
|
+
"env": {
|
|
99
|
+
"HOME": "/path/to/your/home"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Replace `/path/to/your/home` with the actual directory you want to use. This ensures the MCP server can properly generate and execute tests in the desired location.
|
|
107
|
+
|
|
108
|
+
On Windows, you might need to use this alternative configuration:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"skyramp-mcp": {
|
|
114
|
+
"command": "cmd",
|
|
115
|
+
"args": ["/k", "npx", "-y", "@skyramp/mcp@latest"]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
[](https://cursor.com/install-mcp?name=skyramp-mcp&config=eyJjb21tYW5kIjoiY21kIC9rIG5weCAteSBAc2t5cmFtcC9tY3BAbGF0ZXN0In0=)
|
|
122
|
+
|
|
123
|
+
## Available tools
|
|
124
|
+
|
|
125
|
+
This MCP server provides the following tools:
|
|
126
|
+
|
|
127
|
+
| Tool Name | Description |
|
|
128
|
+
| ----------------------------------- | ---------------------------- |
|
|
129
|
+
| skyramp_smoke_test_generation | Generate a smoke test |
|
|
130
|
+
| skyramp_fuzz_test_generation | Generate a fuzz test |
|
|
131
|
+
| skyramp_contract_test_generation | Generate a contract test |
|
|
132
|
+
| skyramp_load_test_generation | Generate a load test |
|
|
133
|
+
| skyramp_integration_test_generation | Generate an integration test |
|
|
134
|
+
| skyramp_e2e_test_generation | Generate an E2E test |
|
|
135
|
+
| skyramp_ui_test_generation | Generate an UI test |
|
|
136
|
+
| skyramp_start_trace_generation | Start trace collection |
|
|
137
|
+
| skyramp_stop_trace_generation | Stop trace collection |
|
|
138
|
+
| skyramp_execute_test | Execute a Skyramp test |
|
|
139
|
+
|
|
140
|
+
## Available prompts
|
|
141
|
+
|
|
142
|
+
This MCP server provides the following prompts:
|
|
143
|
+
|
|
144
|
+
| Prompt Name | Description |
|
|
145
|
+
| ------------------------------------ | -------------------------------------- |
|
|
146
|
+
| skyramp_test_generation_prompt | Guidance for generating Skyramp tests |
|
|
147
|
+
| skyramp_trace_prompt | Guidance for starting trace collection |
|
|
148
|
+
| skyramp_stop_trace_collection_prompt | Guidance for stopping trace collection |
|
|
149
|
+
|
|
150
|
+
## How it Works
|
|
151
|
+
|
|
152
|
+
- The server registers a Skyramp prompt (see `src/prompts/skyrampPrompts.ts`) that guides users through test generation and answers questions about Skyramp.
|
|
153
|
+
- Test generation tools for smoke, fuzz, contract, load, and integration tests are registered and available for use.
|
|
154
|
+
- The server communicates over stdio, making it suitable for CLI or integration with other tools.
|
|
155
|
+
|
|
156
|
+
## Documentation
|
|
157
|
+
|
|
158
|
+
- Skyramp documentation: [https://skyramp.dev/docs](https://skyramp.dev/docs)
|
|
159
|
+
- Model Context Protocol: [https://modelcontextprotocol.io](https://modelcontextprotocol.io)
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
For questions or contributions, please open an issue or pull request.
|
package/build/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { registerStartTraceCollectionPrompt } from "./prompts/startTraceCollectionPrompts.js";
|
|
5
|
+
import { registerTraceTool } from "./tools/startTraceCollectionTool.js";
|
|
6
|
+
import { registerTraceStopTool } from "./tools/stopTraceCollectionTool.js";
|
|
7
|
+
import { registerExecuteSkyrampTestTool } from "./tools/executeSkyrampTestTool.js";
|
|
8
|
+
import { registerStopTraceCollectionPrompt } from "./prompts/stopTraceCollectionPrompts.js";
|
|
9
|
+
import { registerTestGenerationPrompt } from "./prompts/testGenerationPrompt.js";
|
|
10
|
+
import { logger } from "./utils/logger.js";
|
|
11
|
+
import { registerUITestTool } from "./tools/generateUIRestTool.js";
|
|
12
|
+
import { registerSmokeTestTool } from "./tools/generateSmokeRestTool.js";
|
|
13
|
+
import { registerFuzzTestTool } from "./tools/generateFuzzRestTool.js";
|
|
14
|
+
import { registerContractTestTool } from "./tools/generateContractRestTool.js";
|
|
15
|
+
import { registerLoadTestTool } from "./tools/generateLoadRestTool.js";
|
|
16
|
+
import { registerIntegrationTestTool } from "./tools/generateIntegrationRestTool.js";
|
|
17
|
+
import { registerEndtoEndTestTool } from "./tools/generateE2ERestTool.js";
|
|
18
|
+
const server = new McpServer({
|
|
19
|
+
name: "Skyramp MCP Server",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
capabilities: {
|
|
22
|
+
resources: {},
|
|
23
|
+
tools: {},
|
|
24
|
+
prompts: {},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// Register prompts
|
|
28
|
+
registerTestGenerationPrompt(server);
|
|
29
|
+
registerStartTraceCollectionPrompt(server);
|
|
30
|
+
registerStopTraceCollectionPrompt(server);
|
|
31
|
+
// Register test generation tools
|
|
32
|
+
registerSmokeTestTool(server);
|
|
33
|
+
registerFuzzTestTool(server);
|
|
34
|
+
registerContractTestTool(server);
|
|
35
|
+
registerLoadTestTool(server);
|
|
36
|
+
registerIntegrationTestTool(server);
|
|
37
|
+
registerEndtoEndTestTool(server);
|
|
38
|
+
registerUITestTool(server);
|
|
39
|
+
// Register other Skyramp tools
|
|
40
|
+
registerExecuteSkyrampTestTool(server);
|
|
41
|
+
registerTraceTool(server);
|
|
42
|
+
registerTraceStopTool(server);
|
|
43
|
+
// Start MCP server
|
|
44
|
+
async function main() {
|
|
45
|
+
const transport = new StdioServerTransport();
|
|
46
|
+
await server.connect(transport);
|
|
47
|
+
logger.info("MCP Server started successfully");
|
|
48
|
+
}
|
|
49
|
+
main().catch((error) => {
|
|
50
|
+
logger.critical("Fatal error in main()", {
|
|
51
|
+
error: error.message,
|
|
52
|
+
stack: error.stack,
|
|
53
|
+
});
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/prompts/skyrampPrompt.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
// read env variable and use it to set custom prompt
|
|
5
|
+
const isDockerEnv = process.env.MCP_SERVER_RUNTIME === "docker";
|
|
6
|
+
logger.info("MCP server runtime environment", { isDockerEnv });
|
|
7
|
+
export function registerStartTraceCollectionPrompt(mcpServer) {
|
|
8
|
+
mcpServer.prompt("skyramp_trace_prompt", "Skyramp trace collection prompt", {
|
|
9
|
+
include: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe("Comma-separated list of URLs to include in the trace."),
|
|
12
|
+
exclude: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Comma-separated list of URLs to exclude."),
|
|
16
|
+
noProxy: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Comma-separated list of noProxy values."),
|
|
20
|
+
runtime: z
|
|
21
|
+
.string()
|
|
22
|
+
.describe("Runtime environment for trace collection. Docker is supported for trace collection."),
|
|
23
|
+
dockerNetwork: z.string().optional(),
|
|
24
|
+
dockerWorkerPort: z.string().optional(),
|
|
25
|
+
playwright: z.string(),
|
|
26
|
+
}, ({ include, exclude, noProxy, runtime, dockerNetwork, dockerWorkerPort, playwright, }) => ({
|
|
27
|
+
messages: [
|
|
28
|
+
{
|
|
29
|
+
role: "user",
|
|
30
|
+
content: {
|
|
31
|
+
type: "text",
|
|
32
|
+
text: `Information about trace generation:
|
|
33
|
+
|
|
34
|
+
**General information about Skyramp's trace generation:**
|
|
35
|
+
* You can start a Skyramp trace session to capture network traffic from an active terminal window and for activity within a browser.
|
|
36
|
+
* Once you start a Skyramp trace session, you can stop it any time. Once stopped, a new session will be required to start a new trace collection.
|
|
37
|
+
* Please refer to the Skyramp documentation at https://www.skyramp.dev/docs/concepts/trace-collection for more details on trace collection.
|
|
38
|
+
* DO NOT assume the runtime environment for trace collection.
|
|
39
|
+
* Spawn a new terminal shell to start a trace collection in the same IDE window.
|
|
40
|
+
* Once you have all the data call the start trace generation tool to start the trace collection.
|
|
41
|
+
*Always ask user if they want to enable playwright for trace collection.
|
|
42
|
+
|
|
43
|
+
**Example usage prompt for trace collection:**
|
|
44
|
+
* To start a trace collection session using agent, run the following command:
|
|
45
|
+
Generate trace with default settings and include realworld.demo.com:8080
|
|
46
|
+
|
|
47
|
+
**Example usage prompt for trace collection for playwright trace:**
|
|
48
|
+
* To start a playwright trace collection session using agent, run the following command:
|
|
49
|
+
Start playwright trace collection with default settings.`,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// Utility function to resolve paths to absolute
|
|
4
|
+
function resolveToAbsolutePath(filePath, cwd) {
|
|
5
|
+
if (path.isAbsolute(filePath)) {
|
|
6
|
+
return filePath;
|
|
7
|
+
}
|
|
8
|
+
return path.resolve(cwd, filePath);
|
|
9
|
+
}
|
|
10
|
+
export function registerStopTraceCollectionPrompt(mcpServer) {
|
|
11
|
+
mcpServer.prompt("skyramp_stop_trace_collection_prompt", "Skyramp stop trace collection prompt", {
|
|
12
|
+
traceOutputFile: z
|
|
13
|
+
.string()
|
|
14
|
+
.describe("Path to the trace collection output file (relative or absolute). If relative, it will be resolved relative to the current IDE/project directory."),
|
|
15
|
+
currentWorkingDirectory: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe("The current working directory from the IDE/client context. This is REQUIRED for resolving relative paths to absolute paths."),
|
|
18
|
+
playwright: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Whether to use playwright for trace collection. If not provided, it will be set to false."),
|
|
22
|
+
playwrightOutput: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Path to the playwright output file (relative or absolute). If relative, it will be resolved relative to the current IDE/project directory. If playwright is enabled, this will be the path to the playwright output file. If playwright is disabled, this will be empty."),
|
|
26
|
+
}, ({ traceOutputFile, currentWorkingDirectory, playwright, playwrightOutput, }) => {
|
|
27
|
+
// Validate currentWorkingDirectory is provided
|
|
28
|
+
if (!currentWorkingDirectory || currentWorkingDirectory.trim() === "") {
|
|
29
|
+
return {
|
|
30
|
+
messages: [
|
|
31
|
+
{
|
|
32
|
+
role: "user",
|
|
33
|
+
content: {
|
|
34
|
+
type: "text",
|
|
35
|
+
text: `**ERROR: Current working directory is required**
|
|
36
|
+
|
|
37
|
+
The currentWorkingDirectory parameter is required to resolve relative paths to absolute paths. Please ensure your IDE/client provides the current working directory context.
|
|
38
|
+
|
|
39
|
+
**Expected Parameters:**
|
|
40
|
+
- traceOutputFile: "${traceOutputFile}"
|
|
41
|
+
- currentWorkingDirectory: [REQUIRED - NOT PROVIDED]
|
|
42
|
+
- playwright: ${playwright || "false"}
|
|
43
|
+
- playwrightOutput: "${playwrightOutput || ""}"
|
|
44
|
+
|
|
45
|
+
**Resolution:** The IDE/client must provide the currentWorkingDirectory parameter to resolve relative paths properly.`,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Resolve paths to absolute
|
|
52
|
+
const absoluteTraceOutputFile = resolveToAbsolutePath(traceOutputFile, currentWorkingDirectory);
|
|
53
|
+
const absolutePlaywrightOutput = playwrightOutput
|
|
54
|
+
? resolveToAbsolutePath(playwrightOutput, currentWorkingDirectory)
|
|
55
|
+
: "";
|
|
56
|
+
return {
|
|
57
|
+
messages: [
|
|
58
|
+
{
|
|
59
|
+
role: "user",
|
|
60
|
+
content: {
|
|
61
|
+
type: "text",
|
|
62
|
+
text: `Information about trace generation:
|
|
63
|
+
**General information about Skyramp's trace collection:**
|
|
64
|
+
* You can start a Skyramp trace session to capture network traffic from an active terminal window and for activity within a browser.
|
|
65
|
+
* Once you start a Skyramp trace session, you can stop it any time. Once stopped, a new session will be required to start a new trace collection.
|
|
66
|
+
* Please refer to the Skyramp documentation at https://www.skyramp.dev/docs/concepts/trace-collection for more details on trace collection.
|
|
67
|
+
|
|
68
|
+
**CRITICAL: You MUST use the following absolute paths for all tool calls:**
|
|
69
|
+
|
|
70
|
+
**Path Resolution Summary:**
|
|
71
|
+
- Original traceOutputFile: "${traceOutputFile}"
|
|
72
|
+
- Current working directory: "${currentWorkingDirectory}"
|
|
73
|
+
- Resolved absolute traceOutputFile: "${absoluteTraceOutputFile}"
|
|
74
|
+
${playwrightOutput ? `- Original playwrightOutput: "${playwrightOutput}"` : ""}
|
|
75
|
+
${playwrightOutput
|
|
76
|
+
? `- Resolved absolute playwrightOutput: "${absolutePlaywrightOutput}"`
|
|
77
|
+
: ""}
|
|
78
|
+
|
|
79
|
+
**Required Absolute Paths for Tool Calls:**
|
|
80
|
+
1. **traceOutputFile parameter**: MUST use exactly this absolute path: "${absoluteTraceOutputFile}"
|
|
81
|
+
2. **playwrightOutput parameter**: ${playwrightOutput
|
|
82
|
+
? `MUST use exactly this absolute path: "${absolutePlaywrightOutput}"`
|
|
83
|
+
: "Not applicable (playwright disabled)"}
|
|
84
|
+
3. **playwright parameter**: ${playwright === "true" ? "true" : "false"}
|
|
85
|
+
|
|
86
|
+
**IMPORTANT: Path Resolution Instructions:**
|
|
87
|
+
- The paths above have been automatically resolved from relative to absolute paths
|
|
88
|
+
- You MUST use these exact absolute paths in all tool calls - do not modify them
|
|
89
|
+
- DO NOT attempt to resolve paths yourself - use the provided absolute paths exactly as shown
|
|
90
|
+
- DO NOT use the original relative paths provided by the user
|
|
91
|
+
|
|
92
|
+
**Tool Call Requirements:**
|
|
93
|
+
When calling skyramp_stop_trace_generation, you MUST use:
|
|
94
|
+
- traceOutputFile: "${absoluteTraceOutputFile}" (this exact absolute path)
|
|
95
|
+
- playwright: ${playwright === "true" ? "true" : "false"}
|
|
96
|
+
- playwrightOutput: "${absolutePlaywrightOutput}" ${!playwrightOutput
|
|
97
|
+
? "(empty string if playwright is false)"
|
|
98
|
+
: "(this exact absolute path)"}
|
|
99
|
+
|
|
100
|
+
**Example Tool Call:**
|
|
101
|
+
\`\`\`
|
|
102
|
+
skyramp_stop_trace_generation({
|
|
103
|
+
traceOutputFile: "${absoluteTraceOutputFile}",
|
|
104
|
+
playwright: ${playwright === "true" ? "true" : "false"},
|
|
105
|
+
playwrightOutput: "${absolutePlaywrightOutput}"
|
|
106
|
+
})
|
|
107
|
+
\`\`\``,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|