@zereight/mcp-gitlab 2.0.25 → 2.0.30
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 +40 -0
- package/build/index.js +520 -136
- package/build/schemas.js +268 -90
- package/build/test/test-download-attachment.js +144 -0
- package/build/test/test-toolset-filtering.js +451 -0
- package/build/test-resolve-issue-note.js +127 -0
- package/package.json +3 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This test file demonstrates the new resolve functionality for issue notes.
|
|
3
|
+
* It shows how to use the update_issue_note tool to resolve or unresolve
|
|
4
|
+
* issue discussion threads.
|
|
5
|
+
*/
|
|
6
|
+
import fetch from "node-fetch";
|
|
7
|
+
// GitLab API configuration (replace with actual values when testing)
|
|
8
|
+
const GITLAB_API_URL = process.env.GITLAB_API_URL || "https://gitlab.com";
|
|
9
|
+
const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_TOKEN || "";
|
|
10
|
+
const PROJECT_ID = process.env.PROJECT_ID || "your/project";
|
|
11
|
+
const ISSUE_IID = Number(process.env.ISSUE_IID || "1");
|
|
12
|
+
const DISCUSSION_ID = process.env.DISCUSSION_ID || "your-discussion-id";
|
|
13
|
+
const NOTE_ID = process.env.NOTE_ID || "your-note-id";
|
|
14
|
+
/**
|
|
15
|
+
* Test resolving an issue note
|
|
16
|
+
*/
|
|
17
|
+
async function testResolveIssueNote() {
|
|
18
|
+
try {
|
|
19
|
+
const url = new URL(`${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(PROJECT_ID)}/issues/${ISSUE_IID}/discussions/${DISCUSSION_ID}/notes/${NOTE_ID}`);
|
|
20
|
+
const response = await fetch(url.toString(), {
|
|
21
|
+
method: "PUT",
|
|
22
|
+
headers: {
|
|
23
|
+
Accept: "application/json",
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({ resolved: true }),
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
const errorBody = await response.text();
|
|
31
|
+
throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
|
|
32
|
+
}
|
|
33
|
+
const data = await response.json();
|
|
34
|
+
console.log("Successfully resolved issue note:");
|
|
35
|
+
console.log(JSON.stringify(data, null, 2));
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error("Error resolving issue note:", error);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Test unresolving an issue note
|
|
45
|
+
*/
|
|
46
|
+
async function testUnresolveIssueNote() {
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL(`${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(PROJECT_ID)}/issues/${ISSUE_IID}/discussions/${DISCUSSION_ID}/notes/${NOTE_ID}`);
|
|
49
|
+
const response = await fetch(url.toString(), {
|
|
50
|
+
method: "PUT",
|
|
51
|
+
headers: {
|
|
52
|
+
Accept: "application/json",
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify({ resolved: false }),
|
|
57
|
+
});
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
const errorBody = await response.text();
|
|
60
|
+
throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
|
|
61
|
+
}
|
|
62
|
+
const data = await response.json();
|
|
63
|
+
console.log("Successfully unresolved issue note:");
|
|
64
|
+
console.log(JSON.stringify(data, null, 2));
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error("Error unresolving issue note:", error);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Test updating note body (existing functionality should still work)
|
|
74
|
+
*/
|
|
75
|
+
async function testUpdateIssueNoteBody() {
|
|
76
|
+
try {
|
|
77
|
+
const url = new URL(`${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(PROJECT_ID)}/issues/${ISSUE_IID}/discussions/${DISCUSSION_ID}/notes/${NOTE_ID}`);
|
|
78
|
+
const response = await fetch(url.toString(), {
|
|
79
|
+
method: "PUT",
|
|
80
|
+
headers: {
|
|
81
|
+
Accept: "application/json",
|
|
82
|
+
"Content-Type": "application/json",
|
|
83
|
+
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
84
|
+
},
|
|
85
|
+
body: JSON.stringify({ body: "Updated note content" }),
|
|
86
|
+
});
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
const errorBody = await response.text();
|
|
89
|
+
throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
|
|
90
|
+
}
|
|
91
|
+
const data = await response.json();
|
|
92
|
+
console.log("Successfully updated issue note body:");
|
|
93
|
+
console.log(JSON.stringify(data, null, 2));
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error("Error updating issue note body:", error);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Only run the test if executed directly
|
|
102
|
+
if (require.main === module) {
|
|
103
|
+
console.log("Testing issue note resolve functionality...\n");
|
|
104
|
+
console.log("Note: This is a demonstration test file.");
|
|
105
|
+
console.log("To run actual tests, set the following environment variables:");
|
|
106
|
+
console.log(" - GITLAB_API_URL");
|
|
107
|
+
console.log(" - GITLAB_TOKEN");
|
|
108
|
+
console.log(" - PROJECT_ID");
|
|
109
|
+
console.log(" - ISSUE_IID");
|
|
110
|
+
console.log(" - DISCUSSION_ID");
|
|
111
|
+
console.log(" - NOTE_ID");
|
|
112
|
+
console.log("\nExample MCP tool usage:");
|
|
113
|
+
console.log(`
|
|
114
|
+
{
|
|
115
|
+
"name": "update_issue_note",
|
|
116
|
+
"arguments": {
|
|
117
|
+
"project_id": "your/project",
|
|
118
|
+
"issue_iid": "1",
|
|
119
|
+
"discussion_id": "abc123",
|
|
120
|
+
"note_id": "456",
|
|
121
|
+
"resolved": true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
`);
|
|
125
|
+
}
|
|
126
|
+
// Export for use in other tests
|
|
127
|
+
export { testResolveIssueNote, testUnresolveIssueNote, testUpdateIssueNoteBody };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.30",
|
|
4
4
|
"description": "MCP server for using the GitLab API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "zereight",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"changelog": "auto-changelog -p",
|
|
30
30
|
"test": "npm run test:all",
|
|
31
31
|
"test:all": "npm run build && npm run test:mock && npm run test:live",
|
|
32
|
-
"test:mock": "npx tsx --test test/remote-auth-simple-test.ts && tsx test/oauth-tests.ts && tsx test/test-list-merge-requests.ts && tsx test/test-list-project-members.ts",
|
|
32
|
+
"test:mock": "npx tsx --test test/remote-auth-simple-test.ts && tsx test/oauth-tests.ts && tsx test/test-list-merge-requests.ts && tsx test/test-list-project-members.ts && tsx test/test-download-attachment.ts",
|
|
33
33
|
"test:live": "node test/validate-api.js",
|
|
34
34
|
"test:remote-auth": "npm run build && npx tsx --test test/remote-auth-simple-test.ts",
|
|
35
35
|
"test:oauth": "tsx test/oauth-tests.ts",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"test:approvals": "npm run build && tsx test/test-merge-request-approvals.ts",
|
|
38
38
|
"lint": "eslint . --ext .ts",
|
|
39
39
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
40
|
+
"release": "bash scripts/release.sh",
|
|
40
41
|
"format": "prettier --write \"**/*.{js,ts,json,md}\"",
|
|
41
42
|
"format:check": "prettier --check \"**/*.{js,ts,json,md}\""
|
|
42
43
|
},
|