@hatchbox/hatchbox-mcp 0.4.0 → 0.5.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 +3 -1
- package/build/client.js +7 -0
- package/build/server.js +1 -1
- package/build/tools/logs.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,10 +19,12 @@ One tool per operation, each with a `readOnlyHint` or `destructiveHint` annotati
|
|
|
19
19
|
| Clusters | `hatchbox_get_cluster` (embeds servers) | — |
|
|
20
20
|
| Servers | `hatchbox_list_servers`, `hatchbox_get_server` | `hatchbox_provision_server`, `hatchbox_reboot_server` |
|
|
21
21
|
| Backups | `hatchbox_get_latest_backup`, `hatchbox_get_backup_configuration` | `hatchbox_create_backup`, `hatchbox_test_backup_connection`, `hatchbox_update_backup_configuration`, `hatchbox_disable_backups` |
|
|
22
|
-
| Logs | `hatchbox_get_log` | — |
|
|
22
|
+
| Logs | `hatchbox_list_app_logs`, `hatchbox_get_log` | — |
|
|
23
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 `hatchbox_disable_process` are asynchronous: they return a log id (as `log_id`, except `hatchbox_delete_process` which returns 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
25
|
|
|
26
|
+
`hatchbox_list_app_logs` is paginated (the only paginated tool so far): it returns `{ logs, pagination }`, where `pagination` carries `current_page`/`total_pages`/`total_count`/`page_limit`. `limit` defaults to and is capped at 100 server-side.
|
|
27
|
+
|
|
26
28
|
## Setup
|
|
27
29
|
|
|
28
30
|
1. **Get an API token.** Log into your Hatchbox web app, go to `/api_tokens` → New API Token, name it, and copy the revealed token value.
|
package/build/client.js
CHANGED
|
@@ -24,6 +24,10 @@ export class HatchboxClient {
|
|
|
24
24
|
async get(path, query) {
|
|
25
25
|
return this.request("GET", path, { query });
|
|
26
26
|
}
|
|
27
|
+
/** For paginated endpoints, which advertise page state in response headers rather than the JSON body. */
|
|
28
|
+
async getPaginated(path, query) {
|
|
29
|
+
return this.request("GET", path, { query, includeHeaders: true });
|
|
30
|
+
}
|
|
27
31
|
async post(path, body) {
|
|
28
32
|
return this.request("POST", path, { body });
|
|
29
33
|
}
|
|
@@ -54,6 +58,9 @@ export class HatchboxClient {
|
|
|
54
58
|
if (!response.ok) {
|
|
55
59
|
throw new HatchboxApiError(response.status, describeError(response.status, parsed), parsed);
|
|
56
60
|
}
|
|
61
|
+
if (opts.includeHeaders) {
|
|
62
|
+
return { data: parsed, headers: Object.fromEntries(response.headers.entries()) };
|
|
63
|
+
}
|
|
57
64
|
return parsed;
|
|
58
65
|
}
|
|
59
66
|
}
|
package/build/server.js
CHANGED
|
@@ -14,7 +14,7 @@ import { registerLogsTools } from "./tools/logs.js";
|
|
|
14
14
|
export function createServer(client) {
|
|
15
15
|
const server = new McpServer({
|
|
16
16
|
name: "hatchbox-mcp",
|
|
17
|
-
version: "0.
|
|
17
|
+
version: "0.5.0",
|
|
18
18
|
});
|
|
19
19
|
registerAccountsTools(server, client);
|
|
20
20
|
registerMeTools(server, client);
|
package/build/tools/logs.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { jsonResult, READ_ONLY, runAction } from "./helpers.js";
|
|
3
3
|
export function registerLogsTools(server, client) {
|
|
4
|
+
server.registerTool("hatchbox_list_app_logs", {
|
|
5
|
+
title: "List App Logs",
|
|
6
|
+
description: "List a Hatchbox app's job logs (deploys, restarts, backups, provisioning), newest first — including " +
|
|
7
|
+
"auto-deploys triggered by a git push, not just ones started through this API. Summaries only, without " +
|
|
8
|
+
"the log body (use hatchbox_get_log for a single entry's full body). Paginated: results come back as " +
|
|
9
|
+
"`{ logs, pagination }`, where `pagination` has current_page/total_pages/total_count/page_limit; " +
|
|
10
|
+
"`limit` is capped at 100 server-side regardless of what's requested.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
app_id: z.number().int().describe("Numeric app id."),
|
|
13
|
+
page: z.number().int().optional().describe("Page number, 1-indexed. Defaults to 1."),
|
|
14
|
+
limit: z.number().int().optional().describe("Results per page. Defaults to and is capped at 100."),
|
|
15
|
+
},
|
|
16
|
+
annotations: READ_ONLY,
|
|
17
|
+
}, async ({ app_id, page, limit }) => runAction(async () => {
|
|
18
|
+
const { data, headers } = await client.getPaginated(`/apps/${app_id}/logs`, { page, limit });
|
|
19
|
+
return jsonResult({
|
|
20
|
+
logs: data,
|
|
21
|
+
pagination: {
|
|
22
|
+
current_page: Number(headers["current-page"]),
|
|
23
|
+
total_pages: Number(headers["total-pages"]),
|
|
24
|
+
total_count: Number(headers["total-count"]),
|
|
25
|
+
page_limit: Number(headers["page-limit"]),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
4
29
|
server.registerTool("hatchbox_get_log", {
|
|
5
30
|
title: "Get Hatchbox Log",
|
|
6
31
|
description: "Read a Hatchbox job log (deploys, restarts, backups, provisioning) and its child logs. Poll this after " +
|