@selfhost.dev/mcp-server 0.7.0 → 0.9.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.
Files changed (53) hide show
  1. package/README.md +118 -17
  2. package/dist/index.js +19 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/tools/alerts.js +83 -12
  5. package/dist/tools/alerts.js.map +1 -1
  6. package/dist/tools/auth.js +13 -1
  7. package/dist/tools/auth.js.map +1 -1
  8. package/dist/tools/backups.js +197 -18
  9. package/dist/tools/backups.js.map +1 -1
  10. package/dist/tools/billing.js +5 -1
  11. package/dist/tools/billing.js.map +1 -1
  12. package/dist/tools/capacity.d.ts +2 -0
  13. package/dist/tools/capacity.js +253 -0
  14. package/dist/tools/capacity.js.map +1 -0
  15. package/dist/tools/database-users.js +33 -6
  16. package/dist/tools/database-users.js.map +1 -1
  17. package/dist/tools/deployments.js +14 -16
  18. package/dist/tools/deployments.js.map +1 -1
  19. package/dist/tools/env-vars.js +23 -0
  20. package/dist/tools/env-vars.js.map +1 -1
  21. package/dist/tools/github.js +65 -4
  22. package/dist/tools/github.js.map +1 -1
  23. package/dist/tools/instance-logs.d.ts +2 -0
  24. package/dist/tools/instance-logs.js +151 -0
  25. package/dist/tools/instance-logs.js.map +1 -0
  26. package/dist/tools/instances.js +251 -25
  27. package/dist/tools/instances.js.map +1 -1
  28. package/dist/tools/organizations.js +107 -13
  29. package/dist/tools/organizations.js.map +1 -1
  30. package/dist/tools/postgres-tls.d.ts +16 -0
  31. package/dist/tools/postgres-tls.js +64 -0
  32. package/dist/tools/postgres-tls.js.map +1 -0
  33. package/dist/tools/project-activities.d.ts +2 -0
  34. package/dist/tools/project-activities.js +52 -0
  35. package/dist/tools/project-activities.js.map +1 -0
  36. package/dist/tools/project-backups.d.ts +2 -0
  37. package/dist/tools/project-backups.js +159 -0
  38. package/dist/tools/project-backups.js.map +1 -0
  39. package/dist/tools/project-databases.js +26 -2
  40. package/dist/tools/project-databases.js.map +1 -1
  41. package/dist/tools/project-services.js +136 -25
  42. package/dist/tools/project-services.js.map +1 -1
  43. package/dist/tools/projects.js +151 -5
  44. package/dist/tools/projects.js.map +1 -1
  45. package/dist/tools/scaling.js +401 -36
  46. package/dist/tools/scaling.js.map +1 -1
  47. package/dist/tools/webhooks.d.ts +2 -0
  48. package/dist/tools/webhooks.js +195 -0
  49. package/dist/tools/webhooks.js.map +1 -0
  50. package/dist/types/models.d.ts +8 -1
  51. package/dist/types/tiers.js +5 -0
  52. package/dist/types/tiers.js.map +1 -1
  53. package/package.json +3 -2
@@ -5,6 +5,33 @@ import { session } from "../session.js";
5
5
  function resolveOrgId(organization_id) {
6
6
  return organization_id || session.getActiveOrgId();
7
7
  }
8
+ /**
9
+ * The five organization roles. `pid` values are seeded literals (`db/seeds.rb`),
10
+ * shared across every org and stable, which is why they can be named here.
11
+ *
12
+ * They have to be: the API takes `role_pid`, but NOTHING returns the full role
13
+ * catalogue. `list_members` gives each member's role as a SLUG only, and
14
+ * `get_my_memberships` gives a pid only for the caller's own role. Without this
15
+ * table an agent cannot name a role it is not already holding.
16
+ *
17
+ * `priority` is what the backend's authorization compares, so it is the number
18
+ * that decides whether a caller may grant or change a given role.
19
+ */
20
+ const ROLES = {
21
+ owner: { pid: "role_owner", name: "Owner", priority: 100, summary: "Full control, including billing and deleting the org" },
22
+ admin: { pid: "role_admin", name: "Admin", priority: 80, summary: "Manages members, settings, projects, instances and alerts; reads billing" },
23
+ billing: { pid: "role_billing", name: "Billing", priority: 60, summary: "Billing and payment management" },
24
+ manager: { pid: "role_manager", name: "Manager", priority: 40, summary: "Operates resources without member or billing control" },
25
+ member: { pid: "role_member", name: "Member", priority: 20, summary: "Day-to-day access, no administrative control" },
26
+ };
27
+ const ROLE_SLUGS = ["owner", "admin", "billing", "manager", "member"];
28
+ /** Rendered into the tool descriptions so the model sees the ladder, not just names. */
29
+ const ROLE_LADDER = ROLE_SLUGS.map((r) => `\`${r}\` ${ROLES[r].name} (priority ${ROLES[r].priority}) - ${ROLES[r].summary}`).join("; ");
30
+ /**
31
+ * The rule the backend applies to both role changes and member removal. Stated in
32
+ * full because a caller who trips it gets a 422 that reads like a bug otherwise.
33
+ */
34
+ const ROLE_AUTHORITY_RULE = "AUTHORITY: an owner may manage everyone. An admin may only manage STRICTLY BELOW their own priority - never a peer admin, and never grant a role at or above their own. You can never change your OWN role (self-demotion would lock you out, self-promotion would be an escalation); an owner stepping down has to be demoted by another owner. The last owner cannot be demoted or removed.";
8
35
  export function registerOrganizationTools(server) {
9
36
  server.tool("list_organizations", "List all organizations you belong to", {}, async () => {
10
37
  const result = await apiRequest("/organizations", {
@@ -34,11 +61,15 @@ export function registerOrganizationTools(server) {
34
61
  return { content: [{ type: "text", text: `Failed to create organization (${result.statusCode}): ${result.message}` }] };
35
62
  }
36
63
  const org = result.data;
37
- // Auto-select the newly created org
38
- session.setActiveOrg({
39
- id: org.id,
40
- name: org.name,
41
- });
64
+ // Auto-select the newly created org. The payload carries `pid`, not `id` - reading
65
+ // `id` here left the session unset, so the very next call claimed no org was selected.
66
+ const newOrgId = org.pid ?? org.id;
67
+ if (newOrgId) {
68
+ session.setActiveOrg({
69
+ id: newOrgId,
70
+ name: org.name,
71
+ });
72
+ }
42
73
  return {
43
74
  content: [
44
75
  { type: "text", text: `Organization "${org.name}" created. You are now working in this org.` },
@@ -118,7 +149,11 @@ export function registerOrganizationTools(server) {
118
149
  }
119
150
  return { content: [{ type: "text", text: `Organization ${orgId} deleted.` }] };
120
151
  });
121
- server.tool("list_members", "List members of an organization with their roles", {
152
+ server.tool("list_members", `List members of an organization with their roles. Each row carries the user pid (as \`id\`), email, name, \`last_active_at\`, \`joined_at\` and \`role\`.
153
+
154
+ \`role\` is a SLUG, not a pid: one of ${ROLE_SLUGS.map((r) => `\`${r}\``).join(", ")}. \`update_member_role\` takes the slug too, so you can pass what you read here straight through.
155
+
156
+ The ladder, highest first: ${ROLE_LADDER}.`, {
122
157
  organization_id: z.string().optional().describe("Organization PID (defaults to active org)"),
123
158
  }, async ({ organization_id }) => {
124
159
  const orgId = resolveOrgId(organization_id);
@@ -134,9 +169,15 @@ export function registerOrganizationTools(server) {
134
169
  }
135
170
  return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
136
171
  });
137
- server.tool("remove_member", "DESTRUCTIVE: Remove a member from an organization (requires owner or admin role). Cannot remove the last owner. You MUST set confirm=true to proceed.", {
172
+ server.tool("remove_member", `DESTRUCTIVE: Remove a member from an organization. They lose access immediately.
173
+
174
+ ${ROLE_AUTHORITY_RULE} The same strict-priority rule applies here as to \`update_member_role\`, deliberately - otherwise an admin blocked from demoting a peer could just remove them instead. Removing YOURSELF (leaving the org) is allowed.
175
+
176
+ If the intent is to reduce someone's access rather than end it, \`update_member_role\` is the tool - offer that first.
177
+
178
+ You MUST set confirm=true to proceed.`, {
138
179
  organization_id: z.string().optional().describe("Organization PID (defaults to active org)"),
139
- user_id: z.string().min(1, "User PID is required"),
180
+ user_id: z.string().min(1, "User PID is required").describe("The member's user pid - the `id` field from `list_members`"),
140
181
  confirm: z.boolean().describe("Must be true to proceed. Ask the user for explicit confirmation before setting this."),
141
182
  }, async ({ organization_id, user_id, confirm }) => {
142
183
  const orgId = resolveOrgId(organization_id);
@@ -161,27 +202,80 @@ export function registerOrganizationTools(server) {
161
202
  }
162
203
  return { content: [{ type: "text", text: `Member ${user_id} removed from organization.` }] };
163
204
  });
164
- server.tool("invite_to_org", "Invite a user to your organization by email. Requires members:invite permission. Role hierarchy is enforced (can only invite at or below your role).", {
205
+ server.tool("invite_to_org", `Invite a user to your organization by email, at a role you choose.
206
+
207
+ Pass \`role\` as a slug - ${ROLE_SLUGS.map((r) => `\`${r}\``).join(", ")} - and this resolves it to the pid the API wants. (\`role_pid\` is still accepted for a role this tool does not know about, but you should not normally need it.)
208
+
209
+ The ladder: ${ROLE_LADDER}.
210
+
211
+ ${ROLE_AUTHORITY_RULE}
212
+
213
+ Requires \`members:invite\`. The invitee gets an email with a token; the membership does not exist until they accept, so they will not show in \`list_members\` yet - track them with \`list_org_invitations\`.`, {
165
214
  organization_id: z.string().optional().describe("Organization PID (defaults to active org)"),
166
215
  email: z.string().email("Valid email is required"),
167
- role_pid: z.string().min(1, "Role PID is required (e.g. role PID for member, admin, etc.)"),
168
- }, async ({ organization_id, email, role_pid }) => {
216
+ role: z.enum(ROLE_SLUGS).optional().describe("Role to invite at, by slug. Resolved to the backend's role pid for you. Prefer this over role_pid."),
217
+ role_pid: z.string().min(1).optional().describe("Escape hatch: pass a raw role pid instead of `role`. Only needed for a role this tool does not list."),
218
+ }, async ({ organization_id, email, role, role_pid }) => {
169
219
  const orgId = resolveOrgId(organization_id);
170
220
  if (!orgId) {
171
221
  return { content: [{ type: "text", text: "No organization selected. Call `select_organization` first or pass an organization_id." }] };
172
222
  }
223
+ const resolvedPid = role ? ROLES[role].pid : role_pid;
224
+ if (!resolvedPid) {
225
+ return {
226
+ content: [{
227
+ type: "text",
228
+ text: `Which role should ${email} be invited at? Pass \`role\` as one of ${ROLE_SLUGS.join(", ")}. Ask the user rather than picking - the roles differ in who can manage members and see billing: ${ROLE_LADDER}.`,
229
+ }],
230
+ };
231
+ }
173
232
  const result = await apiRequest(`/organizations/${orgId}/invitations`, {
174
233
  method: "POST",
175
- body: { email, role_pid },
234
+ body: { email, role_pid: resolvedPid },
176
235
  toolName: "invite_to_org",
177
236
  skipOrgInjection: true,
178
237
  });
179
238
  if (!result.success) {
180
239
  return { content: [{ type: "text", text: `Failed to send invitation (${result.statusCode}): ${result.message}` }] };
181
240
  }
241
+ const roleLabel = role ? ROLES[role].name : resolvedPid;
242
+ return {
243
+ content: [
244
+ { type: "text", text: `Invitation sent to ${email} as ${roleLabel}. They appear in \`list_org_invitations\` until they accept, then in \`list_members\`.` },
245
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
246
+ ],
247
+ };
248
+ });
249
+ server.tool("update_member_role", `Change an existing member's role. This is the only way to promote or demote someone after they have joined - inviting them again does not do it.
250
+
251
+ Pass \`role\` as a slug: ${ROLE_SLUGS.map((r) => `\`${r}\``).join(", ")}. The ladder, highest first: ${ROLE_LADDER}.
252
+
253
+ ${ROLE_AUTHORITY_RULE}
254
+
255
+ \`user_id\` is the member's USER pid - the \`id\` field from \`list_members\`, not their membership or email.
256
+
257
+ A 422 here is almost always one of the authority rules above rather than a fault: read the message back to the user instead of retrying. Confirm the change with them first - a demotion can remove someone's access to billing or to every instance in the org.`, {
258
+ organization_id: z.string().optional().describe("Organization PID (defaults to active org)"),
259
+ user_id: z.string().min(1).describe("The member's user pid - the `id` field from `list_members`"),
260
+ role: z.enum(ROLE_SLUGS).describe("The role to move them to"),
261
+ }, async ({ organization_id, user_id, role }) => {
262
+ const orgId = resolveOrgId(organization_id);
263
+ if (!orgId) {
264
+ return { content: [{ type: "text", text: "No organization selected. Call `select_organization` first or pass an organization_id." }] };
265
+ }
266
+ const target = ROLES[role];
267
+ const result = await apiRequest(`/organizations/${orgId}/members/${user_id}/role`, {
268
+ method: "PATCH",
269
+ body: { role_pid: target.pid },
270
+ toolName: "update_member_role",
271
+ skipOrgInjection: true,
272
+ });
273
+ if (!result.success) {
274
+ return { content: [{ type: "text", text: `Failed to change member role (${result.statusCode}): ${result.message}` }] };
275
+ }
182
276
  return {
183
277
  content: [
184
- { type: "text", text: `Invitation sent to ${email}.` },
278
+ { type: "text", text: `Member ${user_id} is now ${target.name} (priority ${target.priority}).` },
185
279
  { type: "text", text: JSON.stringify(result.data, null, 2) },
186
280
  ],
187
281
  };
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.js","sourceRoot":"","sources":["../../src/tools/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,kFAAkF;AAClF,SAAS,YAAY,CAAC,eAAwB;IAC5C,OAAO,eAAe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* PostgreSQL client TLS - encryption in transit for client connections.
4
+ *
5
+ * Endpoint: PATCH /aws/v1/instances/:pid with `{ tls_enabled }` and NOTHING ELSE.
6
+ * The backend refuses the request outright if any other field rides along
7
+ * ("tls_enabled must be sent alone"), which is why this is its own tool rather
8
+ * than another optional field on `update_instance`.
9
+ *
10
+ * State is per instance GROUP, not per instance: one call fans out across the
11
+ * primary and every replica, and certificates are issued lazily per group. A
12
+ * restore or a fork deliberately drops the TLS flag, because the new group has
13
+ * no certificate of its own yet - so TLS has to be re-enabled on a restored or
14
+ * forked instance.
15
+ */
16
+ export declare function registerPostgresTlsTools(server: McpServer): void;
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ import { apiRequest } from "../client.js";
3
+ /**
4
+ * PostgreSQL client TLS - encryption in transit for client connections.
5
+ *
6
+ * Endpoint: PATCH /aws/v1/instances/:pid with `{ tls_enabled }` and NOTHING ELSE.
7
+ * The backend refuses the request outright if any other field rides along
8
+ * ("tls_enabled must be sent alone"), which is why this is its own tool rather
9
+ * than another optional field on `update_instance`.
10
+ *
11
+ * State is per instance GROUP, not per instance: one call fans out across the
12
+ * primary and every replica, and certificates are issued lazily per group. A
13
+ * restore or a fork deliberately drops the TLS flag, because the new group has
14
+ * no certificate of its own yet - so TLS has to be re-enabled on a restored or
15
+ * forked instance.
16
+ */
17
+ export function registerPostgresTlsTools(server) {
18
+ server.tool("set_postgres_tls", `Turn client TLS on or off for a PostgreSQL instance group - encryption in transit between clients and the database.
19
+
20
+ WHOLE GROUP, ONE CALL. TLS is group state, so this covers the primary and every replica together; there is no per-replica setting. Certificates are issued lazily per group.
21
+
22
+ Enabling is the right default for anything a client connects to over a network the user does not control, and worth recommending if a production Postgres has it off. Once on, clients should connect with \`sslmode=require\` (or stricter) - a client left on the default may keep connecting in the clear.
23
+
24
+ TURNING IT OFF is a downgrade, not a cleanup: connections go back to plaintext and any client pinned to \`sslmode=require\` starts failing. Confirm the user means it.
25
+
26
+ Postgres ONLY (422 on any other engine). The instance must be \`running\` or \`provisioned\` and must have a registered agent. Fan-out is dispatched as tasks; a response saying TLS is "already" in that state is a no-op, not a failure.
27
+
28
+ AFTER A RESTORE OR A FORK, TLS IS OFF even if the source had it on - the new group starts without a certificate. Re-enable it explicitly and tell the user, because a restored instance silently serving plaintext is the kind of thing nobody checks.`, {
29
+ instance_id: z.string().min(1, "Instance PID is required"),
30
+ tls_enabled: z.boolean().describe("true = require/allow TLS for client connections across the group; false = back to plaintext"),
31
+ confirm: z.boolean().optional().describe("Required only when turning TLS OFF, since that downgrades every client connection in the group."),
32
+ }, async ({ instance_id, tls_enabled, confirm }) => {
33
+ if (!tls_enabled && !confirm) {
34
+ return {
35
+ content: [{
36
+ type: "text",
37
+ text: `About to DISABLE client TLS on instance group ${instance_id}.\n\nConnections revert to plaintext across the primary and every replica, and any client configured with \`sslmode=require\` will stop connecting.\n\nIf the goal is to fix a connection problem, check the client's sslmode first - disabling TLS server-side is rarely the right fix. To proceed, call again with confirm=true.`,
38
+ }],
39
+ };
40
+ }
41
+ // Sent alone, deliberately: the backend 422s if any other key is present.
42
+ const result = await apiRequest(`/aws/v1/instances/${instance_id}`, {
43
+ method: "PATCH",
44
+ body: { tls_enabled },
45
+ toolName: "set_postgres_tls",
46
+ skipOrgInjection: true,
47
+ });
48
+ if (!result.success) {
49
+ return { content: [{ type: "text", text: `Failed to change TLS (${result.statusCode}): ${result.message}` }] };
50
+ }
51
+ return {
52
+ content: [
53
+ {
54
+ type: "text",
55
+ text: tls_enabled
56
+ ? "TLS enablement dispatched across the instance group. Once it completes, point clients at `sslmode=require` - until they do, they may still connect in the clear."
57
+ : "TLS disablement dispatched across the instance group. Client connections will be plaintext; clients pinned to `sslmode=require` will fail.",
58
+ },
59
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
60
+ ],
61
+ };
62
+ });
63
+ }
64
+ //# sourceMappingURL=postgres-tls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-tls.js","sourceRoot":"","sources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C;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,WAAW;wBACf,CAAC,CAAC,kKAAkK;wBACpK,CAAC,CAAC,4IAA4I;iBACjJ;gBACD,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;aAC7D;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerProjectActivityTools(server: McpServer): void;
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import { apiRequest } from "../client.js";
3
+ import { session } from "../session.js";
4
+ /**
5
+ * Project activity feed - one chronological list per project, merging Hetzner's
6
+ * server-action history with the platform's own ActivityLog.
7
+ *
8
+ * Endpoint:
9
+ * - GET /api/v1/platform/projects/:pid/activities?page=&per_page=
10
+ *
11
+ * Read-only and ungated: it works on a stopped or billing-suspended project, which
12
+ * is exactly when someone needs it.
13
+ */
14
+ const PROJECTS_BASE = "/api/v1/platform/projects";
15
+ const NO_ORG = "No active organization. Call `list_organizations` then `select_organization` first.";
16
+ function hasOrg() {
17
+ return session.getActiveOrgId() !== null;
18
+ }
19
+ export function registerProjectActivityTools(server) {
20
+ server.tool("list_project_activities", `The history of what has happened to a project, newest first. This is the tool for "why did my project go down", "when was this restarted", "who deleted that service" - questions no other project tool can answer.
21
+
22
+ Two sources merged into one chronological, paginated feed, each item tagged with \`source\`:
23
+ - \`hetzner\` - infrastructure actions on the server itself: create_server, rebuild, enable_backup, assign_primary_ip and so on.
24
+ - \`platform\` - our own events: backups, restores, deployments, provisioning stages, lifecycle changes including credit-driven stops.
25
+
26
+ Reading them together is the point. A project that stopped answering shows the platform event and the server action side by side, which is usually enough to tell "we stopped it for billing" from "the machine was rebuilt".
27
+
28
+ If Hetzner is unreachable the feed degrades to platform events only and sets \`meta.server_activities_available: false\` rather than failing. Check that flag before concluding nothing happened at the infrastructure level - an empty infra history and an unavailable one look identical otherwise.
29
+
30
+ Works on a stopped or billing-suspended project.`, {
31
+ project_pid: z.string().min(1),
32
+ page: z.number().int().min(1).optional().describe("1-based page number; omit for the first (newest) page"),
33
+ per_page: z.number().int().min(1).max(100).optional().describe("Items per page"),
34
+ }, async ({ project_pid, page, per_page }) => {
35
+ if (!hasOrg())
36
+ return { content: [{ type: "text", text: NO_ORG }] };
37
+ const query = {};
38
+ if (page !== undefined)
39
+ query.page = String(page);
40
+ if (per_page !== undefined)
41
+ query.per_page = String(per_page);
42
+ const result = await apiRequest(`${PROJECTS_BASE}/${project_pid}/activities`, {
43
+ toolName: "list_project_activities",
44
+ query,
45
+ });
46
+ if (!result.success) {
47
+ return { content: [{ type: "text", text: `Failed to list project activities (${result.statusCode}): ${result.message}` }] };
48
+ }
49
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
50
+ });
51
+ }
52
+ //# sourceMappingURL=project-activities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-activities.js","sourceRoot":"","sources":["../../src/tools/project-activities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;;;;;GASG;AAEH,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAElD,MAAM,MAAM,GACV,qFAAqF,CAAC;AAExF,SAAS,MAAM;IACb,OAAO,OAAO,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,MAAiB;IAC5D,MAAM,CAAC,IAAI,CACT,yBAAyB,EACzB;;;;;;;;;;iDAU6C,EAC7C;QACE,WAAW,EAAE,CAAC,CAAC,M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AAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerProjectBackupTools(server: McpServer): void;
@@ -0,0 +1,159 @@
1
+ import { z } from "zod";
2
+ import { apiRequest } from "../client.js";
3
+ import { session } from "../session.js";
4
+ /**
5
+ * Project backups - native Hetzner snapshots of a project's whole VM.
6
+ *
7
+ * Endpoints:
8
+ * - GET /api/v1/platform/projects/:pid/backups
9
+ * - POST /api/v1/platform/projects/:pid/backups/enable (202)
10
+ * - POST /api/v1/platform/projects/:pid/backups/disable (202 - DELETES existing backups)
11
+ * - POST /api/v1/platform/projects/:pid/backups/restore (202 - rebuilds the VM's boot disk)
12
+ *
13
+ * Hetzner owns the schedule and retention; there is no local backup record, so
14
+ * `list_project_backups` reads through to Hetzner and the toggles only flip project
15
+ * state. Hetzner rotates and auto-deletes backups with the server.
16
+ *
17
+ * DIFFERENT THING from the managed-database backups in `backups.ts`. Those are EBS
18
+ * disk snapshots and ClickHouse data backups of an AWS instance. These are whole-VM
19
+ * images of a PaaS project's server, and they are the ONLY backup a project has -
20
+ * a project's databases and services live on that VM.
21
+ *
22
+ * NOT BILLED. There is no backup component for coolify and no `hetzner_*_backup` SKU,
23
+ * so the platform absorbs Hetzner's charge in full. An earlier version of this screen
24
+ * told users it added ~20% to the server cost; that was wrong and was removed. Do not
25
+ * reintroduce a cost claim here.
26
+ */
27
+ const PROJECTS_BASE = "/api/v1/platform/projects";
28
+ const NO_ORG = "No active organization. Call `list_organizations` then `select_organization` first.";
29
+ function hasOrg() {
30
+ return session.getActiveOrgId() !== null;
31
+ }
32
+ /** Shared with every tool here: what a failure actually means. */
33
+ const FAILURE_NOTE = "A 409 means the project is not `active` yet (or its server is not up) - wait, do not retry in a loop. A 502 means Hetzner refused the operation.";
34
+ export function registerProjectBackupTools(server) {
35
+ server.tool("list_project_backups", `List the automatic backups of a project's server, read live from Hetzner.
36
+
37
+ Returns \`backups_enabled\`, a \`backup_schedule\` (\`cadence\`, \`retention\`, and the UTC window) and the \`backups\` themselves. Each backup carries the image id you pass to \`restore_project_backup\`.
38
+
39
+ Backups are daily and seven are kept - both fixed, neither configurable. Hetzner assigns the daily window shortly AFTER backups are switched on, so a just-enabled project can legitimately report the cadence and retention with a null window; that is "window pending", not a fault.
40
+
41
+ This is a read and works on a stopped or billing-suspended project, so it is safe to call when a project is in trouble and the user is deciding whether they can recover it.
42
+
43
+ Backups cost the customer nothing - the platform absorbs the provider charge. Do not quote a backup price.`, {
44
+ project_pid: z.string().min(1),
45
+ }, async ({ project_pid }) => {
46
+ if (!hasOrg())
47
+ return { content: [{ type: "text", text: NO_ORG }] };
48
+ const result = await apiRequest(`${PROJECTS_BASE}/${project_pid}/backups`, {
49
+ toolName: "list_project_backups",
50
+ });
51
+ if (!result.success) {
52
+ return { content: [{ type: "text", text: `Failed to list project backups (${result.statusCode}): ${result.message}` }] };
53
+ }
54
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
55
+ });
56
+ server.tool("enable_project_backups", `Turn on automatic daily backups of a project's server. Seven are kept, on a window Hetzner assigns shortly after this call.
57
+
58
+ FREE. There is no backup SKU for projects, so this adds nothing to the bill - the platform absorbs the provider cost. Say that plainly if the user asks what it costs; do not hedge with a percentage.
59
+
60
+ Given that, this is close to a straight win for any project holding real data, and worth recommending when a user has databases or services in a project with backups off.
61
+
62
+ The project must be \`active\`. ${FAILURE_NOTE}
63
+
64
+ Returns 202. Confirm with \`list_project_backups\`; the first backup appears after the first window passes, not immediately.`, {
65
+ project_pid: z.string().min(1),
66
+ }, async ({ project_pid }) => {
67
+ if (!hasOrg())
68
+ return { content: [{ type: "text", text: NO_ORG }] };
69
+ const result = await apiRequest(`${PROJECTS_BASE}/${project_pid}/backups/enable`, {
70
+ method: "POST",
71
+ toolName: "enable_project_backups",
72
+ });
73
+ if (!result.success) {
74
+ return { content: [{ type: "text", text: `Failed to enable project backups (${result.statusCode}): ${result.message}` }] };
75
+ }
76
+ return {
77
+ content: [
78
+ { type: "text", text: "Automatic daily backups enabled (7 kept, no extra charge). The window is assigned shortly - `list_project_backups` will show it, and the first backup lands after the first window passes." },
79
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
80
+ ],
81
+ };
82
+ });
83
+ server.tool("disable_project_backups", `DESTRUCTIVE: turn off automatic backups for a project AND DELETE THE BACKUPS ALREADY TAKEN. Hetzner removes them with the schedule; there is no pause that keeps them and no way to get them back.
84
+
85
+ So this is not "stop making new backups" - it is "stop, and throw away every restore point this project has". Check with the user that they mean both. If they only want to stop paying for something, tell them backups are free and there is nothing to save.
86
+
87
+ The project must be \`active\`. ${FAILURE_NOTE}
88
+
89
+ You MUST set confirm=true to proceed.`, {
90
+ project_pid: z.string().min(1),
91
+ confirm: z.boolean().describe("Must be true. Deletes every existing backup of this project, irreversibly."),
92
+ }, async ({ project_pid, confirm }) => {
93
+ if (!hasOrg())
94
+ return { content: [{ type: "text", text: NO_ORG }] };
95
+ if (!confirm) {
96
+ return {
97
+ content: [{
98
+ type: "text",
99
+ text: `About to disable backups on project ${project_pid}.\n\nThis DELETES every backup already taken - the project loses all of its restore points, permanently. Backups are free, so there is no cost reason to do this.\n\nCall \`list_project_backups\` first if the user wants to see what they are giving up. To proceed, call again with confirm=true.`,
100
+ }],
101
+ };
102
+ }
103
+ const result = await apiRequest(`${PROJECTS_BASE}/${project_pid}/backups/disable`, {
104
+ method: "POST",
105
+ toolName: "disable_project_backups",
106
+ });
107
+ if (!result.success) {
108
+ return { content: [{ type: "text", text: `Failed to disable project backups (${result.statusCode}): ${result.message}` }] };
109
+ }
110
+ return {
111
+ content: [
112
+ { type: "text", text: "Automatic backups disabled and existing backups removed." },
113
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
114
+ ],
115
+ };
116
+ });
117
+ server.tool("restore_project_backup", `DESTRUCTIVE: rebuild a project's server from one of its backups. The VM's boot disk is overwritten, so EVERYTHING on it goes back to the state it was in when that backup was taken - the Coolify install, every service, and every project database, including anything written since.
118
+
119
+ This is a real rollback, unlike the ClickHouse data restore in \`restore_backup\` which merges. Data created after the chosen backup is gone and cannot be recovered.
120
+
121
+ The project goes to status \`restoring\` and is UNAVAILABLE while the server is rebuilt. Every app and database in it is down for the duration.
122
+
123
+ Requires \`image_id\` from \`list_project_backups\`, and \`name\` must exactly match the project's current name (422 otherwise) - that check exists so a restore cannot be fired at the wrong project. Backups must be enabled.
124
+
125
+ ${FAILURE_NOTE}
126
+
127
+ Before calling: show the user the backup list with dates, get them to pick, and state what they will lose. You MUST set confirm=true.`, {
128
+ project_pid: z.string().min(1),
129
+ image_id: z.union([z.string(), z.number()]).describe("The backup image to restore, from `list_project_backups`"),
130
+ name: z.string().min(1).describe("The project's exact current name - must match or the backend refuses"),
131
+ confirm: z.boolean().describe("Must be true. Overwrites the server's disk; everything written since this backup is lost."),
132
+ }, async ({ project_pid, image_id, name, confirm }) => {
133
+ if (!hasOrg())
134
+ return { content: [{ type: "text", text: NO_ORG }] };
135
+ if (!confirm) {
136
+ return {
137
+ content: [{
138
+ type: "text",
139
+ text: `About to REBUILD project \`${name}\` (${project_pid}) from backup image ${image_id}.\n\nThe server's disk is overwritten. Coolify, every service and every project database revert to that backup's state, and anything written since is permanently lost. The project is unavailable throughout.\n\nConfirm with the user which backup they picked and what they are discarding, then call again with confirm=true.`,
140
+ }],
141
+ };
142
+ }
143
+ const result = await apiRequest(`${PROJECTS_BASE}/${project_pid}/backups/restore`, {
144
+ method: "POST",
145
+ body: { image_id, name },
146
+ toolName: "restore_project_backup",
147
+ });
148
+ if (!result.success) {
149
+ return { content: [{ type: "text", text: `Failed to start project restore (${result.statusCode}): ${result.message}` }] };
150
+ }
151
+ return {
152
+ content: [
153
+ { type: "text", text: "Restore started. The project is now `restoring` and unavailable until the server has been rebuilt - poll `get_project` until it returns to `active`." },
154
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
155
+ ],
156
+ };
157
+ });
158
+ }
159
+ //# sourceMappingURL=project-backups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-backups.js","sourceRoot":"","sources":["../../src/tools/project-backups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAElD,MAAM,MAAM,GACV,qFAAqF,CAAC;AAExF,SAAS,MAAM;IACb,OAAO,OAAO,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC;AAC3C,CAAC;AAED,kEAAkE;AAClE,MAAM,YAAY,GAChB,kJAAkJ,CAAC;AAErJ,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB;;;;;;;;2GAQuG,EACvG;QACE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KAC/B,EACD,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;QACxB,IAAI,CAAC,MAAM,EAAE;YAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACpE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAU,GAAG,aAAa,IAAI,WAAW,UAAU,EAAE;YAClF,QAAQ,EAAE,sBAAsB;SACjC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mCAAmC,M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AM,EAAE,IAAI,EAAE,oCAAoC,MAAM,CAAC,UAAU,MAAM,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;QAC5H,CAAC;QACD,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sJAAsJ,EAAE;gBAC9K,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;aAC7D;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -9,10 +9,12 @@ import { session } from "../session.js";
9
9
  *
10
10
  * Endpoints:
11
11
  * - GET /api/v1/platform/projects/:pid/databases
12
+ * - GET /api/v1/platform/projects/:pid/databases/:database_pid (refreshes status live)
12
13
  * - POST /api/v1/platform/projects/:pid/databases/:db_type (202 - async provisioning)
13
14
  * - DELETE /api/v1/platform/projects/:pid/databases/:database_pid (202; body {name} must match)
14
15
  *
15
- * The project must be `active` before creating a database (409 otherwise).
16
+ * The project must be `active` before creating a database (409 otherwise). `show` is
17
+ * NOT gated that way - a billing-stopped project can still be inspected.
16
18
  */
17
19
  const PROJECTS_BASE = "/api/v1/platform/projects";
18
20
  const DB_TYPES = ["postgres", "redis", "mysql", "mongodb"];
@@ -36,7 +38,9 @@ function checkPassword(label, v) {
36
38
  return null;
37
39
  }
38
40
  export function registerProjectDatabaseTools(server) {
39
- server.tool("list_project_databases", "List the databases attached to a project (Postgres/Redis/MySQL/MongoDB provisioned via Coolify, NOT AWS managed instances). Returns pid, name, db_type, status (active | inactive | creating | failed | unknown), is_public, and public_port. Passwords are never returned here.", {
41
+ server.tool("list_project_databases", `List the databases attached to a project (Postgres/Redis/MySQL/MongoDB provisioned via Coolify, NOT AWS managed instances). Returns pid, name, db_type, status (\`active\` | \`inactive\` | \`creating\` | \`failed\` | \`unknown\`), is_public, public_port, \`vector_enabled\` / \`timescaledb_enabled\` on Postgres, and a \`provisioning\` block with per-stage progress.
42
+
43
+ Passwords are never returned here. Statuses on this list are the last known values; \`get_project_database\` re-reads one live from Coolify.`, {
40
44
  project_pid: z.string().min(1),
41
45
  }, async ({ project_pid }) => {
42
46
  if (!hasOrg())
@@ -49,6 +53,26 @@ export function registerProjectDatabaseTools(server) {
49
53
  }
50
54
  return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
51
55
  });
56
+ server.tool("get_project_database", `Get one project database, with its status re-read LIVE from Coolify rather than served from the last known value. Use this when \`list_project_databases\` shows \`creating\` and you need to know whether it has actually finished, or when a status looks stale.
57
+
58
+ Also returns \`vector_enabled\` / \`timescaledb_enabled\` (Postgres) and the \`provisioning\` stage block, so it is the tool to reach for when a user asks why provisioning is taking so long.
59
+
60
+ Unlike create, this works on a stopped or billing-suspended project. On one of those the live refresh is skipped (the server is powered off and there is nothing to ask) and you get the stored record - so a \`creating\` status on a stopped project means "we never found out", not "still working".
61
+
62
+ Passwords are not returned. Connection details for a project database come from the console.`, {
63
+ project_pid: z.string().min(1),
64
+ database_pid: z.string().min(1),
65
+ }, async ({ project_pid, database_pid }) => {
66
+ if (!hasOrg())
67
+ return { content: [{ type: "text", text: NO_ORG }] };
68
+ const result = await apiRequest(`${PROJECTS_BASE}/${project_pid}/databases/${database_pid}`, {
69
+ toolName: "get_project_database",
70
+ });
71
+ if (!result.success) {
72
+ return { content: [{ type: "text", text: `Failed to get project database (${result.statusCode}): ${result.message}` }] };
73
+ }
74
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
75
+ });
52
76
  server.tool("create_project_database", `Create a database inside a project (provisioned via Coolify; returns 202, status starts \`creating\` - poll \`list_project_databases\`). The project must be \`active\`. Provide the type-specific credentials (see fields). Passwords must be 8+ chars with no spaces or shell-dangerous chars. \`is_public\` is REQUIRED and has no default: ASK THE USER whether the database should be publicly reachable on a port (convenient for external clients but exposes it to the internet) or kept private to the project (safer). Do not assume.
53
77
 
54
78
  POSTGRES EXTENSIONS (create-time only here - unlike AWS instances, a project database cannot gain an extension later; you would have to recreate it):