@hatchbox/hatchbox-mcp 0.5.0 → 0.6.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 +5 -2
- package/build/server.js +3 -1
- package/build/tools/firewallRules.js +73 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,12 +18,15 @@ One tool per operation, each with a `readOnlyHint` or `destructiveHint` annotati
|
|
|
18
18
|
| Databases | `hatchbox_list_app_databases`, `hatchbox_get_app_database`, `hatchbox_list_cluster_databases`, `hatchbox_get_cluster_database` | `hatchbox_create_database`, `hatchbox_update_database`, `hatchbox_attach_database`, `hatchbox_detach_database` |
|
|
19
19
|
| Clusters | `hatchbox_get_cluster` (embeds servers) | — |
|
|
20
20
|
| Servers | `hatchbox_list_servers`, `hatchbox_get_server` | `hatchbox_provision_server`, `hatchbox_reboot_server` |
|
|
21
|
+
| Firewall rules | `hatchbox_list_firewall_rules`, `hatchbox_get_firewall_rule` | `hatchbox_create_firewall_rule`, `hatchbox_delete_firewall_rule` |
|
|
21
22
|
| Backups | `hatchbox_get_latest_backup`, `hatchbox_get_backup_configuration` | `hatchbox_create_backup`, `hatchbox_test_backup_connection`, `hatchbox_update_backup_configuration`, `hatchbox_disable_backups` |
|
|
22
23
|
| Logs | `hatchbox_list_app_logs`, `hatchbox_get_log` | — |
|
|
23
24
|
|
|
24
|
-
`hatchbox_restart_app`, `hatchbox_deploy_app`, `hatchbox_create_backup`, `hatchbox_test_backup_connection`, `hatchbox_update_backup_configuration`, `hatchbox_disable_backups`, `hatchbox_provision_server`, `hatchbox_reboot_server`, `hatchbox_create_process`, `hatchbox_update_process`, `hatchbox_delete_process`, `hatchbox_enable_process`, and `
|
|
25
|
+
`hatchbox_restart_app`, `hatchbox_deploy_app`, `hatchbox_create_backup`, `hatchbox_test_backup_connection`, `hatchbox_update_backup_configuration`, `hatchbox_disable_backups`, `hatchbox_provision_server`, `hatchbox_reboot_server`, `hatchbox_create_process`, `hatchbox_update_process`, `hatchbox_delete_process`, `hatchbox_enable_process`, `hatchbox_disable_process`, `hatchbox_create_firewall_rule`, and `hatchbox_delete_firewall_rule` are asynchronous: they return a log id (as `log_id`, except `hatchbox_delete_process` and `hatchbox_delete_firewall_rule`, which return it as `id`) you follow up on with `hatchbox_get_log` until `state` is `completed`/`failed`/`aborted`. `hatchbox_enable_process`/`hatchbox_disable_process` return no log id when the process was already in that state (a no-op).
|
|
25
26
|
|
|
26
|
-
`hatchbox_list_app_logs`
|
|
27
|
+
`hatchbox_list_app_logs` and `hatchbox_list_firewall_rules` are paginated: they return `{ logs, pagination }` / `{ firewall_rules, pagination }` respectively, where `pagination` carries `current_page`/`total_pages`/`total_count`/`page_limit`. `limit` defaults to and is capped at 100 server-side.
|
|
28
|
+
|
|
29
|
+
`hatchbox_delete_firewall_rule` fails with a 422 if the rule is one Hatchbox manages itself (SSH, and 80/443 on web servers) — check the `removable` field from `hatchbox_list_firewall_rules`/`hatchbox_get_firewall_rule` before attempting to delete a rule.
|
|
27
30
|
|
|
28
31
|
## Setup
|
|
29
32
|
|
package/build/server.js
CHANGED
|
@@ -11,10 +11,11 @@ import { registerClustersTools } from "./tools/clusters.js";
|
|
|
11
11
|
import { registerServersTools } from "./tools/servers.js";
|
|
12
12
|
import { registerBackupsTools } from "./tools/backups.js";
|
|
13
13
|
import { registerLogsTools } from "./tools/logs.js";
|
|
14
|
+
import { registerFirewallRulesTools } from "./tools/firewallRules.js";
|
|
14
15
|
export function createServer(client) {
|
|
15
16
|
const server = new McpServer({
|
|
16
17
|
name: "hatchbox-mcp",
|
|
17
|
-
version: "0.
|
|
18
|
+
version: "0.6.0",
|
|
18
19
|
});
|
|
19
20
|
registerAccountsTools(server, client);
|
|
20
21
|
registerMeTools(server, client);
|
|
@@ -28,5 +29,6 @@ export function createServer(client) {
|
|
|
28
29
|
registerServersTools(server, client);
|
|
29
30
|
registerBackupsTools(server, client);
|
|
30
31
|
registerLogsTools(server, client);
|
|
32
|
+
registerFirewallRulesTools(server, client);
|
|
31
33
|
return server;
|
|
32
34
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, READ_ONLY, runAction, WRITE } from "./helpers.js";
|
|
3
|
+
const serverIdSchema = {
|
|
4
|
+
cluster_id: z.number().int().describe("Numeric cluster id (see hatchbox_list_account_clusters)."),
|
|
5
|
+
server_id: z.number().int().describe("Numeric server id (see hatchbox_list_servers)."),
|
|
6
|
+
};
|
|
7
|
+
const firewallRuleIdSchema = {
|
|
8
|
+
...serverIdSchema,
|
|
9
|
+
firewall_rule_id: z.number().int().describe("Numeric firewall rule id (see hatchbox_list_firewall_rules)."),
|
|
10
|
+
};
|
|
11
|
+
export function registerFirewallRulesTools(server, client) {
|
|
12
|
+
server.registerTool("hatchbox_list_firewall_rules", {
|
|
13
|
+
title: "List Server Firewall Rules",
|
|
14
|
+
description: "List the firewall (ufw) rules on a Hatchbox server, lowest port first. Paginated: results come back as " +
|
|
15
|
+
"`{ firewall_rules, pagination }`, where `pagination` has current_page/total_pages/total_count/page_limit; " +
|
|
16
|
+
"`limit` is capped at 100 server-side regardless of what's requested.",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
...serverIdSchema,
|
|
19
|
+
page: z.number().int().optional().describe("Page number, 1-indexed. Defaults to 1."),
|
|
20
|
+
limit: z.number().int().optional().describe("Results per page. Defaults to and is capped at 100."),
|
|
21
|
+
},
|
|
22
|
+
annotations: READ_ONLY,
|
|
23
|
+
}, async ({ cluster_id, server_id, page, limit }) => runAction(async () => {
|
|
24
|
+
const { data, headers } = await client.getPaginated(`/clusters/${cluster_id}/servers/${server_id}/firewall_rules`, {
|
|
25
|
+
page,
|
|
26
|
+
limit,
|
|
27
|
+
});
|
|
28
|
+
return jsonResult({
|
|
29
|
+
firewall_rules: data,
|
|
30
|
+
pagination: {
|
|
31
|
+
current_page: Number(headers["current-page"]),
|
|
32
|
+
total_pages: Number(headers["total-pages"]),
|
|
33
|
+
total_count: Number(headers["total-count"]),
|
|
34
|
+
page_limit: Number(headers["page-limit"]),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}));
|
|
38
|
+
server.registerTool("hatchbox_get_firewall_rule", {
|
|
39
|
+
title: "Get Server Firewall Rule",
|
|
40
|
+
description: "Fetch a single firewall rule on a Hatchbox server.",
|
|
41
|
+
inputSchema: firewallRuleIdSchema,
|
|
42
|
+
annotations: READ_ONLY,
|
|
43
|
+
}, async ({ cluster_id, server_id, firewall_rule_id }) => runAction(async () => jsonResult(await client.get(`/clusters/${cluster_id}/servers/${server_id}/firewall_rules/${firewall_rule_id}`))));
|
|
44
|
+
server.registerTool("hatchbox_create_firewall_rule", {
|
|
45
|
+
title: "Create Server Firewall Rule",
|
|
46
|
+
description: "Add a firewall (ufw) rule to a Hatchbox server. Works even if the server has no IP address yet — the rule " +
|
|
47
|
+
"is applied the next time the server is provisioned. Fails with a 422 if it duplicates an existing rule " +
|
|
48
|
+
"(same port/action/from) or if `from` isn't a valid IP address or CIDR range. Asynchronous — returns the " +
|
|
49
|
+
"created record plus a log_id, follow up with hatchbox_get_log.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
...serverIdSchema,
|
|
52
|
+
port: z.number().int().min(0).max(65535).describe("Port number, 0-65535."),
|
|
53
|
+
action: z.enum(["allow", "deny"]).optional().describe("Defaults to 'allow'."),
|
|
54
|
+
from: z
|
|
55
|
+
.string()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Restrict the rule to a single IP address or CIDR range. Omit to apply it to any address."),
|
|
58
|
+
description: z.string().optional().describe("Free-text label for the rule."),
|
|
59
|
+
},
|
|
60
|
+
annotations: WRITE,
|
|
61
|
+
}, async ({ cluster_id, server_id, port, action, from, description }) => runAction(async () => jsonResult(await client.post(`/clusters/${cluster_id}/servers/${server_id}/firewall_rules`, {
|
|
62
|
+
firewall_rule: { port, action, from, description },
|
|
63
|
+
}))));
|
|
64
|
+
server.registerTool("hatchbox_delete_firewall_rule", {
|
|
65
|
+
title: "Delete Server Firewall Rule",
|
|
66
|
+
description: "Remove a firewall rule from a Hatchbox server. Fails with a 422 if the rule is one Hatchbox manages itself " +
|
|
67
|
+
"(SSH, and 80/443 on web servers — check `removable` on the record) or if the server has no reachable IP " +
|
|
68
|
+
"address. Asynchronous — returns an id (the log id, not named log_id for this endpoint), follow up with " +
|
|
69
|
+
"hatchbox_get_log.",
|
|
70
|
+
inputSchema: firewallRuleIdSchema,
|
|
71
|
+
annotations: WRITE,
|
|
72
|
+
}, async ({ cluster_id, server_id, firewall_rule_id }) => runAction(async () => jsonResult(await client.delete(`/clusters/${cluster_id}/servers/${server_id}/firewall_rules/${firewall_rule_id}`))));
|
|
73
|
+
}
|