@mguttmann/hetzner-cloud-mcp 0.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/.env.example +25 -0
- package/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/config.js +53 -0
- package/dist/config.js.map +1 -0
- package/dist/http/action-polling.js +34 -0
- package/dist/http/action-polling.js.map +1 -0
- package/dist/http/client.js +94 -0
- package/dist/http/client.js.map +1 -0
- package/dist/http/errors.js +36 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/pagination.js +51 -0
- package/dist/http/pagination.js.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.js +12 -0
- package/dist/logger.js.map +1 -0
- package/dist/server.js +37 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/_error.js +25 -0
- package/dist/tools/_error.js.map +1 -0
- package/dist/tools/confirm.js +46 -0
- package/dist/tools/confirm.js.map +1 -0
- package/dist/tools/generated/operations.js +49725 -0
- package/dist/tools/generated/operations.js.map +1 -0
- package/dist/tools/generated/tools.js +162 -0
- package/dist/tools/generated/tools.js.map +1 -0
- package/dist/tools/raw_request.js +87 -0
- package/dist/tools/raw_request.js.map +1 -0
- package/dist/tools/registry.js +19 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/wait_action.js +37 -0
- package/dist/tools/wait_action.js.map +1 -0
- package/dist/tools/wrappers/_server_action.js +23 -0
- package/dist/tools/wrappers/_server_action.js.map +1 -0
- package/dist/tools/wrappers/apply_firewall_to_server.js +47 -0
- package/dist/tools/wrappers/apply_firewall_to_server.js.map +1 -0
- package/dist/tools/wrappers/server_backup.js +25 -0
- package/dist/tools/wrappers/server_backup.js.map +1 -0
- package/dist/tools/wrappers/server_change_type.js +27 -0
- package/dist/tools/wrappers/server_change_type.js.map +1 -0
- package/dist/tools/wrappers/server_get.js +53 -0
- package/dist/tools/wrappers/server_get.js.map +1 -0
- package/dist/tools/wrappers/server_list.js +69 -0
- package/dist/tools/wrappers/server_list.js.map +1 -0
- package/dist/tools/wrappers/server_metrics.js +55 -0
- package/dist/tools/wrappers/server_metrics.js.map +1 -0
- package/dist/tools/wrappers/server_power.js +32 -0
- package/dist/tools/wrappers/server_power.js.map +1 -0
- package/dist/tools/wrappers/server_rebuild.js +34 -0
- package/dist/tools/wrappers/server_rebuild.js.map +1 -0
- package/dist/tools/wrappers/server_rescue.js +34 -0
- package/dist/tools/wrappers/server_rescue.js.map +1 -0
- package/dist/tools/wrappers/server_snapshot.js +33 -0
- package/dist/tools/wrappers/server_snapshot.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +72 -0
- package/scripts/generate.ts +245 -0
- package/scripts/refresh-snapshot.ts +33 -0
- package/scripts/refresh-spec.ts +35 -0
- package/specs/cloud.spec.json +77624 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { mapErrorResponse } from "../http/errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* If the HTTP response is a Hetzner error (non-2xx with the standard
|
|
4
|
+
* `{ error: { code, message, details } }` envelope, or any other non-2xx),
|
|
5
|
+
* convert it into a `ToolResult` with `isError: true` carrying the typed
|
|
6
|
+
* `HetznerApiError.toString()` payload.
|
|
7
|
+
*
|
|
8
|
+
* Returns `null` for successful responses, so call sites can simply do:
|
|
9
|
+
*
|
|
10
|
+
* const errResult = asToolError(res);
|
|
11
|
+
* if (errResult) return errResult;
|
|
12
|
+
*
|
|
13
|
+
* Keep the helper inert when the response is 2xx/3xx — the happy-path code
|
|
14
|
+
* stays untouched.
|
|
15
|
+
*/
|
|
16
|
+
export function asToolError(res) {
|
|
17
|
+
const err = mapErrorResponse(res.status, res.body);
|
|
18
|
+
if (!err)
|
|
19
|
+
return null;
|
|
20
|
+
return {
|
|
21
|
+
content: [{ type: "text", text: err.toString() }],
|
|
22
|
+
isError: true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_error.js","sourceRoot":"","sources":["../../src/tools/_error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAI,GAAoB;IACjD,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;QACjD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function shouldGuard(tool, enabled) {
|
|
2
|
+
if (!enabled)
|
|
3
|
+
return false;
|
|
4
|
+
return tool.annotations.destructiveHint || !tool.annotations.readOnlyHint;
|
|
5
|
+
}
|
|
6
|
+
function previewResult(tool, input) {
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{
|
|
10
|
+
type: "text",
|
|
11
|
+
text: `PREVIEW — would execute ${tool.name}\n` +
|
|
12
|
+
`Input: ${JSON.stringify(input, null, 2)}\n` +
|
|
13
|
+
`To execute, retry the same call with confirm: "YES".`,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function withConfirmGuard(tool, enabled) {
|
|
19
|
+
if (!shouldGuard(tool, enabled))
|
|
20
|
+
return tool;
|
|
21
|
+
const props = {
|
|
22
|
+
...tool.inputSchema.properties,
|
|
23
|
+
confirm: {
|
|
24
|
+
type: "string",
|
|
25
|
+
enum: ["YES"],
|
|
26
|
+
description: 'Set to "YES" to actually execute. Without this, the tool returns a preview only.',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const inputSchema = {
|
|
30
|
+
...tool.inputSchema,
|
|
31
|
+
properties: props,
|
|
32
|
+
};
|
|
33
|
+
const originalHandler = tool.handler;
|
|
34
|
+
return {
|
|
35
|
+
...tool,
|
|
36
|
+
inputSchema,
|
|
37
|
+
handler: async (input) => {
|
|
38
|
+
if (input.confirm !== "YES") {
|
|
39
|
+
return previewResult(tool, input);
|
|
40
|
+
}
|
|
41
|
+
const { confirm: _drop, ...rest } = input;
|
|
42
|
+
return originalHandler(rest);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../src/tools/confirm.ts"],"names":[],"mappings":"AAEA,SAAS,WAAW,CAAC,IAAa,EAAE,OAAgB;IAClD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;AAC5E,CAAC;AAED,SAAS,aAAa,CAAC,IAAa,EAAE,KAA8B;IAClE,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EACF,2BAA2B,IAAI,CAAC,IAAI,IAAI;oBACxC,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;oBAC5C,sDAAsD;aACzD;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAa,EAAE,OAAgB;IAC9D,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7C,MAAM,KAAK,GAAG;QACZ,GAAI,IAAI,CAAC,WAAwD,CAAC,UAAU;QAC5E,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,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