@hatchbox/hatchbox-mcp 0.1.0 → 0.2.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 CHANGED
@@ -14,6 +14,7 @@ One tool per operation, each with a `readOnlyHint` or `destructiveHint` annotati
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_restart_process` |
17
+ | Cron jobs | `hatchbox_list_cron_jobs`, `hatchbox_get_cron_job` | `hatchbox_create_cron_job`, `hatchbox_update_cron_job`, `hatchbox_delete_cron_job` |
17
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` |
18
19
  | Clusters | `hatchbox_get_cluster` (embeds servers) | — |
19
20
  | Servers | `hatchbox_list_servers`, `hatchbox_get_server` | — |
package/build/server.js CHANGED
@@ -5,6 +5,7 @@ import { registerAppsTools } from "./tools/apps.js";
5
5
  import { registerDomainsTools } from "./tools/domains.js";
6
6
  import { registerEnvVarsTools } from "./tools/envVars.js";
7
7
  import { registerProcessesTools } from "./tools/processes.js";
8
+ import { registerCronJobsTools } from "./tools/cronJobs.js";
8
9
  import { registerDatabasesTools } from "./tools/databases.js";
9
10
  import { registerClustersTools } from "./tools/clusters.js";
10
11
  import { registerServersTools } from "./tools/servers.js";
@@ -13,7 +14,7 @@ import { registerLogsTools } from "./tools/logs.js";
13
14
  export function createServer(client) {
14
15
  const server = new McpServer({
15
16
  name: "hatchbox-mcp",
16
- version: "0.1.0",
17
+ version: "0.2.0",
17
18
  });
18
19
  registerAccountsTools(server, client);
19
20
  registerMeTools(server, client);
@@ -21,6 +22,7 @@ export function createServer(client) {
21
22
  registerDomainsTools(server, client);
22
23
  registerEnvVarsTools(server, client);
23
24
  registerProcessesTools(server, client);
25
+ registerCronJobsTools(server, client);
24
26
  registerDatabasesTools(server, client);
25
27
  registerClustersTools(server, client);
26
28
  registerServersTools(server, client);
@@ -0,0 +1,88 @@
1
+ import { z } from "zod";
2
+ import { jsonResult, READ_ONLY, runAction, textResult, WRITE } from "./helpers.js";
3
+ const appIdSchema = {
4
+ app_id: z.number().int().describe("Numeric app id."),
5
+ };
6
+ const cronJobIdSchema = {
7
+ ...appIdSchema,
8
+ cron_job_id: z.number().int().describe("Numeric cron job id (see hatchbox_list_cron_jobs)."),
9
+ };
10
+ const cronJobWriteFields = {
11
+ name: z.string().describe("Cron job name.").optional(),
12
+ run_at: z
13
+ .string()
14
+ .describe("Cron expression for when to run, e.g. '0 0 * * *' (daily at midnight UTC). Must be a valid cron expression.")
15
+ .optional(),
16
+ command: z.string().describe("Shell command to run, executed from the app's current release directory.").optional(),
17
+ appsignal: z
18
+ .boolean()
19
+ .describe("Wrap the command with AppSignal cron monitoring. Requires AppSignal to already be connected to the app — " +
20
+ "fails with a 422 otherwise.")
21
+ .optional(),
22
+ honeybadger_checkin_id: z
23
+ .string()
24
+ .describe("Wrap the command with a Honeybadger check-in, using this check-in id.")
25
+ .optional(),
26
+ };
27
+ const CRON_JOB_WRITE_KEYS = Object.keys(cronJobWriteFields);
28
+ function cronJobParams(args) {
29
+ const cronJob = {};
30
+ for (const key of CRON_JOB_WRITE_KEYS) {
31
+ if (args[key] !== undefined)
32
+ cronJob[key] = args[key];
33
+ }
34
+ return cronJob;
35
+ }
36
+ const ASYNC_APPLY_NOTE = "Applied to the server asynchronously via a background job with no pollable status — unlike " +
37
+ "hatchbox_restart_app/hatchbox_deploy_app, there's no log id to follow up on.";
38
+ export function registerCronJobsTools(server, client) {
39
+ server.registerTool("hatchbox_list_cron_jobs", {
40
+ title: "List App Cron Jobs",
41
+ description: "List the cron jobs configured on a Hatchbox app.",
42
+ inputSchema: appIdSchema,
43
+ annotations: READ_ONLY,
44
+ }, async ({ app_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/cron_jobs`))));
45
+ server.registerTool("hatchbox_get_cron_job", {
46
+ title: "Get App Cron Job",
47
+ description: "Fetch a single cron job configured on a Hatchbox app.",
48
+ inputSchema: cronJobIdSchema,
49
+ annotations: READ_ONLY,
50
+ }, async ({ app_id, cron_job_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/cron_jobs/${cron_job_id}`))));
51
+ server.registerTool("hatchbox_create_cron_job", {
52
+ title: "Create App Cron Job",
53
+ description: `Create a new cron job on a Hatchbox app. Fails with a 422 if the app's cluster has no active server with ` +
54
+ `the cron role. ${ASYNC_APPLY_NOTE}`,
55
+ inputSchema: {
56
+ ...cronJobWriteFields,
57
+ ...appIdSchema,
58
+ name: z.string().describe("Cron job name."),
59
+ run_at: z
60
+ .string()
61
+ .describe("Cron expression for when to run, e.g. '0 0 * * *' (daily at midnight UTC). Must be a valid cron expression."),
62
+ command: z.string().describe("Shell command to run, executed from the app's current release directory."),
63
+ },
64
+ annotations: WRITE,
65
+ }, async (args) => runAction(async () => {
66
+ const { app_id } = args;
67
+ return jsonResult(await client.post(`/apps/${app_id}/cron_jobs`, { cron_job: cronJobParams(args) }));
68
+ }));
69
+ server.registerTool("hatchbox_update_cron_job", {
70
+ title: "Update App Cron Job",
71
+ description: `Update a cron job on a Hatchbox app. Only the fields you pass are changed. Fails with a 422 if the app's ` +
72
+ `cluster has no active server with the cron role. ${ASYNC_APPLY_NOTE}`,
73
+ inputSchema: { ...cronJobIdSchema, ...cronJobWriteFields },
74
+ annotations: WRITE,
75
+ }, async (args) => runAction(async () => {
76
+ const { app_id, cron_job_id } = args;
77
+ return jsonResult(await client.patch(`/apps/${app_id}/cron_jobs/${cron_job_id}`, { cron_job: cronJobParams(args) }));
78
+ }));
79
+ server.registerTool("hatchbox_delete_cron_job", {
80
+ title: "Delete App Cron Job",
81
+ description: `Delete a cron job from a Hatchbox app. Allowed even if the app's cluster has no active cron server. ${ASYNC_APPLY_NOTE}`,
82
+ inputSchema: cronJobIdSchema,
83
+ annotations: WRITE,
84
+ }, async ({ app_id, cron_job_id }) => runAction(async () => {
85
+ await client.delete(`/apps/${app_id}/cron_jobs/${cron_job_id}`);
86
+ return textResult(`Deleted cron job ${cron_job_id} from app ${app_id}.`);
87
+ }));
88
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchbox/hatchbox-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server that wraps the Hatchbox /api/v1 API",
5
5
  "type": "module",
6
6
  "main": "build/index.js",