@hoststack.dev/mcp 0.2.0 → 0.3.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/dist/hoststack-mcp.js +217 -37
- package/dist/hoststack-mcp.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +217 -37
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/hoststack-mcp.js
CHANGED
|
@@ -320,6 +320,9 @@ function shapeUser(value) {
|
|
|
320
320
|
function shapeTeam(value) {
|
|
321
321
|
return isObject(value) ? dropNullsAndInternals(value) : {};
|
|
322
322
|
}
|
|
323
|
+
function shapeVolume(value) {
|
|
324
|
+
return isObject(value) ? dropNullsAndInternals(value) : {};
|
|
325
|
+
}
|
|
323
326
|
|
|
324
327
|
// src/resources/hoststack-resources.ts
|
|
325
328
|
defineResource({
|
|
@@ -585,8 +588,8 @@ defineTool({
|
|
|
585
588
|
handler: async (args2, ctx) => {
|
|
586
589
|
const teamId = await ctx.resolveTeamId();
|
|
587
590
|
const response = await ctx.hoststack.deploys.list(teamId, args2.service_id);
|
|
588
|
-
const data = shapeList(response, "
|
|
589
|
-
const summary = data.items.length === 0 ? `No deploys yet for service ${args2.service_id}.` : `Found ${data.items.length} deploy${data.items.length === 1 ? "" : "s"} for service ${args2.service_id}.`;
|
|
591
|
+
const data = shapeList(response, "data", shapeDeploy);
|
|
592
|
+
const summary = data.items.length === 0 ? `No deploys yet for service ${args2.service_id}.` : `Found ${data.items.length} deploy${data.items.length === 1 ? "" : "s"} for service ${args2.service_id} (page ${response.page} of ${response.totalPages}, ${response.total} total).`;
|
|
590
593
|
return respond({ summary, data });
|
|
591
594
|
}
|
|
592
595
|
});
|
|
@@ -692,22 +695,32 @@ defineTool({
|
|
|
692
695
|
" - service_id: publicId of the service.",
|
|
693
696
|
" - deploy_id: publicId of the deploy.",
|
|
694
697
|
"",
|
|
695
|
-
"Returns: { logs: string } \u2014
|
|
698
|
+
"Returns: { logs: string, lineCount: number, nextAfterId: number | null } \u2014 flattened build output joined with newlines, line count, and a cursor for pagination (pass back as after_id to fetch the next page).",
|
|
696
699
|
"",
|
|
697
|
-
'Example: get_deploy_logs({ service_id: "svc_abc", deploy_id: "dpl_xyz" }) \u2192 { logs: "Building\u2026\\nStep 1/8\u2026\\n\u2026" }'
|
|
700
|
+
'Example: get_deploy_logs({ service_id: "svc_abc", deploy_id: "dpl_xyz" }) \u2192 { logs: "Building\u2026\\nStep 1/8\u2026\\n\u2026", lineCount: 42, nextAfterId: 1234 }'
|
|
698
701
|
].join("\n"),
|
|
699
702
|
input: {
|
|
700
703
|
service_id: z5.string().describe("Service publicId."),
|
|
701
|
-
deploy_id: z5.string().describe("Deploy publicId.")
|
|
704
|
+
deploy_id: z5.string().describe("Deploy publicId."),
|
|
705
|
+
after_id: z5.number().int().optional().describe("Pagination cursor from a previous response\u2019s nextAfterId."),
|
|
706
|
+
limit: z5.number().int().min(1).max(5e3).optional().describe("Max log entries to fetch (default 500, hard cap 5000).")
|
|
702
707
|
},
|
|
703
708
|
handler: async (args2, ctx) => {
|
|
704
709
|
const teamId = await ctx.resolveTeamId();
|
|
705
|
-
const response = await ctx.hoststack.deploys.getLogs(
|
|
706
|
-
|
|
707
|
-
|
|
710
|
+
const response = await ctx.hoststack.deploys.getLogs(
|
|
711
|
+
teamId,
|
|
712
|
+
args2.service_id,
|
|
713
|
+
args2.deploy_id,
|
|
714
|
+
{
|
|
715
|
+
...args2.after_id !== void 0 ? { afterId: args2.after_id } : {},
|
|
716
|
+
...args2.limit !== void 0 ? { limit: args2.limit } : {}
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
const entries = response.logs;
|
|
720
|
+
const logs = entries.map((e) => e.message).join("\n");
|
|
708
721
|
return respond({
|
|
709
|
-
summary: `Fetched ${
|
|
710
|
-
data: { logs }
|
|
722
|
+
summary: `Fetched ${entries.length} log line${entries.length === 1 ? "" : "s"} for deploy ${args2.deploy_id}.`,
|
|
723
|
+
data: { logs, lineCount: entries.length, nextAfterId: response.nextAfterId }
|
|
711
724
|
});
|
|
712
725
|
}
|
|
713
726
|
});
|
|
@@ -1233,52 +1246,79 @@ defineTool({
|
|
|
1233
1246
|
name: "update_service_config",
|
|
1234
1247
|
category: "services",
|
|
1235
1248
|
description: [
|
|
1236
|
-
"Update build/runtime configuration for a service: build command, start command, branch, root directory, dockerfile path, auto-deploy flag, instance count
|
|
1249
|
+
"Update build/runtime configuration for a service: build command, start command, install command, branch, root directory, dockerfile path, auto-deploy flag, instance count. All fields optional \u2014 pass only what you want to change.",
|
|
1237
1250
|
"",
|
|
1238
|
-
"When to use: the user wants to tweak how a service builds or runs
|
|
1251
|
+
"When to use: the user wants to tweak how a service builds or runs. Build/runtime fields (branch, install/build/start command, root, dockerfile) take effect on the next deploy \u2014 call trigger_deploy after if you need them applied immediately. instance_count rescales without a redeploy.",
|
|
1239
1252
|
"",
|
|
1240
1253
|
"Inputs:",
|
|
1241
1254
|
" - service_id: publicId of the service.",
|
|
1242
|
-
" - build_command, start_command (optional): shell commands.",
|
|
1255
|
+
" - install_command, build_command, start_command (optional): shell commands. Pass null to clear.",
|
|
1243
1256
|
" - branch (optional): git branch to track.",
|
|
1244
|
-
" - root_directory
|
|
1257
|
+
" - root_directory (optional): build context root inside the repo.",
|
|
1258
|
+
" - dockerfile_path (optional): path to Dockerfile relative to root_directory. Pass null to clear.",
|
|
1245
1259
|
" - auto_deploy (optional): boolean \u2014 auto-deploy on git push.",
|
|
1246
|
-
" - instance_count (optional): integer \u22651 \u2014
|
|
1247
|
-
' - plan (optional): plan tier slug (e.g. "starter", "standard", "pro").',
|
|
1260
|
+
" - instance_count (optional): integer \u22651 \u2014 pin both min and max instances to this value.",
|
|
1248
1261
|
"",
|
|
1249
|
-
"Returns: { config
|
|
1262
|
+
"Returns: { service?: Service, config?: ServiceConfig } \u2014 whichever rows were touched.",
|
|
1250
1263
|
"",
|
|
1251
|
-
'Example: update_service_config({ service_id: "svc_abc",
|
|
1264
|
+
'Example: update_service_config({ service_id: "svc_abc", start_command: "bun apps/api/src/index.ts" }) \u2192 { service: { startCommand: "bun apps/api/src/index.ts", \u2026 } }'
|
|
1252
1265
|
].join("\n"),
|
|
1253
1266
|
input: {
|
|
1254
1267
|
service_id: z9.string().describe("Service publicId."),
|
|
1255
|
-
|
|
1256
|
-
|
|
1268
|
+
install_command: z9.string().nullable().optional().describe("Install shell command. Null clears."),
|
|
1269
|
+
build_command: z9.string().nullable().optional().describe("Build shell command. Null clears."),
|
|
1270
|
+
start_command: z9.string().nullable().optional().describe("Start shell command. Null clears."),
|
|
1257
1271
|
branch: z9.string().optional().describe("Git branch to track."),
|
|
1258
1272
|
root_directory: z9.string().optional().describe("Build context root."),
|
|
1259
|
-
dockerfile_path: z9.string().optional().describe("Path to Dockerfile relative to root."),
|
|
1273
|
+
dockerfile_path: z9.string().nullable().optional().describe("Path to Dockerfile relative to root. Null clears."),
|
|
1260
1274
|
auto_deploy: z9.boolean().optional().describe("Auto-deploy on push."),
|
|
1261
|
-
instance_count: z9.number().int().positive().optional().describe("
|
|
1262
|
-
plan: z9.string().optional().describe("Plan tier slug.")
|
|
1275
|
+
instance_count: z9.number().int().positive().max(50).optional().describe("Pin min and max instances to this value (1\u201350).")
|
|
1263
1276
|
},
|
|
1264
1277
|
handler: async (args2, ctx) => {
|
|
1265
1278
|
const teamId = await ctx.resolveTeamId();
|
|
1266
|
-
const
|
|
1267
|
-
if (args2.
|
|
1268
|
-
|
|
1269
|
-
if (args2.
|
|
1270
|
-
if (args2.
|
|
1271
|
-
if (args2.dockerfile_path !== void 0)
|
|
1272
|
-
|
|
1273
|
-
if (args2.
|
|
1274
|
-
if (args2.
|
|
1275
|
-
|
|
1279
|
+
const serviceUpdate = {};
|
|
1280
|
+
if (args2.install_command !== void 0)
|
|
1281
|
+
serviceUpdate["installCommand"] = args2.install_command;
|
|
1282
|
+
if (args2.build_command !== void 0) serviceUpdate["buildCommand"] = args2.build_command;
|
|
1283
|
+
if (args2.start_command !== void 0) serviceUpdate["startCommand"] = args2.start_command;
|
|
1284
|
+
if (args2.dockerfile_path !== void 0)
|
|
1285
|
+
serviceUpdate["dockerfilePath"] = args2.dockerfile_path;
|
|
1286
|
+
if (args2.branch !== void 0) serviceUpdate["branch"] = args2.branch;
|
|
1287
|
+
if (args2.root_directory !== void 0)
|
|
1288
|
+
serviceUpdate["rootDirectory"] = args2.root_directory;
|
|
1289
|
+
if (args2.auto_deploy !== void 0) serviceUpdate["autoDeploy"] = args2.auto_deploy;
|
|
1290
|
+
const configUpdate = {};
|
|
1291
|
+
if (args2.instance_count !== void 0) {
|
|
1292
|
+
configUpdate["minInstances"] = args2.instance_count;
|
|
1293
|
+
configUpdate["maxInstances"] = args2.instance_count;
|
|
1294
|
+
}
|
|
1295
|
+
if (Object.keys(serviceUpdate).length === 0 && Object.keys(configUpdate).length === 0) {
|
|
1276
1296
|
return respond({ summary: "No fields to update.", data: {} });
|
|
1277
1297
|
}
|
|
1278
|
-
const
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1298
|
+
const data = {};
|
|
1299
|
+
const touchedFields = [];
|
|
1300
|
+
if (Object.keys(serviceUpdate).length > 0) {
|
|
1301
|
+
const serviceResponse = await ctx.hoststack.services.update(
|
|
1302
|
+
teamId,
|
|
1303
|
+
args2.service_id,
|
|
1304
|
+
serviceUpdate
|
|
1305
|
+
);
|
|
1306
|
+
data["service"] = shape(serviceResponse.service);
|
|
1307
|
+
touchedFields.push(...Object.keys(serviceUpdate));
|
|
1308
|
+
}
|
|
1309
|
+
if (Object.keys(configUpdate).length > 0) {
|
|
1310
|
+
const configResponse = await ctx.hoststack.services.updateConfig(
|
|
1311
|
+
teamId,
|
|
1312
|
+
args2.service_id,
|
|
1313
|
+
configUpdate
|
|
1314
|
+
);
|
|
1315
|
+
data["config"] = shape(configResponse.config);
|
|
1316
|
+
touchedFields.push(...Object.keys(configUpdate));
|
|
1317
|
+
}
|
|
1318
|
+
return respond({
|
|
1319
|
+
summary: `Updated ${touchedFields.join(", ")} on service ${args2.service_id}.`,
|
|
1320
|
+
data
|
|
1321
|
+
});
|
|
1282
1322
|
}
|
|
1283
1323
|
});
|
|
1284
1324
|
defineTool({
|
|
@@ -1369,6 +1409,146 @@ defineTool({
|
|
|
1369
1409
|
}
|
|
1370
1410
|
});
|
|
1371
1411
|
|
|
1412
|
+
// src/tools/volumes.ts
|
|
1413
|
+
import { z as z10 } from "zod";
|
|
1414
|
+
defineTool({
|
|
1415
|
+
name: "list_volumes",
|
|
1416
|
+
category: "volumes",
|
|
1417
|
+
description: [
|
|
1418
|
+
"List persistent disks attached to a service. Volumes mount writable storage into the container at the path you choose, surviving redeploys and restarts.",
|
|
1419
|
+
"",
|
|
1420
|
+
"When to use: auditing what disks are attached, checking sizes before adding more, or confirming a volume took effect after creation. Note: storage is metered for billing \u2014 use this to spot oversized disks.",
|
|
1421
|
+
"",
|
|
1422
|
+
"Inputs:",
|
|
1423
|
+
" - service_id: publicId of the service.",
|
|
1424
|
+
"",
|
|
1425
|
+
"Returns: { items: Volume[] } \u2014 each entry has id, publicId, name, mountPath, sizeGb, status (pending|active|deleting), createdAt, updatedAt.",
|
|
1426
|
+
"",
|
|
1427
|
+
'Example: list_volumes({ service_id: "svc_abc" }) \u2192 { items: [{ name: "data", mountPath: "/var/data", sizeGb: 10, status: "active" }] }'
|
|
1428
|
+
].join("\n"),
|
|
1429
|
+
input: {
|
|
1430
|
+
service_id: z10.string().describe("Service publicId (e.g. svc_abc123).")
|
|
1431
|
+
},
|
|
1432
|
+
handler: async (args2, ctx) => {
|
|
1433
|
+
const teamId = await ctx.resolveTeamId();
|
|
1434
|
+
const response = await ctx.hoststack.volumes.list(teamId, args2.service_id);
|
|
1435
|
+
const data = shapeList(response, "volumes", shapeVolume);
|
|
1436
|
+
const summary = data.items.length === 0 ? `No volumes attached to service ${args2.service_id}.` : `Found ${data.items.length} volume${data.items.length === 1 ? "" : "s"} on service ${args2.service_id}.`;
|
|
1437
|
+
return respond({ summary, data });
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
defineTool({
|
|
1441
|
+
name: "create_volume",
|
|
1442
|
+
category: "volumes",
|
|
1443
|
+
description: [
|
|
1444
|
+
"Attach a new persistent disk to a service. The disk gets provisioned on the host and bind-mounted into the container at `mount_path` on the next deploy. Use this when an app needs writable persistent storage \u2014 uploads, caches, SQLite databases, anything that must survive container restarts.",
|
|
1445
|
+
"",
|
|
1446
|
+
"When to use: the user mentions storing files, uploads, or any data that needs to outlive a container restart. For purely ephemeral scratch space, point the app at /tmp instead (already tmpfs-mounted, free, no provisioning needed) \u2014 see HOSTSTACK_TMP_DIR.",
|
|
1447
|
+
"",
|
|
1448
|
+
"Inputs:",
|
|
1449
|
+
" - service_id: publicId of the service to attach to.",
|
|
1450
|
+
" - name: lowercase alphanumeric + hyphens, \u226464 chars (used as the docker volume identifier \u2014 change with care once data is written).",
|
|
1451
|
+
' - mount_path: in-container absolute path (e.g. "/var/data").',
|
|
1452
|
+
" - size_gb: optional, 1\u2013100, default 1. Counts against your plan storage quota and is metered for billing.",
|
|
1453
|
+
"",
|
|
1454
|
+
"Returns: { volume: Volume } \u2014 the created record.",
|
|
1455
|
+
"",
|
|
1456
|
+
'Example: create_volume({ service_id: "svc_abc", name: "data", mount_path: "/var/data", size_gb: 10 }) \u2192 { volume: { name: "data", mountPath: "/var/data", sizeGb: 10, status: "active" } }'
|
|
1457
|
+
].join("\n"),
|
|
1458
|
+
input: {
|
|
1459
|
+
service_id: z10.string().describe("Service publicId."),
|
|
1460
|
+
name: z10.string().min(1).max(64).regex(/^[a-z0-9-]+$/).describe("Volume name (lowercase alphanumeric + hyphens)."),
|
|
1461
|
+
mount_path: z10.string().startsWith("/").max(500).describe("In-container mount path (absolute)."),
|
|
1462
|
+
size_gb: z10.number().int().min(1).max(100).optional().describe("Disk size in GB (default 1, max 100).")
|
|
1463
|
+
},
|
|
1464
|
+
handler: async (args2, ctx) => {
|
|
1465
|
+
const teamId = await ctx.resolveTeamId();
|
|
1466
|
+
const input = {
|
|
1467
|
+
name: args2.name,
|
|
1468
|
+
mountPath: args2.mount_path
|
|
1469
|
+
};
|
|
1470
|
+
if (args2.size_gb !== void 0) input.sizeGb = args2.size_gb;
|
|
1471
|
+
const response = await ctx.hoststack.volumes.create(teamId, args2.service_id, input);
|
|
1472
|
+
const data = { volume: shape(response.volume) };
|
|
1473
|
+
return respond({
|
|
1474
|
+
summary: `Attached volume "${args2.name}" (${args2.size_gb ?? 1}GB) at ${args2.mount_path} on service ${args2.service_id}.`,
|
|
1475
|
+
data
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
defineTool({
|
|
1480
|
+
name: "update_volume",
|
|
1481
|
+
category: "volumes",
|
|
1482
|
+
description: [
|
|
1483
|
+
"Update a volume's mountPath or sizeGb. Resizes take effect on the next deploy; shrinking is rejected at the storage layer (filesystems can't safely shrink under live data).",
|
|
1484
|
+
"",
|
|
1485
|
+
"When to use: the user wants to grow the disk for an existing volume, or move where it mounts inside the container.",
|
|
1486
|
+
"",
|
|
1487
|
+
"Inputs:",
|
|
1488
|
+
" - service_id: publicId of the service.",
|
|
1489
|
+
" - volume_id: publicId of the volume to update.",
|
|
1490
|
+
" - mount_path (optional): new in-container mount path.",
|
|
1491
|
+
" - size_gb (optional): new size in GB (must be \u2265 current).",
|
|
1492
|
+
"",
|
|
1493
|
+
"Returns: { volume: Volume } \u2014 the updated record.",
|
|
1494
|
+
"",
|
|
1495
|
+
'Example: update_volume({ service_id: "svc_abc", volume_id: "vol_xyz", size_gb: 20 }) \u2192 { volume: { sizeGb: 20, \u2026 } }'
|
|
1496
|
+
].join("\n"),
|
|
1497
|
+
input: {
|
|
1498
|
+
service_id: z10.string().describe("Service publicId."),
|
|
1499
|
+
volume_id: z10.string().describe("Volume publicId (e.g. vol_\u2026)."),
|
|
1500
|
+
mount_path: z10.string().startsWith("/").max(500).optional().describe("New mount path."),
|
|
1501
|
+
size_gb: z10.number().int().min(1).max(100).optional().describe("New size in GB.")
|
|
1502
|
+
},
|
|
1503
|
+
handler: async (args2, ctx) => {
|
|
1504
|
+
const teamId = await ctx.resolveTeamId();
|
|
1505
|
+
const input = {};
|
|
1506
|
+
if (args2.mount_path !== void 0) input.mountPath = args2.mount_path;
|
|
1507
|
+
if (args2.size_gb !== void 0) input.sizeGb = args2.size_gb;
|
|
1508
|
+
if (Object.keys(input).length === 0) {
|
|
1509
|
+
return respond({ summary: "No fields to update.", data: {} });
|
|
1510
|
+
}
|
|
1511
|
+
const response = await ctx.hoststack.volumes.update(
|
|
1512
|
+
teamId,
|
|
1513
|
+
args2.service_id,
|
|
1514
|
+
args2.volume_id,
|
|
1515
|
+
input
|
|
1516
|
+
);
|
|
1517
|
+
const data = { volume: shape(response.volume) };
|
|
1518
|
+
const fields = Object.keys(input).join(", ");
|
|
1519
|
+
return respond({ summary: `Updated ${fields} on volume ${args2.volume_id}.`, data });
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
defineTool({
|
|
1523
|
+
name: "delete_volume",
|
|
1524
|
+
category: "volumes",
|
|
1525
|
+
description: [
|
|
1526
|
+
"Detach and deprovision a volume. The underlying disk is destroyed \u2014 back up any data first. Async: marks the row deleting, the host agent finalises removal once it acks. A periodic reaper retries if the agent was offline at delete time.",
|
|
1527
|
+
"",
|
|
1528
|
+
"When to use: the user explicitly says to remove a volume, or you're cleaning up after retiring a service. Confirm before calling on production data.",
|
|
1529
|
+
"",
|
|
1530
|
+
"Inputs:",
|
|
1531
|
+
" - service_id: publicId of the service.",
|
|
1532
|
+
" - volume_id: publicId of the volume.",
|
|
1533
|
+
"",
|
|
1534
|
+
"Returns: { ok: true }.",
|
|
1535
|
+
"",
|
|
1536
|
+
'Example: delete_volume({ service_id: "svc_abc", volume_id: "vol_xyz" }) \u2192 { ok: true }'
|
|
1537
|
+
].join("\n"),
|
|
1538
|
+
input: {
|
|
1539
|
+
service_id: z10.string().describe("Service publicId."),
|
|
1540
|
+
volume_id: z10.string().describe("Volume publicId.")
|
|
1541
|
+
},
|
|
1542
|
+
handler: async (args2, ctx) => {
|
|
1543
|
+
const teamId = await ctx.resolveTeamId();
|
|
1544
|
+
await ctx.hoststack.volumes.delete(teamId, args2.service_id, args2.volume_id);
|
|
1545
|
+
return respond({
|
|
1546
|
+
summary: `Detached volume ${args2.volume_id} from service ${args2.service_id} (deprovisioning).`,
|
|
1547
|
+
data: { ok: true }
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1372
1552
|
// src/server-factory.ts
|
|
1373
1553
|
var PACKAGE_NAME = "hoststack";
|
|
1374
1554
|
var PACKAGE_VERSION = "0.1.2";
|