magicpod-mcp-server 0.1.2 → 0.1.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/build/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { initMagicPodApiProxy } from "./tools/magicpod-web-api.js";
|
|
|
7
7
|
import { apiV1_0UploadFileCreate } from "./tools/api-v1-0-upload-file-create.js";
|
|
8
8
|
const program = new Command();
|
|
9
9
|
program.option("--api-token <key>", "MagicPod API token to use");
|
|
10
|
+
program.option("--debug", "For internal debug use");
|
|
10
11
|
program.parse(process.argv);
|
|
11
12
|
const options = program.opts();
|
|
12
13
|
if (!options.apiToken) {
|
|
@@ -14,7 +15,8 @@ if (!options.apiToken) {
|
|
|
14
15
|
process.exit(1);
|
|
15
16
|
}
|
|
16
17
|
async function main() {
|
|
17
|
-
const
|
|
18
|
+
const baseUrlEnvironmentVariable = options.debug ? process.env.BASE_URL : undefined;
|
|
19
|
+
const baseUrl = baseUrlEnvironmentVariable || "https://app.magicpod.com";
|
|
18
20
|
const proxy = await initMagicPodApiProxy(baseUrl, options.apiToken, [
|
|
19
21
|
apiV1_0UploadFileCreate(baseUrl, options.apiToken),
|
|
20
22
|
searchMagicpodArticles(),
|
|
@@ -12,7 +12,7 @@ export class MCPProxy {
|
|
|
12
12
|
openApiLookup;
|
|
13
13
|
constructor(name, openApiSpec, apiToken, otherTools) {
|
|
14
14
|
this.otherTools = otherTools;
|
|
15
|
-
this.server = new Server({ name, version: "0.1.
|
|
15
|
+
this.server = new Server({ name, version: "0.1.4" }, { capabilities: { tools: {} } });
|
|
16
16
|
const baseUrl = openApiSpec.servers?.[0].url;
|
|
17
17
|
if (!baseUrl) {
|
|
18
18
|
throw new Error("No base URL found in OpenAPI spec");
|
|
@@ -84,7 +84,7 @@ export class MCPProxy {
|
|
|
84
84
|
// to reduce the tool list response size
|
|
85
85
|
// TODO description is actually required
|
|
86
86
|
const inputSchema = JSON.parse(JSON.stringify(method.inputSchema));
|
|
87
|
-
|
|
87
|
+
this.removeDescriptions(inputSchema);
|
|
88
88
|
// 95% of the response size is consumed by $defs
|
|
89
89
|
const body = method.inputSchema.properties?.body;
|
|
90
90
|
if (body == null || typeof body === "boolean") {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const generateTestCase = () => {
|
|
2
|
+
return {
|
|
3
|
+
name: "generate-test-case",
|
|
4
|
+
description: "Generate a new test case on MagicPod",
|
|
5
|
+
arguments: [
|
|
6
|
+
{
|
|
7
|
+
name: "organizationName",
|
|
8
|
+
description: "An organization name",
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "projectName",
|
|
13
|
+
description: "A project name",
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "prompt",
|
|
18
|
+
description: "A prompt to generate a test case",
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
handleRequest: async (request) => {
|
|
23
|
+
return {
|
|
24
|
+
messages: [
|
|
25
|
+
{
|
|
26
|
+
role: "user",
|
|
27
|
+
content: {
|
|
28
|
+
type: "text",
|
|
29
|
+
text: `
|
|
30
|
+
Your role is to ask the MagicPod MCP server to create a new test case, bypassing the prompt below. You can use API-v1_0_generate-test-case_create tool for this purpose.
|
|
31
|
+
You don't have to compose the test steps because this tool can do it. Just immediately share the original prompt with the tool without any modifications.
|
|
32
|
+
Create a test case under organization: ${request.params.arguments?.organizationName}, project: ${request.params.arguments?.projectName}
|
|
33
|
+
|
|
34
|
+
<prompt>
|
|
35
|
+
${request.params.arguments?.prompt}
|
|
36
|
+
</prompt>
|
|
37
|
+
`,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
export const apiV1_0GenerateTestCaseCreate = (baseUrl, apiToken) => {
|
|
4
|
+
return {
|
|
5
|
+
name: "API-v1_0_generate-test-case_create",
|
|
6
|
+
description: "Generate a new test case in accord with the provided prompt. " +
|
|
7
|
+
"When you are asked by a user to create a new test case, you don't have to compose the test steps because this tool can do it. " +
|
|
8
|
+
"Just immediately share the original user's input without any modifications.",
|
|
9
|
+
inputSchema: z.object({
|
|
10
|
+
organizationName: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("The organization name where a test case will be created"),
|
|
13
|
+
projectName: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe("The project name where a test case will be created"),
|
|
16
|
+
prompt: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe("A prompt that describes the specification of a test case"),
|
|
19
|
+
}),
|
|
20
|
+
handleRequest: async ({ organizationName, projectName, prompt }) => {
|
|
21
|
+
try {
|
|
22
|
+
const url = `${baseUrl}/api/v1.0/${organizationName}/${projectName}/generate-test-case/`;
|
|
23
|
+
const response = await axios.post(url, { prompt }, {
|
|
24
|
+
headers: {
|
|
25
|
+
"User-Agent": "magicpod-mcp-server",
|
|
26
|
+
Authorization: `Token ${apiToken}`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (response.status !== 200) {
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: "Failed to generate a test case",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: JSON.stringify({
|
|
44
|
+
message: "Succeeded to generate a test case",
|
|
45
|
+
...response.data,
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error("Failed to generate a test case: ", error instanceof Error ? error.message : String(error));
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|