@dyno181cm.nexsoft/zentao_mcp 1.0.2 → 1.1.0
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 +6 -0
- package/build/tools.js +23 -0
- package/build/zentaoClient.js +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ A Model Context Protocol (MCP) server for integrating with the Zentao API. This
|
|
|
9
9
|
- `zentao_get_execution_tasks`: Retrieve tasks in an execution (sprint), with optional filtering by module ID.
|
|
10
10
|
- `zentao_get_product_bugs`: Fetch a list of bugs associated with a specific product.
|
|
11
11
|
- `zentao_get_bug_details`: Get detailed information about a specific bug.
|
|
12
|
+
- `zentao_download_attachment`: Download file attachments from ZenTao (e.g., bug/task images or videos).
|
|
12
13
|
|
|
13
14
|
## Requirements
|
|
14
15
|
|
|
@@ -105,3 +106,8 @@ If a user clones the repository locally, they can configure their client to run
|
|
|
105
106
|
- **`zentao_get_bug_details`**
|
|
106
107
|
- **Inputs:**
|
|
107
108
|
- `bugId` (string | number) - Required. Bug ID.
|
|
109
|
+
|
|
110
|
+
- **`zentao_download_attachment`**
|
|
111
|
+
- **Inputs:**
|
|
112
|
+
- `fileId` (string | number) - Required. File ID to download.
|
|
113
|
+
- `extension` (string) - Optional. File extension (e.g., mp4, png).
|
package/build/tools.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
import * as path from "path";
|
|
2
4
|
import { ZentaoClient } from "./zentaoClient.js";
|
|
3
5
|
const client = new ZentaoClient();
|
|
4
6
|
export function registerTools(server) {
|
|
@@ -38,4 +40,25 @@ export function registerTools(server) {
|
|
|
38
40
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
39
41
|
};
|
|
40
42
|
});
|
|
43
|
+
server.registerTool("zentao_download_attachment", {
|
|
44
|
+
description: "Download a file attachment from ZenTao and save it locally",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
fileId: z.union([z.string(), z.number()]).describe("File ID to download"),
|
|
47
|
+
extension: z.string().optional().describe("Optional file extension (e.g., mp4, png)"),
|
|
48
|
+
}
|
|
49
|
+
}, async ({ fileId, extension }) => {
|
|
50
|
+
const ext = extension ? (extension.startsWith('.') ? extension : `.${extension}`) : '';
|
|
51
|
+
const targetPath = path.join(os.tmpdir(), `zentao_file_${fileId}${ext}`);
|
|
52
|
+
try {
|
|
53
|
+
const savedPath = await client.downloadFile(fileId, targetPath);
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: "text", text: `File downloaded successfully to: ${savedPath}` }],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return {
|
|
60
|
+
content: [{ type: "text", text: `Failed to download file: ${error.message}` }],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
41
64
|
}
|
package/build/zentaoClient.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import * as dotenv from 'dotenv';
|
|
3
|
+
import * as fs from 'fs';
|
|
3
4
|
dotenv.config();
|
|
4
5
|
export class ZentaoClient {
|
|
5
6
|
client;
|
|
@@ -98,4 +99,24 @@ export class ZentaoClient {
|
|
|
98
99
|
const res = await this.client.get(`/bugs/${bugId}`);
|
|
99
100
|
return res.data;
|
|
100
101
|
}
|
|
102
|
+
async downloadFile(fileId, targetPath) {
|
|
103
|
+
const writer = fs.createWriteStream(targetPath);
|
|
104
|
+
const res = await this.client.get(`/files/${fileId}`, {
|
|
105
|
+
responseType: 'stream',
|
|
106
|
+
});
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
res.data.pipe(writer);
|
|
109
|
+
let error = null;
|
|
110
|
+
writer.on('error', err => {
|
|
111
|
+
error = err;
|
|
112
|
+
writer.close();
|
|
113
|
+
reject(err);
|
|
114
|
+
});
|
|
115
|
+
writer.on('close', () => {
|
|
116
|
+
if (!error) {
|
|
117
|
+
resolve(targetPath);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
101
122
|
}
|