@hatchbox/hatchbox-mcp 0.5.0 → 0.7.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 +10 -3
- package/build/server.js +3 -1
- package/build/tools/apps.js +34 -4
- package/build/tools/firewallRules.js +73 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ One tool per operation, each with a `readOnlyHint` or `destructiveHint` annotati
|
|
|
10
10
|
|---|---|---|
|
|
11
11
|
| Accounts | `hatchbox_list_accounts`, `hatchbox_get_account`, `hatchbox_list_account_apps`, `hatchbox_list_account_clusters`, `hatchbox_list_account_database_clusters`, `hatchbox_list_account_git_providers` | — |
|
|
12
12
|
| User | `hatchbox_get_me` | — |
|
|
13
|
-
| Apps | `hatchbox_get_app` | `hatchbox_create_app`, `hatchbox_update_app`, `hatchbox_restart_app`, `hatchbox_deploy_app`, `hatchbox_enable_app_auto_deploy`, `hatchbox_disable_app_auto_deploy` |
|
|
13
|
+
| Apps | `hatchbox_get_app` | `hatchbox_create_app`, `hatchbox_update_app`, `hatchbox_rename_app`, `hatchbox_enable_app_maintenance`, `hatchbox_disable_app_maintenance`, `hatchbox_restart_app`, `hatchbox_deploy_app`, `hatchbox_enable_app_auto_deploy`, `hatchbox_disable_app_auto_deploy` |
|
|
14
14
|
| Domains | `hatchbox_list_domains`, `hatchbox_get_domain` | `hatchbox_create_domain`, `hatchbox_update_domain`, `hatchbox_delete_domain` |
|
|
15
15
|
| Env vars | — | `hatchbox_create_env_vars`, `hatchbox_update_env_vars`, `hatchbox_delete_env_vars` |
|
|
16
16
|
| Processes | `hatchbox_list_processes`, `hatchbox_get_process` | `hatchbox_create_process`, `hatchbox_update_process`, `hatchbox_delete_process`, `hatchbox_enable_process`, `hatchbox_disable_process`, `hatchbox_restart_process` |
|
|
@@ -18,12 +18,19 @@ 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_rename_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`, `hatchbox_delete_firewall_rule`, and `hatchbox_rename_app`, 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
|
-
`
|
|
27
|
+
`hatchbox_enable_app_maintenance`/`hatchbox_disable_app_maintenance` are *not* async in this sense: they return the updated app record immediately (`maintenance: true`/`false`). The Caddy config reload that actually flips the served page happens on the app's servers in the background, with no log id to poll.
|
|
28
|
+
|
|
29
|
+
`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.
|
|
30
|
+
|
|
31
|
+
`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.
|
|
32
|
+
|
|
33
|
+
`hatchbox_update_app` rejects the `name` field entirely (422) — renaming moves the app's directory and rewrites server config, so it's handled separately by `hatchbox_rename_app`, which also 422s if the new name is unchanged, blank, contains characters other than letters/numbers/hyphens/underscores, or is already taken by another app in the same cluster.
|
|
27
34
|
|
|
28
35
|
## Setup
|
|
29
36
|
|
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.7.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
|
}
|
package/build/tools/apps.js
CHANGED
|
@@ -5,7 +5,6 @@ const appIdSchema = {
|
|
|
5
5
|
};
|
|
6
6
|
const APP_NAME_REGEX = /^[\w-]+$/;
|
|
7
7
|
const appWriteFields = {
|
|
8
|
-
name: z.string().regex(APP_NAME_REGEX).describe("App name, letters/numbers/underscore/hyphen only.").optional(),
|
|
9
8
|
branch: z.string().describe("Git branch to deploy from.").optional(),
|
|
10
9
|
repo_path: z.string().describe("Repository path, e.g. 'org/repo'.").optional(),
|
|
11
10
|
connected_account_id: z
|
|
@@ -50,18 +49,49 @@ export function registerAppsTools(server, client) {
|
|
|
50
49
|
},
|
|
51
50
|
annotations: WRITE,
|
|
52
51
|
}, async (args) => runAction(async () => {
|
|
53
|
-
const { cluster_id } = args;
|
|
54
|
-
return jsonResult(await client.post(`/apps`, { app: { cluster_id, ...appParams(args) } }));
|
|
52
|
+
const { cluster_id, name } = args;
|
|
53
|
+
return jsonResult(await client.post(`/apps`, { app: { cluster_id, name, ...appParams(args) } }));
|
|
55
54
|
}));
|
|
56
55
|
server.registerTool("hatchbox_update_app", {
|
|
57
56
|
title: "Update Hatchbox App",
|
|
58
|
-
description: "Update a Hatchbox app's configuration. Only the fields you pass are changed."
|
|
57
|
+
description: "Update a Hatchbox app's configuration. Only the fields you pass are changed. Renaming isn't supported here " +
|
|
58
|
+
"(a rename moves the app directory and rewrites server config, so it's a separate async operation) — use " +
|
|
59
|
+
"hatchbox_rename_app instead.",
|
|
59
60
|
inputSchema: { ...appIdSchema, ...appWriteFields },
|
|
60
61
|
annotations: WRITE,
|
|
61
62
|
}, async (args) => runAction(async () => {
|
|
62
63
|
const { app_id } = args;
|
|
63
64
|
return jsonResult(await client.patch(`/apps/${app_id}`, { app: appParams(args) }));
|
|
64
65
|
}));
|
|
66
|
+
server.registerTool("hatchbox_rename_app", {
|
|
67
|
+
title: "Rename Hatchbox App",
|
|
68
|
+
description: "Rename a Hatchbox app. Moves the app directory and rewrites every systemd unit on its servers, so it runs " +
|
|
69
|
+
"as a background script rather than a plain field update — the app keeps its old name until the script " +
|
|
70
|
+
"completes. Asynchronous — returns an id (the log id, not named log_id for this endpoint), follow up with " +
|
|
71
|
+
"hatchbox_get_log. Fails with a 422 if the new name matches the current name, is blank, contains characters " +
|
|
72
|
+
"other than letters/numbers/hyphens/underscores, or is already taken by another app in the same cluster.",
|
|
73
|
+
inputSchema: {
|
|
74
|
+
...appIdSchema,
|
|
75
|
+
name: z.string().regex(APP_NAME_REGEX).describe("New app name, letters/numbers/underscore/hyphen only."),
|
|
76
|
+
},
|
|
77
|
+
annotations: WRITE,
|
|
78
|
+
}, async ({ app_id, name }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/rename`, { app: { name } }))));
|
|
79
|
+
server.registerTool("hatchbox_enable_app_maintenance", {
|
|
80
|
+
title: "Enable App Maintenance Mode",
|
|
81
|
+
description: "Put a Hatchbox app into maintenance mode, serving a maintenance page instead of the app. Returns the " +
|
|
82
|
+
"updated app record immediately with `maintenance: true` — the actual Caddy config reload on the app's " +
|
|
83
|
+
"servers happens in the background, with no log id to follow up on.",
|
|
84
|
+
inputSchema: appIdSchema,
|
|
85
|
+
annotations: WRITE,
|
|
86
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/maintenance`))));
|
|
87
|
+
server.registerTool("hatchbox_disable_app_maintenance", {
|
|
88
|
+
title: "Disable App Maintenance Mode",
|
|
89
|
+
description: "Take a Hatchbox app out of maintenance mode. Returns the updated app record immediately with " +
|
|
90
|
+
"`maintenance: false` — the actual Caddy config reload on the app's servers happens in the background, " +
|
|
91
|
+
"with no log id to follow up on.",
|
|
92
|
+
inputSchema: appIdSchema,
|
|
93
|
+
annotations: WRITE,
|
|
94
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.delete(`/apps/${app_id}/maintenance`))));
|
|
65
95
|
server.registerTool("hatchbox_restart_app", {
|
|
66
96
|
title: "Restart Hatchbox App",
|
|
67
97
|
description: "Restart every process on a Hatchbox app. Asynchronous — returns a log id, follow up with hatchbox_get_log " +
|
|
@@ -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
|
+
}
|