@hatchbox/hatchbox-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/LICENSE +21 -0
- package/README.md +81 -0
- package/build/client.js +98 -0
- package/build/index.js +14 -0
- package/build/server.js +30 -0
- package/build/tools/accounts.js +44 -0
- package/build/tools/apps.js +97 -0
- package/build/tools/backups.js +22 -0
- package/build/tools/clusters.js +13 -0
- package/build/tools/databases.js +97 -0
- package/build/tools/domains.js +47 -0
- package/build/tools/envVars.js +41 -0
- package/build/tools/helpers.js +26 -0
- package/build/tools/logs.js +13 -0
- package/build/tools/me.js +10 -0
- package/build/tools/processes.js +33 -0
- package/build/tools/servers.js +23 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hatchbox
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# hatchbox-mcp
|
|
2
|
+
|
|
3
|
+
An MCP server that wraps Hatchbox's `/api/v1` API, so an LLM agent can inspect and operate your Hatchbox apps, domains, databases, and servers.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
One tool per operation, each with a `readOnlyHint` or `destructiveHint` annotation, grouped by resource:
|
|
8
|
+
|
|
9
|
+
| Resource | Read | Write |
|
|
10
|
+
|---|---|---|
|
|
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
|
+
| 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` |
|
|
14
|
+
| Domains | `hatchbox_list_domains`, `hatchbox_get_domain` | `hatchbox_create_domain`, `hatchbox_update_domain`, `hatchbox_delete_domain` |
|
|
15
|
+
| Env vars | — | `hatchbox_create_env_vars`, `hatchbox_update_env_vars`, `hatchbox_delete_env_vars` |
|
|
16
|
+
| Processes | `hatchbox_list_processes`, `hatchbox_get_process` | `hatchbox_restart_process` |
|
|
17
|
+
| 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
|
+
| Clusters | `hatchbox_get_cluster` (embeds servers) | — |
|
|
19
|
+
| Servers | `hatchbox_list_servers`, `hatchbox_get_server` | — |
|
|
20
|
+
| Backups | `hatchbox_get_latest_backup` | `hatchbox_create_backup` |
|
|
21
|
+
| Logs | `hatchbox_get_log` | — |
|
|
22
|
+
|
|
23
|
+
`hatchbox_restart_app`, `hatchbox_deploy_app`, and `hatchbox_create_backup` are asynchronous: they return a `log_id` you follow up on with `hatchbox_get_log` until `state` is `completed`/`failed`/`aborted`.
|
|
24
|
+
|
|
25
|
+
## Setup
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
2. **Add it to your MCP client config.** No install step needed — `npx` fetches and runs the package on demand.
|
|
29
|
+
|
|
30
|
+
**Claude Code:**
|
|
31
|
+
```
|
|
32
|
+
claude mcp add hatchbox -- npx -y @hatchbox/hatchbox-mcp
|
|
33
|
+
```
|
|
34
|
+
Then set `HATCHBOX_BASE_URL` and `HATCHBOX_API_TOKEN` for that server (see `claude mcp add --help` for passing env vars, or edit `.mcp.json` directly).
|
|
35
|
+
|
|
36
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"hatchbox": {
|
|
41
|
+
"command": "npx",
|
|
42
|
+
"args": ["-y", "@hatchbox/hatchbox-mcp"],
|
|
43
|
+
"env": {
|
|
44
|
+
"HATCHBOX_BASE_URL": "https://hatchbox.io/api/v1",
|
|
45
|
+
"HATCHBOX_API_TOKEN": "your-token-here"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
`HATCHBOX_BASE_URL` should always be `https://hatchbox.io/api/v1` — it's the same for every customer, not a per-account or per-instance value.
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
To work on `hatchbox-mcp` itself rather than just using it:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
git clone git@github.com:hatchboxio/hatchbox-mcp.git
|
|
59
|
+
cd hatchbox-mcp
|
|
60
|
+
npm install
|
|
61
|
+
npm run dev # run directly from src/ via tsx, no build step
|
|
62
|
+
npm run build # compile to build/
|
|
63
|
+
npm start # run the compiled build/index.js
|
|
64
|
+
npm test # run the test suite
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To point an MCP client at your local build instead of the published package, use `node` with an absolute path in place of the `npx` command above:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"command": "node",
|
|
72
|
+
"args": ["/absolute/path/to/hatchbox-mcp/build/index.js"]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For local development against `bin/dev`, `HATCHBOX_BASE_URL` is typically `http://app.lvh.me:3000/api/v1`.
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
- The token has no scoping — it's effectively full access as the owning user, gated only by that user's account/subscription status. Treat it like a password.
|
|
81
|
+
- Every endpoint is subscription-gated (402) except account discovery — a lapsed/never-paid account can't use the API.
|
package/build/client.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Thin HTTP client for the Hatchbox /api/v1 API.
|
|
2
|
+
//
|
|
3
|
+
// Every v1 endpoint speaks JSON, auths via `Authorization: Bearer <token>`,
|
|
4
|
+
// and reports errors as either `{ error: string }` or `{ errors: string[] }`
|
|
5
|
+
// (validation failures use the plural form). This wraps that into one
|
|
6
|
+
// typed error class so tool handlers don't each re-implement parsing.
|
|
7
|
+
export class HatchboxApiError extends Error {
|
|
8
|
+
status;
|
|
9
|
+
body;
|
|
10
|
+
constructor(status, message, body) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.body = body;
|
|
14
|
+
this.name = "HatchboxApiError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class HatchboxClient {
|
|
18
|
+
baseUrl;
|
|
19
|
+
token;
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
22
|
+
this.token = config.token;
|
|
23
|
+
}
|
|
24
|
+
async get(path, query) {
|
|
25
|
+
return this.request("GET", path, { query });
|
|
26
|
+
}
|
|
27
|
+
async post(path, body) {
|
|
28
|
+
return this.request("POST", path, { body });
|
|
29
|
+
}
|
|
30
|
+
async patch(path, body) {
|
|
31
|
+
return this.request("PATCH", path, { body });
|
|
32
|
+
}
|
|
33
|
+
async delete(path, body) {
|
|
34
|
+
return this.request("DELETE", path, { body });
|
|
35
|
+
}
|
|
36
|
+
async request(method, path, opts = {}) {
|
|
37
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
38
|
+
for (const [key, value] of Object.entries(opts.query ?? {})) {
|
|
39
|
+
if (value !== undefined)
|
|
40
|
+
url.searchParams.set(key, String(value));
|
|
41
|
+
}
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
method,
|
|
44
|
+
headers: {
|
|
45
|
+
Authorization: `Bearer ${this.token}`,
|
|
46
|
+
Accept: "application/json",
|
|
47
|
+
...(opts.body !== undefined ? { "Content-Type": "application/json" } : {}),
|
|
48
|
+
},
|
|
49
|
+
body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
|
|
50
|
+
});
|
|
51
|
+
// 204/empty-body success responses (e.g. domain delete, env var update).
|
|
52
|
+
const text = await response.text();
|
|
53
|
+
const parsed = text.length > 0 ? safeJsonParse(text) : undefined;
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new HatchboxApiError(response.status, describeError(response.status, parsed), parsed);
|
|
56
|
+
}
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function safeJsonParse(text) {
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return text;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function describeError(status, body) {
|
|
69
|
+
if (body && typeof body === "object") {
|
|
70
|
+
if ("error" in body && typeof body.error === "string") {
|
|
71
|
+
return body.error;
|
|
72
|
+
}
|
|
73
|
+
if ("errors" in body && Array.isArray(body.errors)) {
|
|
74
|
+
return body.errors.join("; ");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
switch (status) {
|
|
78
|
+
case 401:
|
|
79
|
+
return "Unauthorized — the configured HATCHBOX_API_TOKEN is missing or invalid.";
|
|
80
|
+
case 404:
|
|
81
|
+
return "Not found.";
|
|
82
|
+
case 429:
|
|
83
|
+
return "Rate limited by Hatchbox — retry in about a minute.";
|
|
84
|
+
default:
|
|
85
|
+
return `Request failed with status ${status}.`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function clientFromEnv() {
|
|
89
|
+
const baseUrl = process.env.HATCHBOX_BASE_URL;
|
|
90
|
+
const token = process.env.HATCHBOX_API_TOKEN;
|
|
91
|
+
if (!baseUrl) {
|
|
92
|
+
throw new Error("HATCHBOX_BASE_URL is not set. Point it at the Hatchbox API, e.g. https://hatchbox.io/api/v1");
|
|
93
|
+
}
|
|
94
|
+
if (!token) {
|
|
95
|
+
throw new Error("HATCHBOX_API_TOKEN is not set. Create one at https://hatchbox.io/api_tokens and set it in the MCP server config.");
|
|
96
|
+
}
|
|
97
|
+
return new HatchboxClient({ baseUrl, token });
|
|
98
|
+
}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { clientFromEnv } from "./client.js";
|
|
4
|
+
import { createServer } from "./server.js";
|
|
5
|
+
async function main() {
|
|
6
|
+
const client = clientFromEnv();
|
|
7
|
+
const server = createServer(client);
|
|
8
|
+
const transport = new StdioServerTransport();
|
|
9
|
+
await server.connect(transport);
|
|
10
|
+
}
|
|
11
|
+
main().catch((err) => {
|
|
12
|
+
console.error("hatchbox-mcp failed to start:", err);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
});
|
package/build/server.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { registerAccountsTools } from "./tools/accounts.js";
|
|
3
|
+
import { registerMeTools } from "./tools/me.js";
|
|
4
|
+
import { registerAppsTools } from "./tools/apps.js";
|
|
5
|
+
import { registerDomainsTools } from "./tools/domains.js";
|
|
6
|
+
import { registerEnvVarsTools } from "./tools/envVars.js";
|
|
7
|
+
import { registerProcessesTools } from "./tools/processes.js";
|
|
8
|
+
import { registerDatabasesTools } from "./tools/databases.js";
|
|
9
|
+
import { registerClustersTools } from "./tools/clusters.js";
|
|
10
|
+
import { registerServersTools } from "./tools/servers.js";
|
|
11
|
+
import { registerBackupsTools } from "./tools/backups.js";
|
|
12
|
+
import { registerLogsTools } from "./tools/logs.js";
|
|
13
|
+
export function createServer(client) {
|
|
14
|
+
const server = new McpServer({
|
|
15
|
+
name: "hatchbox-mcp",
|
|
16
|
+
version: "0.1.0",
|
|
17
|
+
});
|
|
18
|
+
registerAccountsTools(server, client);
|
|
19
|
+
registerMeTools(server, client);
|
|
20
|
+
registerAppsTools(server, client);
|
|
21
|
+
registerDomainsTools(server, client);
|
|
22
|
+
registerEnvVarsTools(server, client);
|
|
23
|
+
registerProcessesTools(server, client);
|
|
24
|
+
registerDatabasesTools(server, client);
|
|
25
|
+
registerClustersTools(server, client);
|
|
26
|
+
registerServersTools(server, client);
|
|
27
|
+
registerBackupsTools(server, client);
|
|
28
|
+
registerLogsTools(server, client);
|
|
29
|
+
return server;
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, READ_ONLY, runAction } from "./helpers.js";
|
|
3
|
+
const accountIdSchema = {
|
|
4
|
+
account_id: z.number().int().describe("Numeric account id."),
|
|
5
|
+
};
|
|
6
|
+
export function registerAccountsTools(server, client) {
|
|
7
|
+
server.registerTool("hatchbox_list_accounts", {
|
|
8
|
+
title: "List Hatchbox Accounts",
|
|
9
|
+
description: "List every Hatchbox account you belong to. Start here to discover account_id values needed by other " +
|
|
10
|
+
"hatchbox_* tools. No parameters.",
|
|
11
|
+
inputSchema: {},
|
|
12
|
+
annotations: READ_ONLY,
|
|
13
|
+
}, async () => runAction(async () => jsonResult(await client.get("/accounts"))));
|
|
14
|
+
server.registerTool("hatchbox_get_account", {
|
|
15
|
+
title: "Get Hatchbox Account",
|
|
16
|
+
description: "Fetch a single Hatchbox account by id.",
|
|
17
|
+
inputSchema: accountIdSchema,
|
|
18
|
+
annotations: READ_ONLY,
|
|
19
|
+
}, async ({ account_id }) => runAction(async () => jsonResult(await client.get(`/accounts/${account_id}`))));
|
|
20
|
+
server.registerTool("hatchbox_list_account_apps", {
|
|
21
|
+
title: "List Account Apps",
|
|
22
|
+
description: "List every app under a Hatchbox account.",
|
|
23
|
+
inputSchema: accountIdSchema,
|
|
24
|
+
annotations: READ_ONLY,
|
|
25
|
+
}, async ({ account_id }) => runAction(async () => jsonResult(await client.get(`/accounts/${account_id}/apps`))));
|
|
26
|
+
server.registerTool("hatchbox_list_account_clusters", {
|
|
27
|
+
title: "List Account Clusters",
|
|
28
|
+
description: "List every server cluster under a Hatchbox account.",
|
|
29
|
+
inputSchema: accountIdSchema,
|
|
30
|
+
annotations: READ_ONLY,
|
|
31
|
+
}, async ({ account_id }) => runAction(async () => jsonResult(await client.get(`/accounts/${account_id}/clusters`))));
|
|
32
|
+
server.registerTool("hatchbox_list_account_database_clusters", {
|
|
33
|
+
title: "List Account Database Clusters",
|
|
34
|
+
description: "List every database cluster under a Hatchbox account.",
|
|
35
|
+
inputSchema: accountIdSchema,
|
|
36
|
+
annotations: READ_ONLY,
|
|
37
|
+
}, async ({ account_id }) => runAction(async () => jsonResult(await client.get(`/accounts/${account_id}/database_clusters`))));
|
|
38
|
+
server.registerTool("hatchbox_list_account_git_providers", {
|
|
39
|
+
title: "List Account Git Providers",
|
|
40
|
+
description: "List every connected git provider under a Hatchbox account.",
|
|
41
|
+
inputSchema: accountIdSchema,
|
|
42
|
+
annotations: READ_ONLY,
|
|
43
|
+
}, async ({ account_id }) => runAction(async () => jsonResult(await client.get(`/accounts/${account_id}/git_providers`))));
|
|
44
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 APP_NAME_REGEX = /^[\w-]+$/;
|
|
7
|
+
const appWriteFields = {
|
|
8
|
+
name: z.string().regex(APP_NAME_REGEX).describe("App name, letters/numbers/underscore/hyphen only.").optional(),
|
|
9
|
+
branch: z.string().describe("Git branch to deploy from.").optional(),
|
|
10
|
+
repo_path: z.string().describe("Repository path, e.g. 'org/repo'.").optional(),
|
|
11
|
+
connected_account_id: z
|
|
12
|
+
.number()
|
|
13
|
+
.int()
|
|
14
|
+
.describe("Git provider connection id to pull the repo from (see hatchbox_list_account_git_providers).")
|
|
15
|
+
.optional(),
|
|
16
|
+
pre_build_script: z.string().optional(),
|
|
17
|
+
build_script: z.string().optional(),
|
|
18
|
+
post_build_script: z.string().optional(),
|
|
19
|
+
post_deploy_script: z.string().optional(),
|
|
20
|
+
failed_deploy_script: z.string().optional(),
|
|
21
|
+
dns_provider: z.string().describe("DNS provider slug. Set together with dns_access_token.").optional(),
|
|
22
|
+
dns_access_token: z.string().describe("DNS provider API token. Set together with dns_provider. Write-only, never returned.").optional(),
|
|
23
|
+
dns_api_user: z.string().optional(),
|
|
24
|
+
caddyfile: z.string().describe("Custom Caddy config imports. Changing this (even to the same value) re-applies Caddy config on next update.").optional(),
|
|
25
|
+
health_check_uri: z.string().describe("URI path Hatchbox polls to confirm a deploy succeeded, e.g. '/up'.").optional(),
|
|
26
|
+
};
|
|
27
|
+
const APP_WRITE_KEYS = Object.keys(appWriteFields);
|
|
28
|
+
function appParams(args) {
|
|
29
|
+
const app = {};
|
|
30
|
+
for (const key of APP_WRITE_KEYS) {
|
|
31
|
+
if (args[key] !== undefined)
|
|
32
|
+
app[key] = args[key];
|
|
33
|
+
}
|
|
34
|
+
return app;
|
|
35
|
+
}
|
|
36
|
+
export function registerAppsTools(server, client) {
|
|
37
|
+
server.registerTool("hatchbox_get_app", {
|
|
38
|
+
title: "Get Hatchbox App",
|
|
39
|
+
description: "Fetch a Hatchbox app's configuration.",
|
|
40
|
+
inputSchema: appIdSchema,
|
|
41
|
+
annotations: READ_ONLY,
|
|
42
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}`))));
|
|
43
|
+
server.registerTool("hatchbox_create_app", {
|
|
44
|
+
title: "Create Hatchbox App",
|
|
45
|
+
description: "Create a new Hatchbox app on a cluster.",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
...appWriteFields,
|
|
48
|
+
cluster_id: z.number().int().describe("Cluster to create the app on (see hatchbox_list_account_clusters)."),
|
|
49
|
+
name: z.string().regex(APP_NAME_REGEX).describe("App name, letters/numbers/underscore/hyphen only."),
|
|
50
|
+
},
|
|
51
|
+
annotations: WRITE,
|
|
52
|
+
}, async (args) => runAction(async () => {
|
|
53
|
+
const { cluster_id } = args;
|
|
54
|
+
return jsonResult(await client.post(`/apps`, { app: { cluster_id, ...appParams(args) } }));
|
|
55
|
+
}));
|
|
56
|
+
server.registerTool("hatchbox_update_app", {
|
|
57
|
+
title: "Update Hatchbox App",
|
|
58
|
+
description: "Update a Hatchbox app's configuration. Only the fields you pass are changed.",
|
|
59
|
+
inputSchema: { ...appIdSchema, ...appWriteFields },
|
|
60
|
+
annotations: WRITE,
|
|
61
|
+
}, async (args) => runAction(async () => {
|
|
62
|
+
const { app_id } = args;
|
|
63
|
+
return jsonResult(await client.patch(`/apps/${app_id}`, { app: appParams(args) }));
|
|
64
|
+
}));
|
|
65
|
+
server.registerTool("hatchbox_restart_app", {
|
|
66
|
+
title: "Restart Hatchbox App",
|
|
67
|
+
description: "Restart every process on a Hatchbox app. Asynchronous — returns a log id, follow up with hatchbox_get_log " +
|
|
68
|
+
"to see progress and completion status.",
|
|
69
|
+
inputSchema: appIdSchema,
|
|
70
|
+
annotations: WRITE,
|
|
71
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/restart`))));
|
|
72
|
+
server.registerTool("hatchbox_deploy_app", {
|
|
73
|
+
title: "Deploy Hatchbox App",
|
|
74
|
+
description: "Trigger a deploy of a Hatchbox app. Asynchronous — returns a log id, follow up with hatchbox_get_log to see " +
|
|
75
|
+
"progress and completion status.",
|
|
76
|
+
inputSchema: {
|
|
77
|
+
...appIdSchema,
|
|
78
|
+
sha: z.string().describe("Specific commit SHA to deploy. Omit to deploy the latest commit on the app's branch.").optional(),
|
|
79
|
+
},
|
|
80
|
+
annotations: WRITE,
|
|
81
|
+
}, async ({ app_id, sha }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/deploy`, sha ? { sha } : {}))));
|
|
82
|
+
server.registerTool("hatchbox_enable_app_auto_deploy", {
|
|
83
|
+
title: "Enable App Auto-Deploy",
|
|
84
|
+
description: "Enable auto-deploy on a Hatchbox app, so pushes to its branch trigger a deploy automatically.",
|
|
85
|
+
inputSchema: appIdSchema,
|
|
86
|
+
annotations: WRITE,
|
|
87
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/auto_deploy`))));
|
|
88
|
+
server.registerTool("hatchbox_disable_app_auto_deploy", {
|
|
89
|
+
title: "Disable App Auto-Deploy",
|
|
90
|
+
description: "Disable auto-deploy on a Hatchbox app.",
|
|
91
|
+
inputSchema: appIdSchema,
|
|
92
|
+
annotations: WRITE,
|
|
93
|
+
}, async ({ app_id }) => runAction(async () => {
|
|
94
|
+
await client.delete(`/apps/${app_id}/auto_deploy`);
|
|
95
|
+
return textResult(`Disabled auto-deploy on app ${app_id}.`);
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, READ_ONLY, runAction, WRITE } from "./helpers.js";
|
|
3
|
+
const databaseIdSchema = {
|
|
4
|
+
database_id: z.number().int().describe("Numeric database id (see hatchbox_list_app_databases)."),
|
|
5
|
+
};
|
|
6
|
+
export function registerBackupsTools(server, client) {
|
|
7
|
+
server.registerTool("hatchbox_create_backup", {
|
|
8
|
+
title: "Create Database Backup",
|
|
9
|
+
description: "Trigger a new backup run for a Hatchbox database. Only for unmanaged databases with backups enabled " +
|
|
10
|
+
"(managed databases should be backed up via their hosting provider instead). Fails with a 409 if a backup is " +
|
|
11
|
+
"already running. Asynchronous — returns a log id, follow up with hatchbox_get_log.",
|
|
12
|
+
inputSchema: databaseIdSchema,
|
|
13
|
+
annotations: WRITE,
|
|
14
|
+
}, async ({ database_id }) => runAction(async () => jsonResult(await client.post(`/databases/${database_id}/backups`))));
|
|
15
|
+
server.registerTool("hatchbox_get_latest_backup", {
|
|
16
|
+
title: "Get Latest Database Backup",
|
|
17
|
+
description: "Get a presigned download URL for the most recent completed backup of a Hatchbox database. Only works when " +
|
|
18
|
+
"the backup provider is S3/S3-compatible.",
|
|
19
|
+
inputSchema: databaseIdSchema,
|
|
20
|
+
annotations: READ_ONLY,
|
|
21
|
+
}, async ({ database_id }) => runAction(async () => jsonResult(await client.get(`/databases/${database_id}/backups/latest`))));
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, READ_ONLY, runAction } from "./helpers.js";
|
|
3
|
+
export function registerClustersTools(server, client) {
|
|
4
|
+
server.registerTool("hatchbox_get_cluster", {
|
|
5
|
+
title: "Get Hatchbox Cluster",
|
|
6
|
+
description: "Fetch a Hatchbox server cluster, with its servers embedded under a `servers` key. For a standalone server " +
|
|
7
|
+
"list/get, use hatchbox_list_servers / hatchbox_get_server.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
cluster_id: z.number().int().describe("Numeric cluster id (see hatchbox_list_account_clusters)."),
|
|
10
|
+
},
|
|
11
|
+
annotations: READ_ONLY,
|
|
12
|
+
}, async ({ cluster_id }) => runAction(async () => jsonResult(await client.get(`/clusters/${cluster_id}`))));
|
|
13
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 clusterIdSchema = {
|
|
7
|
+
database_cluster_id: z
|
|
8
|
+
.number()
|
|
9
|
+
.int()
|
|
10
|
+
.describe("Numeric database cluster id (see hatchbox_list_account_database_clusters)."),
|
|
11
|
+
};
|
|
12
|
+
const CREDENTIALS_NOTE = "Responses include connection credentials (username/password/connection URIs) in plaintext for " +
|
|
13
|
+
"relational/redis databases, or a file path for SQLite.";
|
|
14
|
+
export function registerDatabasesTools(server, client) {
|
|
15
|
+
server.registerTool("hatchbox_list_app_databases", {
|
|
16
|
+
title: "List App Databases",
|
|
17
|
+
description: `List the databases attached to a Hatchbox app. ${CREDENTIALS_NOTE}`,
|
|
18
|
+
inputSchema: appIdSchema,
|
|
19
|
+
annotations: READ_ONLY,
|
|
20
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/databases`))));
|
|
21
|
+
server.registerTool("hatchbox_get_app_database", {
|
|
22
|
+
title: "Get App Database",
|
|
23
|
+
description: `Fetch a single database attached to a Hatchbox app. ${CREDENTIALS_NOTE}`,
|
|
24
|
+
inputSchema: {
|
|
25
|
+
...appIdSchema,
|
|
26
|
+
database_id: z.number().int().describe("Numeric database id."),
|
|
27
|
+
},
|
|
28
|
+
annotations: READ_ONLY,
|
|
29
|
+
}, async ({ app_id, database_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/databases/${database_id}`))));
|
|
30
|
+
server.registerTool("hatchbox_list_cluster_databases", {
|
|
31
|
+
title: "List Cluster Databases",
|
|
32
|
+
description: `List the databases on a Hatchbox database cluster. ${CREDENTIALS_NOTE}`,
|
|
33
|
+
inputSchema: clusterIdSchema,
|
|
34
|
+
annotations: READ_ONLY,
|
|
35
|
+
}, async ({ database_cluster_id }) => runAction(async () => jsonResult(await client.get(`/database_clusters/${database_cluster_id}/databases`))));
|
|
36
|
+
server.registerTool("hatchbox_get_cluster_database", {
|
|
37
|
+
title: "Get Cluster Database",
|
|
38
|
+
description: `Fetch a single database on a Hatchbox database cluster. ${CREDENTIALS_NOTE}`,
|
|
39
|
+
inputSchema: {
|
|
40
|
+
...clusterIdSchema,
|
|
41
|
+
database_id: z.number().int().describe("Numeric database id."),
|
|
42
|
+
},
|
|
43
|
+
annotations: READ_ONLY,
|
|
44
|
+
}, async ({ database_cluster_id, database_id }) => runAction(async () => jsonResult(await client.get(`/database_clusters/${database_cluster_id}/databases/${database_id}`))));
|
|
45
|
+
server.registerTool("hatchbox_create_database", {
|
|
46
|
+
title: "Create Database",
|
|
47
|
+
description: "Create a new database on a Hatchbox database cluster. Does NOT attach it to any app — call " +
|
|
48
|
+
"hatchbox_attach_database afterward.",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
...clusterIdSchema,
|
|
51
|
+
name: z.string().describe("Database name. Ignored for redis/elasticsearch/memcached clusters.").optional(),
|
|
52
|
+
path: z.string().describe("Absolute file path. Required for SQLite clusters, unused otherwise.").optional(),
|
|
53
|
+
},
|
|
54
|
+
annotations: WRITE,
|
|
55
|
+
}, async ({ database_cluster_id, name, path }) => runAction(async () => jsonResult(await client.post(`/database_clusters/${database_cluster_id}/databases`, { database: { name, path } }))));
|
|
56
|
+
server.registerTool("hatchbox_update_database", {
|
|
57
|
+
title: "Update Database",
|
|
58
|
+
description: "Update a database on a Hatchbox database cluster. Only SQLite databases can be updated — fails with a 422 " +
|
|
59
|
+
"on any other engine (postgresql, mysql, redis, etc.).",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
...clusterIdSchema,
|
|
62
|
+
database_id: z.number().int().describe("Numeric database id."),
|
|
63
|
+
name: z.string().describe("Database name.").optional(),
|
|
64
|
+
path: z.string().describe("Absolute file path. SQLite only — re-points every attached app.").optional(),
|
|
65
|
+
},
|
|
66
|
+
annotations: WRITE,
|
|
67
|
+
}, async ({ database_cluster_id, database_id, name, path }) => runAction(async () => jsonResult(await client.patch(`/database_clusters/${database_cluster_id}/databases/${database_id}`, {
|
|
68
|
+
database: { name, path },
|
|
69
|
+
}))));
|
|
70
|
+
server.registerTool("hatchbox_attach_database", {
|
|
71
|
+
title: "Attach Database to App",
|
|
72
|
+
description: "Attach a database to a Hatchbox app, creating a connection env var on the app. A database can be attached " +
|
|
73
|
+
"to the same app more than once.",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
...appIdSchema,
|
|
76
|
+
database_id: z.number().int().describe("Numeric database id."),
|
|
77
|
+
env_var: z
|
|
78
|
+
.string()
|
|
79
|
+
.describe("Env var name to store the connection string under. Omit to use the database's default " +
|
|
80
|
+
"(e.g. DATABASE_URL), auto color-prefixed on collision.")
|
|
81
|
+
.optional(),
|
|
82
|
+
},
|
|
83
|
+
annotations: WRITE,
|
|
84
|
+
}, async ({ app_id, database_id, env_var }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/databases/${database_id}/attachment`, { env_var }))));
|
|
85
|
+
server.registerTool("hatchbox_detach_database", {
|
|
86
|
+
title: "Detach Database from App",
|
|
87
|
+
description: "Detach a database from a Hatchbox app, removing its connection env var.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
...appIdSchema,
|
|
90
|
+
database_id: z.number().int().describe("Numeric database id."),
|
|
91
|
+
},
|
|
92
|
+
annotations: WRITE,
|
|
93
|
+
}, async ({ app_id, database_id }) => runAction(async () => {
|
|
94
|
+
await client.delete(`/apps/${app_id}/databases/${database_id}/attachment`);
|
|
95
|
+
return textResult(`Detached database ${database_id} from app ${app_id}.`);
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 the domain belongs to."),
|
|
5
|
+
};
|
|
6
|
+
const domainNameSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.describe("The domain's name, e.g. 'example.com' or '*.example.com'. Domains are looked up by name, not id.");
|
|
9
|
+
export function registerDomainsTools(server, client) {
|
|
10
|
+
server.registerTool("hatchbox_list_domains", {
|
|
11
|
+
title: "List App Domains",
|
|
12
|
+
description: "List every domain attached to a Hatchbox app.",
|
|
13
|
+
inputSchema: appIdSchema,
|
|
14
|
+
annotations: READ_ONLY,
|
|
15
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/domains`))));
|
|
16
|
+
server.registerTool("hatchbox_get_domain", {
|
|
17
|
+
title: "Get App Domain",
|
|
18
|
+
description: "Fetch a single domain attached to a Hatchbox app, by name.",
|
|
19
|
+
inputSchema: { ...appIdSchema, name: domainNameSchema },
|
|
20
|
+
annotations: READ_ONLY,
|
|
21
|
+
}, async ({ app_id, name }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/domains/${encodeURIComponent(name)}`))));
|
|
22
|
+
server.registerTool("hatchbox_create_domain", {
|
|
23
|
+
title: "Create App Domain",
|
|
24
|
+
description: "Attach a new domain to a Hatchbox app.",
|
|
25
|
+
inputSchema: { ...appIdSchema, name: domainNameSchema },
|
|
26
|
+
annotations: WRITE,
|
|
27
|
+
}, async ({ app_id, name }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/domains`, { domain: { name } }))));
|
|
28
|
+
server.registerTool("hatchbox_update_domain", {
|
|
29
|
+
title: "Rename App Domain",
|
|
30
|
+
description: "Rename a domain attached to a Hatchbox app.",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
...appIdSchema,
|
|
33
|
+
name: domainNameSchema.describe("The domain's CURRENT name."),
|
|
34
|
+
new_name: z.string().describe("The new name to rename the domain to."),
|
|
35
|
+
},
|
|
36
|
+
annotations: WRITE,
|
|
37
|
+
}, async ({ app_id, name, new_name }) => runAction(async () => jsonResult(await client.patch(`/apps/${app_id}/domains/${encodeURIComponent(name)}`, { domain: { name: new_name } }))));
|
|
38
|
+
server.registerTool("hatchbox_delete_domain", {
|
|
39
|
+
title: "Delete App Domain",
|
|
40
|
+
description: "Remove a domain from a Hatchbox app.",
|
|
41
|
+
inputSchema: { ...appIdSchema, name: domainNameSchema },
|
|
42
|
+
annotations: WRITE,
|
|
43
|
+
}, async ({ app_id, name }) => runAction(async () => {
|
|
44
|
+
await client.delete(`/apps/${app_id}/domains/${encodeURIComponent(name)}`);
|
|
45
|
+
return textResult(`Deleted domain ${name} from app ${app_id}.`);
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, runAction, textResult, WRITE } from "./helpers.js";
|
|
3
|
+
const appIdSchema = {
|
|
4
|
+
app_id: z.number().int().describe("Numeric app id."),
|
|
5
|
+
};
|
|
6
|
+
const envVarsSchema = z
|
|
7
|
+
.array(z.object({
|
|
8
|
+
name: z.string().describe("Env var name. Will be uppercased server-side."),
|
|
9
|
+
value: z.string().describe("Env var value."),
|
|
10
|
+
}))
|
|
11
|
+
.describe('Env vars to set, e.g. [{"name": "FOO", "value": "bar"}].');
|
|
12
|
+
export function registerEnvVarsTools(server, client) {
|
|
13
|
+
server.registerTool("hatchbox_create_env_vars", {
|
|
14
|
+
title: "Create App Env Vars",
|
|
15
|
+
description: "Create new environment variables on a Hatchbox app. Fails with a 422 if a name already exists — use " +
|
|
16
|
+
"hatchbox_update_env_vars to change an existing one. Values are write-only — reads elsewhere never return them.",
|
|
17
|
+
inputSchema: { ...appIdSchema, env_vars: envVarsSchema },
|
|
18
|
+
annotations: WRITE,
|
|
19
|
+
}, async ({ app_id, env_vars }) => runAction(async () => jsonResult(await client.post(`/apps/${app_id}/env_vars`, { env_vars }))));
|
|
20
|
+
server.registerTool("hatchbox_update_env_vars", {
|
|
21
|
+
title: "Update App Env Vars",
|
|
22
|
+
description: "Update existing environment variables on a Hatchbox app.",
|
|
23
|
+
inputSchema: { ...appIdSchema, env_vars: envVarsSchema },
|
|
24
|
+
annotations: WRITE,
|
|
25
|
+
}, async ({ app_id, env_vars }) => runAction(async () => {
|
|
26
|
+
await client.patch(`/apps/${app_id}/env_vars`, { env_vars });
|
|
27
|
+
return textResult(`Updated ${env_vars.length} env var(s) on app ${app_id}.`);
|
|
28
|
+
}));
|
|
29
|
+
server.registerTool("hatchbox_delete_env_vars", {
|
|
30
|
+
title: "Delete App Env Vars",
|
|
31
|
+
description: "Remove environment variables from a Hatchbox app. Unknown names are ignored, not errors.",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
...appIdSchema,
|
|
34
|
+
names: z.array(z.string()).describe("Env var names to remove."),
|
|
35
|
+
},
|
|
36
|
+
annotations: WRITE,
|
|
37
|
+
}, async ({ app_id, names }) => runAction(async () => {
|
|
38
|
+
await client.delete(`/apps/${app_id}/env_vars`, { env_vars: names });
|
|
39
|
+
return textResult(`Removed env var(s) ${names.join(", ")} from app ${app_id}.`);
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HatchboxApiError } from "../client.js";
|
|
2
|
+
/** Annotations for tools that only read data (safe HTTP methods). */
|
|
3
|
+
export const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
4
|
+
/** Annotations for tools that create/update/delete data (unsafe HTTP methods). */
|
|
5
|
+
export const WRITE = { destructiveHint: true, openWorldHint: true };
|
|
6
|
+
export function jsonResult(data) {
|
|
7
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
8
|
+
}
|
|
9
|
+
export function textResult(text) {
|
|
10
|
+
return { content: [{ type: "text", text }] };
|
|
11
|
+
}
|
|
12
|
+
export function errorResult(text) {
|
|
13
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
14
|
+
}
|
|
15
|
+
/** Runs a tool action, translating HatchboxApiError into an MCP tool error instead of throwing. */
|
|
16
|
+
export async function runAction(fn) {
|
|
17
|
+
try {
|
|
18
|
+
return await fn();
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err instanceof HatchboxApiError) {
|
|
22
|
+
return errorResult(`Hatchbox API error (${err.status}): ${err.message}`);
|
|
23
|
+
}
|
|
24
|
+
return errorResult(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, READ_ONLY, runAction } from "./helpers.js";
|
|
3
|
+
export function registerLogsTools(server, client) {
|
|
4
|
+
server.registerTool("hatchbox_get_log", {
|
|
5
|
+
title: "Get Hatchbox Log",
|
|
6
|
+
description: "Read a Hatchbox job log (deploys, restarts, backups, provisioning) and its child logs. Poll this after " +
|
|
7
|
+
"hatchbox_restart_app, hatchbox_deploy_app, or hatchbox_create_backup until `state` is completed/failed/aborted.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
log_id: z.number().int().describe("Numeric log id, returned by whichever action started the async job."),
|
|
10
|
+
},
|
|
11
|
+
annotations: READ_ONLY,
|
|
12
|
+
}, async ({ log_id }) => runAction(async () => jsonResult(await client.get(`/logs/${log_id}`))));
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsonResult, READ_ONLY, runAction } from "./helpers.js";
|
|
2
|
+
export function registerMeTools(server, client) {
|
|
3
|
+
server.registerTool("hatchbox_get_me", {
|
|
4
|
+
title: "Get Current Hatchbox User",
|
|
5
|
+
description: "Fetch the Hatchbox user identified by the configured HATCHBOX_API_TOKEN. Useful as a connectivity/auth check " +
|
|
6
|
+
"before calling other hatchbox_* tools. No parameters.",
|
|
7
|
+
inputSchema: {},
|
|
8
|
+
annotations: READ_ONLY,
|
|
9
|
+
}, async () => runAction(async () => jsonResult(await client.get("/me"))));
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 processIdSchema = {
|
|
7
|
+
...appIdSchema,
|
|
8
|
+
process_id: z.number().int().describe("Numeric process id (see hatchbox_list_processes)."),
|
|
9
|
+
};
|
|
10
|
+
export function registerProcessesTools(server, client) {
|
|
11
|
+
server.registerTool("hatchbox_list_processes", {
|
|
12
|
+
title: "List App Processes",
|
|
13
|
+
description: "List the individual processes (web/worker/cron) running under a Hatchbox app.",
|
|
14
|
+
inputSchema: appIdSchema,
|
|
15
|
+
annotations: READ_ONLY,
|
|
16
|
+
}, async ({ app_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/processes`))));
|
|
17
|
+
server.registerTool("hatchbox_get_process", {
|
|
18
|
+
title: "Get App Process",
|
|
19
|
+
description: "Fetch a single process running under a Hatchbox app.",
|
|
20
|
+
inputSchema: processIdSchema,
|
|
21
|
+
annotations: READ_ONLY,
|
|
22
|
+
}, async ({ app_id, process_id }) => runAction(async () => jsonResult(await client.get(`/apps/${app_id}/processes/${process_id}`))));
|
|
23
|
+
server.registerTool("hatchbox_restart_process", {
|
|
24
|
+
title: "Restart App Process",
|
|
25
|
+
description: "Restart a single process on a Hatchbox app. To restart every process on an app at once, use " +
|
|
26
|
+
"hatchbox_restart_app instead.",
|
|
27
|
+
inputSchema: processIdSchema,
|
|
28
|
+
annotations: WRITE,
|
|
29
|
+
}, async ({ app_id, process_id }) => runAction(async () => {
|
|
30
|
+
await client.post(`/apps/${app_id}/processes/${process_id}/restart`);
|
|
31
|
+
return textResult(`Restarting process ${process_id} on app ${app_id}.`);
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { jsonResult, READ_ONLY, runAction } from "./helpers.js";
|
|
3
|
+
const clusterIdSchema = {
|
|
4
|
+
cluster_id: z.number().int().describe("Numeric cluster id (see hatchbox_list_account_clusters)."),
|
|
5
|
+
};
|
|
6
|
+
export function registerServersTools(server, client) {
|
|
7
|
+
server.registerTool("hatchbox_list_servers", {
|
|
8
|
+
title: "List Cluster Servers",
|
|
9
|
+
description: "List the servers in a Hatchbox cluster (state, roles, IPs, size, etc.). hatchbox_get_cluster also embeds " +
|
|
10
|
+
"this same list on the cluster itself.",
|
|
11
|
+
inputSchema: clusterIdSchema,
|
|
12
|
+
annotations: READ_ONLY,
|
|
13
|
+
}, async ({ cluster_id }) => runAction(async () => jsonResult(await client.get(`/clusters/${cluster_id}/servers`))));
|
|
14
|
+
server.registerTool("hatchbox_get_server", {
|
|
15
|
+
title: "Get Cluster Server",
|
|
16
|
+
description: "Fetch a single server in a Hatchbox cluster.",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
...clusterIdSchema,
|
|
19
|
+
server_id: z.number().int().describe("Numeric server id."),
|
|
20
|
+
},
|
|
21
|
+
annotations: READ_ONLY,
|
|
22
|
+
}, async ({ cluster_id, server_id }) => runAction(async () => jsonResult(await client.get(`/clusters/${cluster_id}/servers/${server_id}`))));
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hatchbox/hatchbox-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server that wraps the Hatchbox /api/v1 API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"hatchbox-mcp": "build/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"build"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc && chmod +x build/index.js",
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"start": "node build/index.js",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"hatchbox",
|
|
24
|
+
"claude",
|
|
25
|
+
"hosting",
|
|
26
|
+
"deployment",
|
|
27
|
+
"devops"
|
|
28
|
+
],
|
|
29
|
+
"author": "Hatchbox",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/hatchboxio/hatchbox-mcp.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/hatchboxio/hatchbox-mcp#readme",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/hatchboxio/hatchbox-mcp/issues"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
44
|
+
"zod": "^4.4.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^26.1.2",
|
|
48
|
+
"tsx": "^4.23.10",
|
|
49
|
+
"typescript": "^7.0.2",
|
|
50
|
+
"vitest": "^4.1.10"
|
|
51
|
+
}
|
|
52
|
+
}
|