@nibgat/nmcp 0.0.0-stage → 2.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/LICENSE +21 -0
- package/README.md +111 -2
- package/dist/auth/vault.d.ts +85 -0
- package/dist/auth/vault.js +256 -0
- package/dist/auth/vault.js.map +1 -0
- package/dist/bin/nmcp.d.ts +2 -0
- package/dist/bin/nmcp.js +198 -0
- package/dist/bin/nmcp.js.map +1 -0
- package/dist/cli/configSnippets.d.ts +11 -0
- package/dist/cli/configSnippets.js +57 -0
- package/dist/cli/configSnippets.js.map +1 -0
- package/dist/config/constants.d.ts +31 -0
- package/dist/config/constants.js +87 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/data/ecosystem.d.ts +187 -0
- package/dist/data/ecosystem.js +955 -0
- package/dist/data/ecosystem.js.map +1 -0
- package/dist/http/client.d.ts +31 -0
- package/dist/http/client.js +179 -0
- package/dist/http/client.js.map +1 -0
- package/dist/http/server.d.ts +17 -0
- package/dist/http/server.js +210 -0
- package/dist/http/server.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.js +132 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/index.js +108 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/security/redact.d.ts +2 -0
- package/dist/security/redact.js +183 -0
- package/dist/security/redact.js.map +1 -0
- package/dist/security/validators.d.ts +205 -0
- package/dist/security/validators.js +394 -0
- package/dist/security/validators.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +44 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.js +1323 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +67 -5
|
@@ -0,0 +1,1323 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { HEALTH_CHECK_TIMEOUT_MS, PUBLIC_HEALTH_TARGETS } from "../config/constants.js";
|
|
3
|
+
import { NCLI_COMMAND_GUIDES, PUBLIC_ECOSYSTEM_SERVICES } from "../data/ecosystem.js";
|
|
4
|
+
import { getSanitizedAuthSummary } from "../auth/vault.js";
|
|
5
|
+
import { redactSecrets } from "../security/redact.js";
|
|
6
|
+
import { gitRefSchema, loadPipelineConfigFile, repoFullNameSchema, safeUrlSchema, slugSchema, validatePipelineConfig } from "../security/validators.js";
|
|
7
|
+
const READ_ONLY_LOCAL_ANNOTATIONS = {
|
|
8
|
+
readOnlyHint: true,
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
idempotentHint: true,
|
|
11
|
+
openWorldHint: false
|
|
12
|
+
};
|
|
13
|
+
const READ_ONLY_REMOTE_ANNOTATIONS = {
|
|
14
|
+
readOnlyHint: true,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
idempotentHint: true,
|
|
17
|
+
openWorldHint: true
|
|
18
|
+
};
|
|
19
|
+
const WRITE_REMOTE_ANNOTATIONS = {
|
|
20
|
+
readOnlyHint: false,
|
|
21
|
+
destructiveHint: false,
|
|
22
|
+
idempotentHint: false,
|
|
23
|
+
openWorldHint: true
|
|
24
|
+
};
|
|
25
|
+
const jsonToolResult = (payload, isError = false) => {
|
|
26
|
+
const sanitized = redactSecrets(payload);
|
|
27
|
+
return {
|
|
28
|
+
isError,
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: JSON.stringify(sanitized, null, 2)
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const apiErrorResult = (endpoint, status, message, details) => {
|
|
38
|
+
return jsonToolResult({
|
|
39
|
+
ok: false,
|
|
40
|
+
endpoint,
|
|
41
|
+
status,
|
|
42
|
+
error: message,
|
|
43
|
+
...(details ? {
|
|
44
|
+
details
|
|
45
|
+
} : {})
|
|
46
|
+
}, true);
|
|
47
|
+
};
|
|
48
|
+
const readOnlyBlockedResult = (toolName) => {
|
|
49
|
+
return jsonToolResult({
|
|
50
|
+
ok: false,
|
|
51
|
+
error: "read-only-mode-active",
|
|
52
|
+
message: `Tool '${toolName}' is disabled because nmcp is running with --read-only.`
|
|
53
|
+
}, true);
|
|
54
|
+
};
|
|
55
|
+
export const registerTools = (server, ctx) => {
|
|
56
|
+
const { httpClient, readOnly } = ctx;
|
|
57
|
+
// 1. nibgat_ecosystem_overview
|
|
58
|
+
server.registerTool("nibgat_ecosystem_overview", {
|
|
59
|
+
title: "NİBGAT Core Complex Ecosystem Overview",
|
|
60
|
+
description: "Returns a structured map of all public NİBGAT Core Complex services, domains, categories, and official documentation links.",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
category: z.enum([
|
|
63
|
+
"all",
|
|
64
|
+
"gateway",
|
|
65
|
+
"identity",
|
|
66
|
+
"developer",
|
|
67
|
+
"communication",
|
|
68
|
+
"assets",
|
|
69
|
+
"portal",
|
|
70
|
+
"docs",
|
|
71
|
+
"commerce",
|
|
72
|
+
"cloud"
|
|
73
|
+
]).optional().describe("Optional category filter (defaults to 'all').")
|
|
74
|
+
},
|
|
75
|
+
annotations: READ_ONLY_LOCAL_ANNOTATIONS
|
|
76
|
+
}, async ({ category }) => {
|
|
77
|
+
const selected = !category || category === "all"
|
|
78
|
+
? PUBLIC_ECOSYSTEM_SERVICES
|
|
79
|
+
: PUBLIC_ECOSYSTEM_SERVICES.filter((svc) => svc.category === category);
|
|
80
|
+
const authSummary = getSanitizedAuthSummary(httpClient.getActiveCredentials());
|
|
81
|
+
return jsonToolResult({
|
|
82
|
+
ok: true,
|
|
83
|
+
ecosystem: "NİBGAT® Core Complex",
|
|
84
|
+
docsHome: "https://docs.nibgat.space",
|
|
85
|
+
mcpDocs: "https://docs.nibgat.space/mcp",
|
|
86
|
+
readOnlyMode: readOnly,
|
|
87
|
+
activeProfile: authSummary.profile,
|
|
88
|
+
configuredEndpoints: {
|
|
89
|
+
coreUrl: authSummary.coreUrl,
|
|
90
|
+
gitUrl: authSummary.gitUrl
|
|
91
|
+
},
|
|
92
|
+
totalServices: selected.length,
|
|
93
|
+
services: selected
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
// 2. nibgat_health_check
|
|
97
|
+
server.registerTool("nibgat_health_check", {
|
|
98
|
+
title: "NİBGAT Public Services Health Check",
|
|
99
|
+
description: "Probes live public health endpoints (core.nibgat.space, git.nibgat.space, docs.nibgat.space, fonts.nibgat.space) and reports HTTP status and latency.",
|
|
100
|
+
inputSchema: {
|
|
101
|
+
timeoutMs: z.number().int().min(1000).max(15000).optional().describe("Per-endpoint probe timeout in milliseconds (default: 6000).")
|
|
102
|
+
},
|
|
103
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
104
|
+
}, async ({ timeoutMs }) => {
|
|
105
|
+
const timeout = timeoutMs ?? HEALTH_CHECK_TIMEOUT_MS;
|
|
106
|
+
const creds = httpClient.getActiveCredentials();
|
|
107
|
+
const targets = PUBLIC_HEALTH_TARGETS.map((target) => {
|
|
108
|
+
if (target.id === "core-api") {
|
|
109
|
+
return {
|
|
110
|
+
...target,
|
|
111
|
+
url: `${creds.coreUrl}/healthcheck`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (target.id === "ngit-api") {
|
|
115
|
+
return {
|
|
116
|
+
...target,
|
|
117
|
+
url: `${creds.gitUrl}/api/v1/health`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
});
|
|
122
|
+
const results = await Promise.all(targets.map(async (target) => {
|
|
123
|
+
const probe = await httpClient.probeUrl(target.url, timeout);
|
|
124
|
+
return {
|
|
125
|
+
id: target.id,
|
|
126
|
+
name: target.name,
|
|
127
|
+
url: target.url,
|
|
128
|
+
...probe
|
|
129
|
+
};
|
|
130
|
+
}));
|
|
131
|
+
const healthyCount = results.filter((r) => r.ok).length;
|
|
132
|
+
return jsonToolResult({
|
|
133
|
+
ok: healthyCount === results.length,
|
|
134
|
+
checkedAt: new Date().toISOString(),
|
|
135
|
+
summary: {
|
|
136
|
+
total: results.length,
|
|
137
|
+
healthy: healthyCount,
|
|
138
|
+
degraded: results.length - healthyCount
|
|
139
|
+
},
|
|
140
|
+
services: results
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
// 3. ncli_command_guide
|
|
144
|
+
server.registerTool("ncli_command_guide", {
|
|
145
|
+
title: "ncli Command Guide",
|
|
146
|
+
description: "Returns exact, safe ncli command recipes, flags, prerequisites, security notes, and docs.nibgat.space links for a given workflow topic.",
|
|
147
|
+
inputSchema: {
|
|
148
|
+
topic: z.enum([
|
|
149
|
+
"auth",
|
|
150
|
+
"pipeline",
|
|
151
|
+
"runner",
|
|
152
|
+
"git",
|
|
153
|
+
"registry",
|
|
154
|
+
"mail",
|
|
155
|
+
"support",
|
|
156
|
+
"profile",
|
|
157
|
+
"release",
|
|
158
|
+
"buyment",
|
|
159
|
+
"cloud"
|
|
160
|
+
]).describe("Workflow topic to retrieve ncli command recipes for.")
|
|
161
|
+
},
|
|
162
|
+
annotations: READ_ONLY_LOCAL_ANNOTATIONS
|
|
163
|
+
}, async ({ topic }) => {
|
|
164
|
+
const guide = NCLI_COMMAND_GUIDES[topic];
|
|
165
|
+
return jsonToolResult({
|
|
166
|
+
ok: true,
|
|
167
|
+
...guide
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
// 4. nibgat_whoami
|
|
171
|
+
server.registerTool("nibgat_whoami", {
|
|
172
|
+
title: "NİBGAT Active Identity Check",
|
|
173
|
+
description: "Checks the active authenticated user across N - Auth (/nauth/sso/session) and N - Git (/api/v1/me) using local encrypted vault or environment credentials without ever exposing raw tokens.",
|
|
174
|
+
inputSchema: {},
|
|
175
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
176
|
+
}, async () => {
|
|
177
|
+
const creds = httpClient.getActiveCredentials();
|
|
178
|
+
const authSummary = getSanitizedAuthSummary(creds);
|
|
179
|
+
const [nauthResp, ngitResp] = await Promise.all([
|
|
180
|
+
httpClient.request({
|
|
181
|
+
target: "core",
|
|
182
|
+
method: "GET",
|
|
183
|
+
path: "/nauth/sso/session"
|
|
184
|
+
}),
|
|
185
|
+
httpClient.request({
|
|
186
|
+
target: "git",
|
|
187
|
+
method: "GET",
|
|
188
|
+
path: "/api/v1/me"
|
|
189
|
+
})
|
|
190
|
+
]);
|
|
191
|
+
return jsonToolResult({
|
|
192
|
+
ok: nauthResp.ok || ngitResp.ok,
|
|
193
|
+
auth: authSummary,
|
|
194
|
+
nauth: {
|
|
195
|
+
authenticated: nauthResp.ok,
|
|
196
|
+
status: nauthResp.status,
|
|
197
|
+
latencyMs: nauthResp.latencyMs,
|
|
198
|
+
profile: nauthResp.ok ? nauthResp.data : null,
|
|
199
|
+
...(nauthResp.errorMessage ? {
|
|
200
|
+
error: nauthResp.errorMessage
|
|
201
|
+
} : {})
|
|
202
|
+
},
|
|
203
|
+
ngit: {
|
|
204
|
+
authenticated: ngitResp.ok,
|
|
205
|
+
status: ngitResp.status,
|
|
206
|
+
latencyMs: ngitResp.latencyMs,
|
|
207
|
+
profile: ngitResp.ok ? ngitResp.data : null,
|
|
208
|
+
...(ngitResp.errorMessage ? {
|
|
209
|
+
error: ngitResp.errorMessage
|
|
210
|
+
} : {})
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
// 5. nchar_profile_get
|
|
215
|
+
server.registerTool("nchar_profile_get", {
|
|
216
|
+
title: "Get N - Char Profile",
|
|
217
|
+
description: "Fetches the authenticated user's N - Char profile (/nchar/sso/me) or a public developer profile by username (/nchar/public/profile/:userName).",
|
|
218
|
+
inputSchema: {
|
|
219
|
+
username: slugSchema.optional().describe("Optional username to look up a public N - Char profile. Omit to fetch your authenticated profile.")
|
|
220
|
+
},
|
|
221
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
222
|
+
}, async ({ username }) => {
|
|
223
|
+
const endpoint = username
|
|
224
|
+
? `/nchar/public/profile/${encodeURIComponent(username)}`
|
|
225
|
+
: "/nchar/sso/me";
|
|
226
|
+
const resp = await httpClient.request({
|
|
227
|
+
target: "core",
|
|
228
|
+
method: "GET",
|
|
229
|
+
path: endpoint,
|
|
230
|
+
requireAuth: !username
|
|
231
|
+
});
|
|
232
|
+
if (!resp.ok) {
|
|
233
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to fetch N - Char profile.", resp.data);
|
|
234
|
+
}
|
|
235
|
+
return jsonToolResult({
|
|
236
|
+
ok: true,
|
|
237
|
+
mode: username ? "public" : "self",
|
|
238
|
+
latencyMs: resp.latencyMs,
|
|
239
|
+
profile: resp.data
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
// 6. ngit_repos_list
|
|
243
|
+
server.registerTool("ngit_repos_list", {
|
|
244
|
+
title: "List N - Git Repositories",
|
|
245
|
+
description: "Lists accessible N - Git repositories (GET /api/v1/repos or /api/v1/overview), filterable by owner slug or search query.",
|
|
246
|
+
inputSchema: {
|
|
247
|
+
owner: slugSchema.optional().describe("Filter repositories by owner or organization slug."),
|
|
248
|
+
query: z.string().trim().max(120).optional().describe("Search substring matching repository name, owner, or description."),
|
|
249
|
+
includeOverview: z.boolean().optional().describe("If true, fetches /api/v1/overview instead of /api/v1/repos (requires auth).")
|
|
250
|
+
},
|
|
251
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
252
|
+
}, async ({ owner, query, includeOverview }) => {
|
|
253
|
+
const endpoint = includeOverview ? "/api/v1/overview" : "/api/v1/repos";
|
|
254
|
+
const resp = await httpClient.request({
|
|
255
|
+
target: "git",
|
|
256
|
+
method: "GET",
|
|
257
|
+
path: endpoint,
|
|
258
|
+
query: includeOverview ? undefined : {
|
|
259
|
+
owner,
|
|
260
|
+
q: query
|
|
261
|
+
},
|
|
262
|
+
requireAuth: Boolean(includeOverview)
|
|
263
|
+
});
|
|
264
|
+
if (!resp.ok) {
|
|
265
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list repositories.", resp.data);
|
|
266
|
+
}
|
|
267
|
+
return jsonToolResult({
|
|
268
|
+
ok: true,
|
|
269
|
+
endpoint,
|
|
270
|
+
latencyMs: resp.latencyMs,
|
|
271
|
+
result: resp.data
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
// 7. ngit_repo_get
|
|
275
|
+
server.registerTool("ngit_repo_get", {
|
|
276
|
+
title: "Get N - Git Repository Details",
|
|
277
|
+
description: "Retrieves repository metadata, branches, tags, open issue/PR counts, and optional README summary.",
|
|
278
|
+
inputSchema: {
|
|
279
|
+
owner: slugSchema.describe("Repository owner or organization slug."),
|
|
280
|
+
repo: slugSchema.describe("Repository slug."),
|
|
281
|
+
includeReadme: z.boolean().optional().describe("Whether to also fetch a truncated README summary (default: true).")
|
|
282
|
+
},
|
|
283
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
284
|
+
}, async ({ owner, repo, includeReadme }) => {
|
|
285
|
+
const repoPath = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`;
|
|
286
|
+
const shouldFetchReadme = includeReadme !== false;
|
|
287
|
+
const [repoResp, readmeResp] = await Promise.all([
|
|
288
|
+
httpClient.request({
|
|
289
|
+
target: "git",
|
|
290
|
+
method: "GET",
|
|
291
|
+
path: repoPath
|
|
292
|
+
}),
|
|
293
|
+
shouldFetchReadme
|
|
294
|
+
? httpClient.request({
|
|
295
|
+
target: "git",
|
|
296
|
+
method: "GET",
|
|
297
|
+
path: `${repoPath}/readme`
|
|
298
|
+
})
|
|
299
|
+
: Promise.resolve(null)
|
|
300
|
+
]);
|
|
301
|
+
if (!repoResp.ok) {
|
|
302
|
+
return apiErrorResult(repoPath, repoResp.status, repoResp.errorMessage || "Failed to fetch repository.", repoResp.data);
|
|
303
|
+
}
|
|
304
|
+
let readmeSummary = null;
|
|
305
|
+
if (readmeResp && readmeResp.ok && readmeResp.data && typeof readmeResp.data === "object") {
|
|
306
|
+
const body = readmeResp.data;
|
|
307
|
+
const payloadObj = (body.payload && typeof body.payload === "object")
|
|
308
|
+
? body.payload
|
|
309
|
+
: body;
|
|
310
|
+
const rawContent = typeof payloadObj.content === "string"
|
|
311
|
+
? payloadObj.content
|
|
312
|
+
: (typeof payloadObj.markdown === "string" ? payloadObj.markdown : "");
|
|
313
|
+
if (rawContent) {
|
|
314
|
+
readmeSummary = rawContent.length > 2000
|
|
315
|
+
? `${rawContent.slice(0, 2000)}\n...[truncated]`
|
|
316
|
+
: rawContent;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return jsonToolResult({
|
|
320
|
+
ok: true,
|
|
321
|
+
latencyMs: repoResp.latencyMs,
|
|
322
|
+
repository: repoResp.data,
|
|
323
|
+
...(shouldFetchReadme ? {
|
|
324
|
+
readmeSummary
|
|
325
|
+
} : {})
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
// 8. ngit_releases_list
|
|
329
|
+
server.registerTool("ngit_releases_list", {
|
|
330
|
+
title: "List N - Git Releases",
|
|
331
|
+
description: "Lists published releases, tags, commit SHAs, and archive URLs for a repository.",
|
|
332
|
+
inputSchema: {
|
|
333
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
334
|
+
repo: slugSchema.describe("Repository slug.")
|
|
335
|
+
},
|
|
336
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
337
|
+
}, async ({ owner, repo }) => {
|
|
338
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/releases`;
|
|
339
|
+
const resp = await httpClient.request({
|
|
340
|
+
target: "git",
|
|
341
|
+
method: "GET",
|
|
342
|
+
path: endpoint
|
|
343
|
+
});
|
|
344
|
+
if (!resp.ok) {
|
|
345
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list releases.", resp.data);
|
|
346
|
+
}
|
|
347
|
+
return jsonToolResult({
|
|
348
|
+
ok: true,
|
|
349
|
+
latencyMs: resp.latencyMs,
|
|
350
|
+
result: resp.data
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
// 9. ngit_release_create (WRITE)
|
|
354
|
+
if (!readOnly) {
|
|
355
|
+
server.registerTool("ngit_release_create", {
|
|
356
|
+
title: "Create N - Git Release",
|
|
357
|
+
description: "Publishes a new release on N - Git (POST /api/v1/repos/:owner/:repo/releases), optionally creating the Git tag and triggering the CI/CD deployment pipeline. Disabled in --read-only mode.",
|
|
358
|
+
inputSchema: {
|
|
359
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
360
|
+
repo: slugSchema.describe("Repository slug."),
|
|
361
|
+
tagName: gitRefSchema.describe("Semantic version or tag name (e.g. 'v1.2.0')."),
|
|
362
|
+
target: gitRefSchema.optional().describe("Target branch or commit ref (defaults to repository default branch)."),
|
|
363
|
+
title: z.string().trim().min(1).max(160).optional().describe("Release title (defaults to tagName)."),
|
|
364
|
+
notes: z.string().max(10_000).optional().describe("Markdown release notes."),
|
|
365
|
+
isDraft: z.boolean().optional().describe("Create as draft release without triggering production deploy webhook."),
|
|
366
|
+
isPrerelease: z.boolean().optional().describe("Mark release as prerelease."),
|
|
367
|
+
createTag: z.boolean().optional().describe("Create Git tag if it does not exist (default: true).")
|
|
368
|
+
},
|
|
369
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
370
|
+
}, async ({ owner, repo, tagName, target, title, notes, isDraft, isPrerelease, createTag }) => {
|
|
371
|
+
if (readOnly) {
|
|
372
|
+
return readOnlyBlockedResult("ngit_release_create");
|
|
373
|
+
}
|
|
374
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/releases`;
|
|
375
|
+
const resp = await httpClient.request({
|
|
376
|
+
target: "git",
|
|
377
|
+
method: "POST",
|
|
378
|
+
path: endpoint,
|
|
379
|
+
requireAuth: true,
|
|
380
|
+
body: {
|
|
381
|
+
tagName,
|
|
382
|
+
...(target ? {
|
|
383
|
+
target
|
|
384
|
+
} : {}),
|
|
385
|
+
title: title || tagName,
|
|
386
|
+
notes: notes || "",
|
|
387
|
+
isDraft: Boolean(isDraft),
|
|
388
|
+
isPrerelease: Boolean(isPrerelease),
|
|
389
|
+
createTag: createTag !== false
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
if (!resp.ok) {
|
|
393
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to create release.", resp.data);
|
|
394
|
+
}
|
|
395
|
+
return jsonToolResult({
|
|
396
|
+
ok: true,
|
|
397
|
+
latencyMs: resp.latencyMs,
|
|
398
|
+
release: resp.data
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
// 10. ngit_deployments_list
|
|
403
|
+
server.registerTool("ngit_deployments_list", {
|
|
404
|
+
title: "List N - Git CI/CD Deployments",
|
|
405
|
+
description: "Lists recent CI/CD deployment runs, stages, durations, and sanitized build logs for a repository.",
|
|
406
|
+
inputSchema: {
|
|
407
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
408
|
+
repo: slugSchema.describe("Repository slug."),
|
|
409
|
+
limit: z.number().int().min(1).max(30).optional().describe("Optional max deployment entries to return (1-30).")
|
|
410
|
+
},
|
|
411
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
412
|
+
}, async ({ owner, repo, limit }) => {
|
|
413
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/deployments`;
|
|
414
|
+
const resp = await httpClient.request({
|
|
415
|
+
target: "git",
|
|
416
|
+
method: "GET",
|
|
417
|
+
path: endpoint,
|
|
418
|
+
requireAuth: true
|
|
419
|
+
});
|
|
420
|
+
if (!resp.ok) {
|
|
421
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list deployments.", resp.data);
|
|
422
|
+
}
|
|
423
|
+
let data = resp.data;
|
|
424
|
+
if (limit && data && typeof data === "object") {
|
|
425
|
+
const record = data;
|
|
426
|
+
const payload = (record.payload && typeof record.payload === "object")
|
|
427
|
+
? record.payload
|
|
428
|
+
: record;
|
|
429
|
+
if (Array.isArray(payload.deployments)) {
|
|
430
|
+
payload.deployments = payload.deployments.slice(0, limit);
|
|
431
|
+
}
|
|
432
|
+
data = record;
|
|
433
|
+
}
|
|
434
|
+
return jsonToolResult({
|
|
435
|
+
ok: true,
|
|
436
|
+
latencyMs: resp.latencyMs,
|
|
437
|
+
result: data
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
// 11. ngit_deployment_trigger (WRITE)
|
|
441
|
+
if (!readOnly) {
|
|
442
|
+
server.registerTool("ngit_deployment_trigger", {
|
|
443
|
+
title: "Trigger N - Git Deployment",
|
|
444
|
+
description: "Manually triggers a CI/CD deployment for a branch or tag ref (POST /api/v1/repos/:owner/:repo/deployments/trigger). Disabled in --read-only mode.",
|
|
445
|
+
inputSchema: {
|
|
446
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
447
|
+
repo: slugSchema.describe("Repository slug."),
|
|
448
|
+
ref: gitRefSchema.describe("Branch or tag reference to deploy (e.g. 'main' or 'v1.2.0').")
|
|
449
|
+
},
|
|
450
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
451
|
+
}, async ({ owner, repo, ref }) => {
|
|
452
|
+
if (readOnly) {
|
|
453
|
+
return readOnlyBlockedResult("ngit_deployment_trigger");
|
|
454
|
+
}
|
|
455
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/deployments/trigger`;
|
|
456
|
+
const resp = await httpClient.request({
|
|
457
|
+
target: "git",
|
|
458
|
+
method: "POST",
|
|
459
|
+
path: endpoint,
|
|
460
|
+
requireAuth: true,
|
|
461
|
+
body: {
|
|
462
|
+
ref
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
if (!resp.ok) {
|
|
466
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to trigger deployment.", resp.data);
|
|
467
|
+
}
|
|
468
|
+
return jsonToolResult({
|
|
469
|
+
ok: true,
|
|
470
|
+
latencyMs: resp.latencyMs,
|
|
471
|
+
deployment: resp.data
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
// 12. ngit_runners_list
|
|
476
|
+
server.registerTool("ngit_runners_list", {
|
|
477
|
+
title: "List N - Git Self-Hosted Runners",
|
|
478
|
+
description: "Lists self-hosted CI/CD runners configured for a repository (GET /api/v1/repos/:owner/:repo/runners).",
|
|
479
|
+
inputSchema: {
|
|
480
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
481
|
+
repo: slugSchema.describe("Repository slug.")
|
|
482
|
+
},
|
|
483
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
484
|
+
}, async ({ owner, repo }) => {
|
|
485
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/runners`;
|
|
486
|
+
const resp = await httpClient.request({
|
|
487
|
+
target: "git",
|
|
488
|
+
method: "GET",
|
|
489
|
+
path: endpoint,
|
|
490
|
+
requireAuth: true
|
|
491
|
+
});
|
|
492
|
+
if (!resp.ok) {
|
|
493
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list runners.", resp.data);
|
|
494
|
+
}
|
|
495
|
+
return jsonToolResult({
|
|
496
|
+
ok: true,
|
|
497
|
+
latencyMs: resp.latencyMs,
|
|
498
|
+
result: resp.data
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
// 13. ngit_registry_list
|
|
502
|
+
server.registerTool("ngit_registry_list", {
|
|
503
|
+
title: "List N - Git OCI Container Registry Images",
|
|
504
|
+
description: "Lists OCI container images, tags, digests, and pull commands from git.nibgat.space (GET /api/v1/registry/repositories).",
|
|
505
|
+
inputSchema: {
|
|
506
|
+
owner: slugSchema.optional().describe("Optional owner slug to filter container repositories.")
|
|
507
|
+
},
|
|
508
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
509
|
+
}, async ({ owner }) => {
|
|
510
|
+
const endpoint = "/api/v1/registry/repositories";
|
|
511
|
+
const resp = await httpClient.request({
|
|
512
|
+
target: "git",
|
|
513
|
+
method: "GET",
|
|
514
|
+
path: endpoint,
|
|
515
|
+
requireAuth: true
|
|
516
|
+
});
|
|
517
|
+
if (!resp.ok) {
|
|
518
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list registry images.", resp.data);
|
|
519
|
+
}
|
|
520
|
+
let data = resp.data;
|
|
521
|
+
if (owner && data && typeof data === "object") {
|
|
522
|
+
const record = data;
|
|
523
|
+
const payload = (record.payload && typeof record.payload === "object")
|
|
524
|
+
? record.payload
|
|
525
|
+
: record;
|
|
526
|
+
if (Array.isArray(payload.repositories)) {
|
|
527
|
+
payload.repositories = payload.repositories.filter((item) => {
|
|
528
|
+
if (!item || typeof item !== "object") {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
const r = item;
|
|
532
|
+
return String(r.ownerSlug || "").toLowerCase() === owner;
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
data = record;
|
|
536
|
+
}
|
|
537
|
+
return jsonToolResult({
|
|
538
|
+
ok: true,
|
|
539
|
+
latencyMs: resp.latencyMs,
|
|
540
|
+
result: data
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
// 14. ngit_issues_list
|
|
544
|
+
server.registerTool("ngit_issues_list", {
|
|
545
|
+
title: "List N - Git Issues & Pull Requests",
|
|
546
|
+
description: "Lists issues and pull requests for a repository with optional kind and state filters.",
|
|
547
|
+
inputSchema: {
|
|
548
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
549
|
+
repo: slugSchema.describe("Repository slug."),
|
|
550
|
+
kind: z.enum([
|
|
551
|
+
"issue",
|
|
552
|
+
"pr"
|
|
553
|
+
]).optional().describe("Filter by 'issue' or 'pr'."),
|
|
554
|
+
state: z.enum([
|
|
555
|
+
"open",
|
|
556
|
+
"closed",
|
|
557
|
+
"all"
|
|
558
|
+
]).optional().describe("Filter by state ('open', 'closed', or 'all').")
|
|
559
|
+
},
|
|
560
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
561
|
+
}, async ({ owner, repo, kind, state }) => {
|
|
562
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/issues`;
|
|
563
|
+
const resp = await httpClient.request({
|
|
564
|
+
target: "git",
|
|
565
|
+
method: "GET",
|
|
566
|
+
path: endpoint,
|
|
567
|
+
query: {
|
|
568
|
+
kind,
|
|
569
|
+
state
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
if (!resp.ok) {
|
|
573
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list issues.", resp.data);
|
|
574
|
+
}
|
|
575
|
+
return jsonToolResult({
|
|
576
|
+
ok: true,
|
|
577
|
+
latencyMs: resp.latencyMs,
|
|
578
|
+
result: resp.data
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
// 15. ngit_issue_create (WRITE)
|
|
582
|
+
if (!readOnly) {
|
|
583
|
+
server.registerTool("ngit_issue_create", {
|
|
584
|
+
title: "Create N - Git Issue",
|
|
585
|
+
description: "Creates a new issue or pull request in a repository (POST /api/v1/repos/:owner/:repo/issues). Disabled in --read-only mode.",
|
|
586
|
+
inputSchema: {
|
|
587
|
+
owner: slugSchema.describe("Repository owner slug."),
|
|
588
|
+
repo: slugSchema.describe("Repository slug."),
|
|
589
|
+
title: z.string().trim().min(1).max(200).describe("Issue title."),
|
|
590
|
+
body: z.string().max(15_000).optional().describe("Markdown body description."),
|
|
591
|
+
kind: z.enum([
|
|
592
|
+
"issue",
|
|
593
|
+
"pr"
|
|
594
|
+
]).optional().describe("Record kind: 'issue' (default) or 'pr'."),
|
|
595
|
+
assigneeUsername: slugSchema.optional().describe("Optional username to assign."),
|
|
596
|
+
sourceBranch: gitRefSchema.optional().describe("Source branch (for PR kind)."),
|
|
597
|
+
targetBranch: gitRefSchema.optional().describe("Target branch (for PR kind).")
|
|
598
|
+
},
|
|
599
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
600
|
+
}, async ({ owner, repo, title, body, kind, assigneeUsername, sourceBranch, targetBranch }) => {
|
|
601
|
+
if (readOnly) {
|
|
602
|
+
return readOnlyBlockedResult("ngit_issue_create");
|
|
603
|
+
}
|
|
604
|
+
const endpoint = `/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/issues`;
|
|
605
|
+
const resp = await httpClient.request({
|
|
606
|
+
target: "git",
|
|
607
|
+
method: "POST",
|
|
608
|
+
path: endpoint,
|
|
609
|
+
requireAuth: true,
|
|
610
|
+
body: {
|
|
611
|
+
title,
|
|
612
|
+
body: body || "",
|
|
613
|
+
kind: kind || "issue",
|
|
614
|
+
...(assigneeUsername ? {
|
|
615
|
+
assigneeUsername
|
|
616
|
+
} : {}),
|
|
617
|
+
...(sourceBranch ? {
|
|
618
|
+
sourceBranch
|
|
619
|
+
} : {}),
|
|
620
|
+
...(targetBranch ? {
|
|
621
|
+
targetBranch
|
|
622
|
+
} : {})
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
if (!resp.ok) {
|
|
626
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to create issue.", resp.data);
|
|
627
|
+
}
|
|
628
|
+
return jsonToolResult({
|
|
629
|
+
ok: true,
|
|
630
|
+
latencyMs: resp.latencyMs,
|
|
631
|
+
issue: resp.data
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
// 16. ncli_pipeline_validate
|
|
636
|
+
server.registerTool("ncli_pipeline_validate", {
|
|
637
|
+
title: "Validate .ngit-deploy.json Pipeline Configuration",
|
|
638
|
+
description: "Validates an inline .ngit-deploy.json object or local .ngit-deploy.json file path against N - Git schema and strict security rules (path traversal, shell injection, safe buildScript, safe targetDir).",
|
|
639
|
+
inputSchema: {
|
|
640
|
+
config: z.record(z.unknown()).optional().describe("Inline .ngit-deploy.json configuration object to validate."),
|
|
641
|
+
filePath: z.string().trim().min(1).max(400).optional().describe("Local path to a .ngit-deploy.json file to read and validate.")
|
|
642
|
+
},
|
|
643
|
+
annotations: READ_ONLY_LOCAL_ANNOTATIONS
|
|
644
|
+
}, async ({ config, filePath }) => {
|
|
645
|
+
if (!config && !filePath) {
|
|
646
|
+
return jsonToolResult({
|
|
647
|
+
ok: false,
|
|
648
|
+
valid: false,
|
|
649
|
+
error: "Provide either 'config' (object) or 'filePath' (path to .ngit-deploy.json)."
|
|
650
|
+
}, true);
|
|
651
|
+
}
|
|
652
|
+
let targetConfig = config;
|
|
653
|
+
let resolvedPath;
|
|
654
|
+
if (filePath) {
|
|
655
|
+
try {
|
|
656
|
+
const loaded = loadPipelineConfigFile(filePath);
|
|
657
|
+
resolvedPath = loaded.resolvedPath;
|
|
658
|
+
targetConfig = loaded.parsed;
|
|
659
|
+
}
|
|
660
|
+
catch (err) {
|
|
661
|
+
return jsonToolResult({
|
|
662
|
+
ok: false,
|
|
663
|
+
valid: false,
|
|
664
|
+
error: err instanceof Error ? err.message : "Failed to load .ngit-deploy.json file."
|
|
665
|
+
}, true);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
const validation = validatePipelineConfig(targetConfig);
|
|
669
|
+
return jsonToolResult({
|
|
670
|
+
ok: validation.valid,
|
|
671
|
+
...(resolvedPath ? {
|
|
672
|
+
filePath: resolvedPath
|
|
673
|
+
} : {}),
|
|
674
|
+
...validation
|
|
675
|
+
});
|
|
676
|
+
});
|
|
677
|
+
// 17. ncli_pipeline_generate_config
|
|
678
|
+
server.registerTool("ncli_pipeline_generate_config", {
|
|
679
|
+
title: "Generate Secure .ngit-deploy.json Preview",
|
|
680
|
+
description: "Generates a validated .ngit-deploy.json configuration preview and exact 'ncli pipeline init' + 'ncli runner init' setup commands for Docker or Static projects.",
|
|
681
|
+
inputSchema: {
|
|
682
|
+
type: z.enum([
|
|
683
|
+
"docker",
|
|
684
|
+
"static"
|
|
685
|
+
]).describe("Pipeline type: 'docker' or 'static'."),
|
|
686
|
+
repo: repoFullNameSchema.describe("Repository in owner/repo format (e.g. 'nibgat/my-app')."),
|
|
687
|
+
image: z.string().trim().optional().describe("Docker OCI image slug 'owner/image-name' (defaults to repo slug for docker type)."),
|
|
688
|
+
dockerfile: z.string().trim().optional().describe("Relative Dockerfile path (default: 'Dockerfile')."),
|
|
689
|
+
context: z.string().trim().optional().describe("Relative build context (default: '.')."),
|
|
690
|
+
target: z.string().trim().optional().describe("Optional Docker multi-stage target (e.g. 'production')."),
|
|
691
|
+
composeService: z.string().trim().optional().describe("Optional Docker Compose service name for zero-downtime recreate."),
|
|
692
|
+
buildScript: z.string().trim().optional().describe("Static build script name in package.json (default: 'web:build')."),
|
|
693
|
+
packageManager: z.enum([
|
|
694
|
+
"yarn",
|
|
695
|
+
"npm",
|
|
696
|
+
"pnpm"
|
|
697
|
+
]).optional().describe("Package manager for static builds (default: 'yarn')."),
|
|
698
|
+
distDir: z.string().trim().optional().describe("Static build output directory (default: 'dist')."),
|
|
699
|
+
targetDir: z.string().trim().optional().describe("Static Nginx target directory under /var/www/<site>."),
|
|
700
|
+
onPush: z.boolean().optional().describe("Trigger on push (default: false — release-driven recommended)."),
|
|
701
|
+
healthcheckUrl: safeUrlSchema.optional().describe("Optional HTTPS healthcheck URL."),
|
|
702
|
+
runnerName: slugSchema.optional().describe("Optional self-hosted runner name for generated runner commands.")
|
|
703
|
+
},
|
|
704
|
+
annotations: READ_ONLY_LOCAL_ANNOTATIONS
|
|
705
|
+
}, async (input) => {
|
|
706
|
+
const [ownerPart, repoPart] = input.repo.toLowerCase().split("/");
|
|
707
|
+
const safeOwner = ownerPart || "nibgat";
|
|
708
|
+
const safeRepo = repoPart || "app";
|
|
709
|
+
const runnerName = input.runnerName || `${safeRepo}-prod-runner`;
|
|
710
|
+
let candidate;
|
|
711
|
+
let pipelineInitCommand;
|
|
712
|
+
if (input.type === "docker") {
|
|
713
|
+
const resolvedImage = input.image || `${safeOwner}/${safeRepo}`;
|
|
714
|
+
const resolvedDockerfile = input.dockerfile || "Dockerfile";
|
|
715
|
+
const resolvedContext = input.context || ".";
|
|
716
|
+
const resolvedComposeService = input.composeService || safeRepo;
|
|
717
|
+
candidate = {
|
|
718
|
+
type: "docker",
|
|
719
|
+
image: resolvedImage,
|
|
720
|
+
dockerfile: resolvedDockerfile,
|
|
721
|
+
context: resolvedContext,
|
|
722
|
+
...(input.target ? {
|
|
723
|
+
target: input.target
|
|
724
|
+
} : {
|
|
725
|
+
target: "production"
|
|
726
|
+
}),
|
|
727
|
+
composeService: resolvedComposeService,
|
|
728
|
+
onPush: input.onPush ?? false,
|
|
729
|
+
...(input.healthcheckUrl ? {
|
|
730
|
+
healthcheckUrl: input.healthcheckUrl
|
|
731
|
+
} : {})
|
|
732
|
+
};
|
|
733
|
+
pipelineInitCommand = [
|
|
734
|
+
"ncli pipeline init",
|
|
735
|
+
"--type docker",
|
|
736
|
+
`--image ${resolvedImage}`,
|
|
737
|
+
`--dockerfile ${resolvedDockerfile}`,
|
|
738
|
+
`--target ${input.target || "production"}`,
|
|
739
|
+
`--compose-service ${resolvedComposeService}`,
|
|
740
|
+
`--on-push ${String(input.onPush ?? false)}`
|
|
741
|
+
].join(" ");
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
const resolvedBuildScript = input.buildScript || "web:build";
|
|
745
|
+
const resolvedPackageManager = input.packageManager || "yarn";
|
|
746
|
+
const resolvedDistDir = input.distDir || "dist";
|
|
747
|
+
const resolvedTargetDir = input.targetDir || `/var/www/${safeRepo}`;
|
|
748
|
+
candidate = {
|
|
749
|
+
type: "static",
|
|
750
|
+
packageManager: resolvedPackageManager,
|
|
751
|
+
buildScript: resolvedBuildScript,
|
|
752
|
+
distDir: resolvedDistDir,
|
|
753
|
+
targetDir: resolvedTargetDir,
|
|
754
|
+
onPush: input.onPush ?? false,
|
|
755
|
+
...(input.healthcheckUrl ? {
|
|
756
|
+
healthcheckUrl: input.healthcheckUrl
|
|
757
|
+
} : {})
|
|
758
|
+
};
|
|
759
|
+
pipelineInitCommand = [
|
|
760
|
+
"ncli pipeline init",
|
|
761
|
+
"--type static",
|
|
762
|
+
`--package-manager ${resolvedPackageManager}`,
|
|
763
|
+
`--build-script ${resolvedBuildScript}`,
|
|
764
|
+
`--dist-dir ${resolvedDistDir}`,
|
|
765
|
+
`--target-dir ${resolvedTargetDir}`,
|
|
766
|
+
`--on-push ${String(input.onPush ?? false)}`
|
|
767
|
+
].join(" ");
|
|
768
|
+
}
|
|
769
|
+
const validation = validatePipelineConfig(candidate);
|
|
770
|
+
if (!validation.valid || !validation.normalizedConfig) {
|
|
771
|
+
return jsonToolResult({
|
|
772
|
+
ok: false,
|
|
773
|
+
error: "Generated pipeline configuration failed security or schema validation.",
|
|
774
|
+
diagnostics: validation.diagnostics,
|
|
775
|
+
securityChecks: validation.securityChecks
|
|
776
|
+
}, true);
|
|
777
|
+
}
|
|
778
|
+
return jsonToolResult({
|
|
779
|
+
ok: true,
|
|
780
|
+
repo: `${safeOwner}/${safeRepo}`,
|
|
781
|
+
fileName: ".ngit-deploy.json",
|
|
782
|
+
config: validation.normalizedConfig,
|
|
783
|
+
jsonPreview: JSON.stringify(validation.normalizedConfig, null, 4),
|
|
784
|
+
validation,
|
|
785
|
+
commands: {
|
|
786
|
+
clientPipelineInit: pipelineInitCommand,
|
|
787
|
+
clientValidate: "ncli pipeline validate --file .ngit-deploy.json",
|
|
788
|
+
serverRunnerInit: `ncli runner init --repo ${safeOwner}/${safeRepo} --name ${runnerName}`,
|
|
789
|
+
serverRunnerStart: "ncli runner start --systemd",
|
|
790
|
+
firstRelease: `ncli release create ${safeOwner}/${safeRepo} --tag v1.0.0 --title "v1.0.0" --notes "Initial release"`
|
|
791
|
+
},
|
|
792
|
+
docsUrl: "https://docs.nibgat.space/cli/pipeline"
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
// 18. nmail_domains_list
|
|
796
|
+
server.registerTool("nmail_domains_list", {
|
|
797
|
+
title: "List N - Mail Domains",
|
|
798
|
+
description: "Lists mail domains associated with the authenticated user or organization (GET /nnotifier/sso/domains).",
|
|
799
|
+
inputSchema: {
|
|
800
|
+
organizationID: z.string().trim().max(100).optional().describe("Optional organization UUID filter."),
|
|
801
|
+
appID: z.string().trim().max(100).optional().describe("Optional application UUID filter.")
|
|
802
|
+
},
|
|
803
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
804
|
+
}, async ({ organizationID, appID }) => {
|
|
805
|
+
const endpoint = "/nnotifier/sso/domains";
|
|
806
|
+
const resp = await httpClient.request({
|
|
807
|
+
target: "core",
|
|
808
|
+
method: "GET",
|
|
809
|
+
path: endpoint,
|
|
810
|
+
query: {
|
|
811
|
+
organizationID,
|
|
812
|
+
appID
|
|
813
|
+
},
|
|
814
|
+
requireAuth: true
|
|
815
|
+
});
|
|
816
|
+
if (!resp.ok) {
|
|
817
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list mail domains.", resp.data);
|
|
818
|
+
}
|
|
819
|
+
return jsonToolResult({
|
|
820
|
+
ok: true,
|
|
821
|
+
latencyMs: resp.latencyMs,
|
|
822
|
+
result: resp.data
|
|
823
|
+
});
|
|
824
|
+
});
|
|
825
|
+
// 19. nmail_notifications_list
|
|
826
|
+
server.registerTool("nmail_notifications_list", {
|
|
827
|
+
title: "List N - Notifier Notifications",
|
|
828
|
+
description: "Lists recent account and system notifications from N - Notifier (GET /nnotifier/sso/notifications).",
|
|
829
|
+
inputSchema: {},
|
|
830
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
831
|
+
}, async () => {
|
|
832
|
+
const endpoint = "/nnotifier/sso/notifications";
|
|
833
|
+
const resp = await httpClient.request({
|
|
834
|
+
target: "core",
|
|
835
|
+
method: "GET",
|
|
836
|
+
path: endpoint,
|
|
837
|
+
requireAuth: true
|
|
838
|
+
});
|
|
839
|
+
if (!resp.ok) {
|
|
840
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list notifications.", resp.data);
|
|
841
|
+
}
|
|
842
|
+
return jsonToolResult({
|
|
843
|
+
ok: true,
|
|
844
|
+
latencyMs: resp.latencyMs,
|
|
845
|
+
result: resp.data
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
// 20. nsupport_tickets_list
|
|
849
|
+
server.registerTool("nsupport_tickets_list", {
|
|
850
|
+
title: "List N - Support Tickets",
|
|
851
|
+
description: "Lists support tickets for the authenticated user (GET /front/sso/tickets).",
|
|
852
|
+
inputSchema: {
|
|
853
|
+
status: z.string().trim().max(40).optional().describe("Optional status filter."),
|
|
854
|
+
page: z.number().int().min(1).max(500).optional().describe("Page number (default: 1)."),
|
|
855
|
+
limit: z.number().int().min(1).max(100).optional().describe("Items per page (default: 20).")
|
|
856
|
+
},
|
|
857
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
858
|
+
}, async ({ status, page, limit }) => {
|
|
859
|
+
const endpoint = "/front/sso/tickets";
|
|
860
|
+
const resp = await httpClient.request({
|
|
861
|
+
target: "core",
|
|
862
|
+
method: "GET",
|
|
863
|
+
path: endpoint,
|
|
864
|
+
query: {
|
|
865
|
+
status,
|
|
866
|
+
page,
|
|
867
|
+
limit
|
|
868
|
+
},
|
|
869
|
+
requireAuth: true
|
|
870
|
+
});
|
|
871
|
+
if (!resp.ok) {
|
|
872
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list support tickets.", resp.data);
|
|
873
|
+
}
|
|
874
|
+
return jsonToolResult({
|
|
875
|
+
ok: true,
|
|
876
|
+
latencyMs: resp.latencyMs,
|
|
877
|
+
result: resp.data
|
|
878
|
+
});
|
|
879
|
+
});
|
|
880
|
+
// 21. nsupport_ticket_create (WRITE)
|
|
881
|
+
if (!readOnly) {
|
|
882
|
+
server.registerTool("nsupport_ticket_create", {
|
|
883
|
+
title: "Create N - Support Ticket",
|
|
884
|
+
description: "Opens a new support ticket on N - Support (POST /front/sso/tickets). Disabled in --read-only mode.",
|
|
885
|
+
inputSchema: {
|
|
886
|
+
subject: z.string().trim().min(3).max(180).describe("Concise ticket subject (3-180 characters)."),
|
|
887
|
+
description: z.string().trim().min(10).max(5000).describe("Detailed ticket description (10-5000 characters)."),
|
|
888
|
+
ticketType: z.enum([
|
|
889
|
+
"organization",
|
|
890
|
+
"developer",
|
|
891
|
+
"partner",
|
|
892
|
+
"member"
|
|
893
|
+
]).optional().describe("Ticket track (default: 'developer')."),
|
|
894
|
+
category: z.enum([
|
|
895
|
+
"feature_request",
|
|
896
|
+
"organization",
|
|
897
|
+
"bug_report",
|
|
898
|
+
"technical",
|
|
899
|
+
"security",
|
|
900
|
+
"account",
|
|
901
|
+
"billing",
|
|
902
|
+
"general"
|
|
903
|
+
]).optional().describe("Ticket category (default: 'technical')."),
|
|
904
|
+
priority: z.enum([
|
|
905
|
+
"urgent",
|
|
906
|
+
"normal",
|
|
907
|
+
"high",
|
|
908
|
+
"low"
|
|
909
|
+
]).optional().describe("Ticket priority (default: 'normal')."),
|
|
910
|
+
locale: z.string().trim().regex(/^[a-z]{2}(?:-[A-Z]{2})?$/).optional().describe("Optional BCP-47 locale (e.g. 'tr' or 'en-US').")
|
|
911
|
+
},
|
|
912
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
913
|
+
}, async ({ subject, description, ticketType, category, priority, locale }) => {
|
|
914
|
+
if (readOnly) {
|
|
915
|
+
return readOnlyBlockedResult("nsupport_ticket_create");
|
|
916
|
+
}
|
|
917
|
+
const endpoint = "/front/sso/tickets";
|
|
918
|
+
const resp = await httpClient.request({
|
|
919
|
+
target: "core",
|
|
920
|
+
method: "POST",
|
|
921
|
+
path: endpoint,
|
|
922
|
+
requireAuth: true,
|
|
923
|
+
body: {
|
|
924
|
+
subject,
|
|
925
|
+
description,
|
|
926
|
+
ticketType: ticketType || "developer",
|
|
927
|
+
category: category || "technical",
|
|
928
|
+
priority: priority || "normal",
|
|
929
|
+
source: "nmcp",
|
|
930
|
+
...(locale ? {
|
|
931
|
+
locale
|
|
932
|
+
} : {})
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
if (!resp.ok) {
|
|
936
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to create support ticket.", resp.data);
|
|
937
|
+
}
|
|
938
|
+
return jsonToolResult({
|
|
939
|
+
ok: true,
|
|
940
|
+
latencyMs: resp.latencyMs,
|
|
941
|
+
ticket: resp.data
|
|
942
|
+
});
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
// 22. buyment_get_catalog
|
|
946
|
+
server.registerTool("buyment_get_catalog", {
|
|
947
|
+
title: "Get N - Buyment Public Catalog",
|
|
948
|
+
description: "Fetches public N - Buyment products, plans, and VAT-inclusive TRY pricing (GET /nbuyment/catalog).",
|
|
949
|
+
inputSchema: {},
|
|
950
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
951
|
+
}, async () => {
|
|
952
|
+
const endpoint = "/nbuyment/catalog";
|
|
953
|
+
const resp = await httpClient.request({
|
|
954
|
+
target: "core",
|
|
955
|
+
method: "GET",
|
|
956
|
+
path: endpoint
|
|
957
|
+
});
|
|
958
|
+
if (!resp.ok) {
|
|
959
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to fetch N - Buyment catalog.", resp.data);
|
|
960
|
+
}
|
|
961
|
+
return jsonToolResult({
|
|
962
|
+
ok: true,
|
|
963
|
+
latencyMs: resp.latencyMs,
|
|
964
|
+
catalog: resp.data
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
// 23. buyment_get_wallet
|
|
968
|
+
server.registerTool("buyment_get_wallet", {
|
|
969
|
+
title: "Get N - Buyment Wallet Balance",
|
|
970
|
+
description: "Fetches authenticated user's prepaid TRY wallet balance and recent ledger entries (GET /nbuyment/sso/wallet).",
|
|
971
|
+
inputSchema: {},
|
|
972
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
973
|
+
}, async () => {
|
|
974
|
+
const endpoint = "/nbuyment/sso/wallet";
|
|
975
|
+
const resp = await httpClient.request({
|
|
976
|
+
target: "core",
|
|
977
|
+
method: "GET",
|
|
978
|
+
path: endpoint,
|
|
979
|
+
requireAuth: true
|
|
980
|
+
});
|
|
981
|
+
if (!resp.ok) {
|
|
982
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to fetch wallet.", resp.data);
|
|
983
|
+
}
|
|
984
|
+
return jsonToolResult({
|
|
985
|
+
ok: true,
|
|
986
|
+
latencyMs: resp.latencyMs,
|
|
987
|
+
wallet: resp.data
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
// 24. buyment_list_subscriptions
|
|
991
|
+
server.registerTool("buyment_list_subscriptions", {
|
|
992
|
+
title: "List N - Buyment Subscriptions",
|
|
993
|
+
description: "Lists active and historical subscriptions across NİBGAT services (GET /nbuyment/sso/subscriptions).",
|
|
994
|
+
inputSchema: {},
|
|
995
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
996
|
+
}, async () => {
|
|
997
|
+
const endpoint = "/nbuyment/sso/subscriptions";
|
|
998
|
+
const resp = await httpClient.request({
|
|
999
|
+
target: "core",
|
|
1000
|
+
method: "GET",
|
|
1001
|
+
path: endpoint,
|
|
1002
|
+
requireAuth: true
|
|
1003
|
+
});
|
|
1004
|
+
if (!resp.ok) {
|
|
1005
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list subscriptions.", resp.data);
|
|
1006
|
+
}
|
|
1007
|
+
return jsonToolResult({
|
|
1008
|
+
ok: true,
|
|
1009
|
+
latencyMs: resp.latencyMs,
|
|
1010
|
+
result: resp.data
|
|
1011
|
+
});
|
|
1012
|
+
});
|
|
1013
|
+
// 25. buyment_list_invoices
|
|
1014
|
+
server.registerTool("buyment_list_invoices", {
|
|
1015
|
+
title: "List N - Buyment e-Invoices",
|
|
1016
|
+
description: "Lists Trendyol e-Fatura and e-Arşiv invoices for the authenticated account (GET /nbuyment/sso/invoices).",
|
|
1017
|
+
inputSchema: {},
|
|
1018
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
1019
|
+
}, async () => {
|
|
1020
|
+
const endpoint = "/nbuyment/sso/invoices";
|
|
1021
|
+
const resp = await httpClient.request({
|
|
1022
|
+
target: "core",
|
|
1023
|
+
method: "GET",
|
|
1024
|
+
path: endpoint,
|
|
1025
|
+
requireAuth: true
|
|
1026
|
+
});
|
|
1027
|
+
if (!resp.ok) {
|
|
1028
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list invoices.", resp.data);
|
|
1029
|
+
}
|
|
1030
|
+
return jsonToolResult({
|
|
1031
|
+
ok: true,
|
|
1032
|
+
latencyMs: resp.latencyMs,
|
|
1033
|
+
result: resp.data
|
|
1034
|
+
});
|
|
1035
|
+
});
|
|
1036
|
+
// 26. buyment_create_order (WRITE)
|
|
1037
|
+
if (!readOnly) {
|
|
1038
|
+
server.registerTool("buyment_create_order", {
|
|
1039
|
+
title: "Create N - Buyment Order",
|
|
1040
|
+
description: "Creates a new subscription, one-time, or hardware order on N - Buyment (POST /nbuyment/sso/orders). Disabled in --read-only mode.",
|
|
1041
|
+
inputSchema: {
|
|
1042
|
+
planId: z.string().trim().min(1).max(120).describe("Target N - Buyment plan ID."),
|
|
1043
|
+
orderKind: z.enum([
|
|
1044
|
+
"subscription",
|
|
1045
|
+
"one_time",
|
|
1046
|
+
"hardware"
|
|
1047
|
+
]).optional().describe("Order kind (default: 'subscription')."),
|
|
1048
|
+
paymentMethod: z.enum([
|
|
1049
|
+
"wallet",
|
|
1050
|
+
"paytr_card",
|
|
1051
|
+
"bank_transfer"
|
|
1052
|
+
]).optional().describe("Payment method (default: 'wallet')."),
|
|
1053
|
+
quantity: z.number().int().min(1).max(50).optional().describe("Order quantity (default: 1)."),
|
|
1054
|
+
couponCode: z.string().trim().max(64).optional().describe("Optional discount coupon code.")
|
|
1055
|
+
},
|
|
1056
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
1057
|
+
}, async ({ planId, orderKind, paymentMethod, quantity, couponCode }) => {
|
|
1058
|
+
if (readOnly) {
|
|
1059
|
+
return readOnlyBlockedResult("buyment_create_order");
|
|
1060
|
+
}
|
|
1061
|
+
const endpoint = "/nbuyment/sso/orders";
|
|
1062
|
+
const resp = await httpClient.request({
|
|
1063
|
+
target: "core",
|
|
1064
|
+
method: "POST",
|
|
1065
|
+
path: endpoint,
|
|
1066
|
+
requireAuth: true,
|
|
1067
|
+
body: {
|
|
1068
|
+
planId,
|
|
1069
|
+
orderKind: orderKind || "subscription",
|
|
1070
|
+
paymentMethod: paymentMethod || "wallet",
|
|
1071
|
+
quantity: quantity || 1,
|
|
1072
|
+
...(couponCode ? {
|
|
1073
|
+
couponCode
|
|
1074
|
+
} : {})
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
if (!resp.ok) {
|
|
1078
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to create order.", resp.data);
|
|
1079
|
+
}
|
|
1080
|
+
return jsonToolResult({
|
|
1081
|
+
ok: true,
|
|
1082
|
+
latencyMs: resp.latencyMs,
|
|
1083
|
+
order: resp.data
|
|
1084
|
+
});
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
// 27. cloud_list_regions
|
|
1088
|
+
server.registerTool("cloud_list_regions", {
|
|
1089
|
+
title: "List N - Cloud Global Regions",
|
|
1090
|
+
description: "Lists all 7 N - Cloud global regions showing active (Istanbul tr-ist-1) vs coming_soon locations (GET /ncloud/regions).",
|
|
1091
|
+
inputSchema: {},
|
|
1092
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
1093
|
+
}, async () => {
|
|
1094
|
+
const endpoint = "/ncloud/regions";
|
|
1095
|
+
const resp = await httpClient.request({
|
|
1096
|
+
target: "core",
|
|
1097
|
+
method: "GET",
|
|
1098
|
+
path: endpoint
|
|
1099
|
+
});
|
|
1100
|
+
if (!resp.ok) {
|
|
1101
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list cloud regions.", resp.data);
|
|
1102
|
+
}
|
|
1103
|
+
return jsonToolResult({
|
|
1104
|
+
ok: true,
|
|
1105
|
+
latencyMs: resp.latencyMs,
|
|
1106
|
+
result: resp.data
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
// 28. cloud_get_catalog
|
|
1110
|
+
server.registerTool("cloud_get_catalog", {
|
|
1111
|
+
title: "Get N - Cloud & Physical Hardware Catalog",
|
|
1112
|
+
description: "Fetches live N - Compute, N - Storage, N - Run, N - Metal, and N - Hardware plans with VAT-inclusive TRY pricing (GET /ncloud/catalog).",
|
|
1113
|
+
inputSchema: {
|
|
1114
|
+
region: z.string().trim().max(32).optional().describe("Optional region filter (e.g. 'tr-ist-1').")
|
|
1115
|
+
},
|
|
1116
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
1117
|
+
}, async ({ region }) => {
|
|
1118
|
+
const endpoint = "/ncloud/catalog";
|
|
1119
|
+
const resp = await httpClient.request({
|
|
1120
|
+
target: "core",
|
|
1121
|
+
method: "GET",
|
|
1122
|
+
path: endpoint,
|
|
1123
|
+
query: {
|
|
1124
|
+
region
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
if (!resp.ok) {
|
|
1128
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to fetch cloud catalog.", resp.data);
|
|
1129
|
+
}
|
|
1130
|
+
return jsonToolResult({
|
|
1131
|
+
ok: true,
|
|
1132
|
+
latencyMs: resp.latencyMs,
|
|
1133
|
+
catalog: resp.data
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
// 29. cloud_get_overview
|
|
1137
|
+
server.registerTool("cloud_get_overview", {
|
|
1138
|
+
title: "Get N - Cloud Account Overview",
|
|
1139
|
+
description: "Fetches authenticated user's N - Cloud wallet balance, active resources count, hardware orders, and estimated monthly spend (GET /ncloud/sso/overview).",
|
|
1140
|
+
inputSchema: {},
|
|
1141
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
1142
|
+
}, async () => {
|
|
1143
|
+
const endpoint = "/ncloud/sso/overview";
|
|
1144
|
+
const resp = await httpClient.request({
|
|
1145
|
+
target: "core",
|
|
1146
|
+
method: "GET",
|
|
1147
|
+
path: endpoint,
|
|
1148
|
+
requireAuth: true
|
|
1149
|
+
});
|
|
1150
|
+
if (!resp.ok) {
|
|
1151
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to fetch cloud overview.", resp.data);
|
|
1152
|
+
}
|
|
1153
|
+
return jsonToolResult({
|
|
1154
|
+
ok: true,
|
|
1155
|
+
latencyMs: resp.latencyMs,
|
|
1156
|
+
overview: resp.data
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
// 30. cloud_list_resources
|
|
1160
|
+
server.registerTool("cloud_list_resources", {
|
|
1161
|
+
title: "List N - Cloud Active Resources",
|
|
1162
|
+
description: "Lists active N - Compute, N - Run, N - Storage, N - Net, and N - Vault resources (GET /ncloud/sso/resources).",
|
|
1163
|
+
inputSchema: {
|
|
1164
|
+
type: z.enum([
|
|
1165
|
+
"server",
|
|
1166
|
+
"container",
|
|
1167
|
+
"storage",
|
|
1168
|
+
"vpc",
|
|
1169
|
+
"dns",
|
|
1170
|
+
"backup",
|
|
1171
|
+
"metal"
|
|
1172
|
+
]).optional().describe("Optional resource type filter.")
|
|
1173
|
+
},
|
|
1174
|
+
annotations: READ_ONLY_REMOTE_ANNOTATIONS
|
|
1175
|
+
}, async ({ type }) => {
|
|
1176
|
+
const endpoint = "/ncloud/sso/resources";
|
|
1177
|
+
const resp = await httpClient.request({
|
|
1178
|
+
target: "core",
|
|
1179
|
+
method: "GET",
|
|
1180
|
+
path: endpoint,
|
|
1181
|
+
query: {
|
|
1182
|
+
type
|
|
1183
|
+
},
|
|
1184
|
+
requireAuth: true
|
|
1185
|
+
});
|
|
1186
|
+
if (!resp.ok) {
|
|
1187
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to list cloud resources.", resp.data);
|
|
1188
|
+
}
|
|
1189
|
+
return jsonToolResult({
|
|
1190
|
+
ok: true,
|
|
1191
|
+
latencyMs: resp.latencyMs,
|
|
1192
|
+
result: resp.data
|
|
1193
|
+
});
|
|
1194
|
+
});
|
|
1195
|
+
// 31. cloud_create_server (WRITE)
|
|
1196
|
+
if (!readOnly) {
|
|
1197
|
+
server.registerTool("cloud_create_server", {
|
|
1198
|
+
title: "Create N - Compute Cloud Server",
|
|
1199
|
+
description: "Deploys a new N - Compute cloud server or NVMe VDS in an active region (default: tr-ist-1) via POST /ncloud/sso/servers. Disabled in --read-only mode.",
|
|
1200
|
+
inputSchema: {
|
|
1201
|
+
name: z.string().trim().min(2).max(64).regex(/^[a-zA-Z0-9-]+$/).describe("Server hostname (letters, digits, hyphens)."),
|
|
1202
|
+
planCode: z.string().trim().min(2).max(64).describe("Cloud plan code from cloud_get_catalog."),
|
|
1203
|
+
regionCode: z.string().trim().max(32).optional().describe("Target region code (default: 'tr-ist-1')."),
|
|
1204
|
+
image: z.string().trim().max(64).optional().describe("OS image (default: 'ubuntu-24.04')."),
|
|
1205
|
+
billingMode: z.enum([
|
|
1206
|
+
"monthly_wallet",
|
|
1207
|
+
"hourly_wallet"
|
|
1208
|
+
]).optional().describe("Wallet billing mode (default: 'monthly_wallet').")
|
|
1209
|
+
},
|
|
1210
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
1211
|
+
}, async ({ name, planCode, regionCode, image, billingMode }) => {
|
|
1212
|
+
if (readOnly) {
|
|
1213
|
+
return readOnlyBlockedResult("cloud_create_server");
|
|
1214
|
+
}
|
|
1215
|
+
const endpoint = "/ncloud/sso/servers";
|
|
1216
|
+
const resp = await httpClient.request({
|
|
1217
|
+
target: "core",
|
|
1218
|
+
method: "POST",
|
|
1219
|
+
path: endpoint,
|
|
1220
|
+
requireAuth: true,
|
|
1221
|
+
body: {
|
|
1222
|
+
name,
|
|
1223
|
+
planCode,
|
|
1224
|
+
regionCode: regionCode || "tr-ist-1",
|
|
1225
|
+
image: image || "ubuntu-24.04",
|
|
1226
|
+
billingMode: billingMode || "monthly_wallet"
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
if (!resp.ok) {
|
|
1230
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to create cloud server.", resp.data);
|
|
1231
|
+
}
|
|
1232
|
+
return jsonToolResult({
|
|
1233
|
+
ok: true,
|
|
1234
|
+
latencyMs: resp.latencyMs,
|
|
1235
|
+
server: resp.data
|
|
1236
|
+
});
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
// 32. cloud_server_power (WRITE)
|
|
1240
|
+
if (!readOnly) {
|
|
1241
|
+
server.registerTool("cloud_server_power", {
|
|
1242
|
+
title: "Control N - Compute Server Power",
|
|
1243
|
+
description: "Executes start, stop, reboot, or poweroff on an N - Compute server (POST /ncloud/sso/servers/:id/power). Disabled in --read-only mode.",
|
|
1244
|
+
inputSchema: {
|
|
1245
|
+
resourceId: z.string().trim().min(2).max(120).describe("Target cloud resource ID."),
|
|
1246
|
+
action: z.enum([
|
|
1247
|
+
"start",
|
|
1248
|
+
"stop",
|
|
1249
|
+
"reboot",
|
|
1250
|
+
"poweroff"
|
|
1251
|
+
]).describe("Power action to execute.")
|
|
1252
|
+
},
|
|
1253
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
1254
|
+
}, async ({ resourceId, action }) => {
|
|
1255
|
+
if (readOnly) {
|
|
1256
|
+
return readOnlyBlockedResult("cloud_server_power");
|
|
1257
|
+
}
|
|
1258
|
+
const endpoint = `/ncloud/sso/servers/${encodeURIComponent(resourceId)}/power`;
|
|
1259
|
+
const resp = await httpClient.request({
|
|
1260
|
+
target: "core",
|
|
1261
|
+
method: "POST",
|
|
1262
|
+
path: endpoint,
|
|
1263
|
+
requireAuth: true,
|
|
1264
|
+
body: {
|
|
1265
|
+
action
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
if (!resp.ok) {
|
|
1269
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to apply power action.", resp.data);
|
|
1270
|
+
}
|
|
1271
|
+
return jsonToolResult({
|
|
1272
|
+
ok: true,
|
|
1273
|
+
latencyMs: resp.latencyMs,
|
|
1274
|
+
result: resp.data
|
|
1275
|
+
});
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
// 33. cloud_create_hardware_order (WRITE)
|
|
1279
|
+
if (!readOnly) {
|
|
1280
|
+
server.registerTool("cloud_create_hardware_order", {
|
|
1281
|
+
title: "Create N - Cloud Physical Hardware Order",
|
|
1282
|
+
description: "Places an N - Metal bare-metal rental or N - Hardware purchase order (POST /ncloud/sso/hardware/orders). Disabled in --read-only mode.",
|
|
1283
|
+
inputSchema: {
|
|
1284
|
+
hardwareItemId: z.string().trim().min(2).max(120).describe("Hardware catalog item ID from cloud_get_catalog."),
|
|
1285
|
+
quantity: z.number().int().min(1).max(20).optional().describe("Order quantity (default: 1)."),
|
|
1286
|
+
deliveryOption: z.enum([
|
|
1287
|
+
"colocation_ist1",
|
|
1288
|
+
"shipping"
|
|
1289
|
+
]).optional().describe("Delivery mode: 'colocation_ist1' (Istanbul DC) or 'shipping'."),
|
|
1290
|
+
notes: z.string().trim().max(600).optional().describe("Optional technical or delivery notes.")
|
|
1291
|
+
},
|
|
1292
|
+
annotations: WRITE_REMOTE_ANNOTATIONS
|
|
1293
|
+
}, async ({ hardwareItemId, quantity, deliveryOption, notes }) => {
|
|
1294
|
+
if (readOnly) {
|
|
1295
|
+
return readOnlyBlockedResult("cloud_create_hardware_order");
|
|
1296
|
+
}
|
|
1297
|
+
const endpoint = "/ncloud/sso/hardware/orders";
|
|
1298
|
+
const resp = await httpClient.request({
|
|
1299
|
+
target: "core",
|
|
1300
|
+
method: "POST",
|
|
1301
|
+
path: endpoint,
|
|
1302
|
+
requireAuth: true,
|
|
1303
|
+
body: {
|
|
1304
|
+
hardwareItemId,
|
|
1305
|
+
quantity: quantity || 1,
|
|
1306
|
+
deliveryOption: deliveryOption || "colocation_ist1",
|
|
1307
|
+
...(notes ? {
|
|
1308
|
+
notes
|
|
1309
|
+
} : {})
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
if (!resp.ok) {
|
|
1313
|
+
return apiErrorResult(endpoint, resp.status, resp.errorMessage || "Failed to place hardware order.", resp.data);
|
|
1314
|
+
}
|
|
1315
|
+
return jsonToolResult({
|
|
1316
|
+
ok: true,
|
|
1317
|
+
latencyMs: resp.latencyMs,
|
|
1318
|
+
order: resp.data
|
|
1319
|
+
});
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
//# sourceMappingURL=index.js.map
|