microsandbox-mcp 0.3.8

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.
@@ -0,0 +1,81 @@
1
+ import { z } from "zod";
2
+ import { Volume } from "microsandbox";
3
+ import { formatError } from "../utils/errors.js";
4
+ export function registerVolumeTools(server) {
5
+ server.registerTool("volume_create", {
6
+ title: "Create Volume",
7
+ description: "Create a named persistent volume. Volumes survive sandbox restarts and can be shared across sandboxes.",
8
+ inputSchema: z.object({
9
+ name: z.string().describe("Volume name"),
10
+ sizeMib: z.number().int().min(1).optional().describe("Quota in MiB"),
11
+ }),
12
+ annotations: {
13
+ readOnlyHint: false,
14
+ destructiveHint: false,
15
+ idempotentHint: false,
16
+ },
17
+ }, async ({ name, sizeMib }) => {
18
+ try {
19
+ const config = {
20
+ name,
21
+ ...(sizeMib && { quotaMib: sizeMib }),
22
+ };
23
+ await Volume.create(config);
24
+ return {
25
+ content: [{ type: "text", text: JSON.stringify({ name, created: true }, null, 2) }],
26
+ };
27
+ }
28
+ catch (error) {
29
+ return formatError(error);
30
+ }
31
+ });
32
+ server.registerTool("volume_list", {
33
+ title: "List Volumes",
34
+ description: "List all named volumes.",
35
+ inputSchema: z.object({}),
36
+ annotations: {
37
+ readOnlyHint: true,
38
+ destructiveHint: false,
39
+ idempotentHint: true,
40
+ },
41
+ }, async () => {
42
+ try {
43
+ const handles = await Volume.list();
44
+ const results = handles.map((h) => ({
45
+ name: h.name,
46
+ quotaMib: h.quotaMib,
47
+ usedBytes: h.usedBytes,
48
+ createdAt: h.createdAt,
49
+ }));
50
+ return {
51
+ content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
52
+ };
53
+ }
54
+ catch (error) {
55
+ return formatError(error);
56
+ }
57
+ });
58
+ server.registerTool("volume_remove", {
59
+ title: "Remove Volume",
60
+ description: "Remove a named volume.",
61
+ inputSchema: z.object({
62
+ name: z.string().describe("Volume name"),
63
+ }),
64
+ annotations: {
65
+ readOnlyHint: false,
66
+ destructiveHint: true,
67
+ idempotentHint: true,
68
+ },
69
+ }, async ({ name }) => {
70
+ try {
71
+ await Volume.remove(name);
72
+ return {
73
+ content: [{ type: "text", text: JSON.stringify({ name, removed: true }, null, 2) }],
74
+ };
75
+ }
76
+ catch (error) {
77
+ return formatError(error);
78
+ }
79
+ });
80
+ }
81
+ //# sourceMappingURL=volume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"volume.js","sourceRoot":"","sources":["../../src/tools/volume.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,KAAK,EAAE,eAAe;QACtB,WAAW,EACT,wGAAwG;QAC1G,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;YACxC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;SACrE,CAAC;QACF,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;SACtB;KACF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG;gBACb,IAAI;gBACJ,GAAG,CAAC,OAAO,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;aACtC,CAAC;YACF,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC5B,OAAO;g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KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,wBAAwB;QACrC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;SACzC,CAAC;QACF,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI;YACrB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC1B,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function formatError(error: unknown): {
2
+ content: {
3
+ type: "text";
4
+ text: string;
5
+ }[];
6
+ isError: true;
7
+ };
@@ -0,0 +1,8 @@
1
+ export function formatError(error) {
2
+ const message = error instanceof Error ? error.message : String(error);
3
+ return {
4
+ content: [{ type: "text", text: message }],
5
+ isError: true,
6
+ };
7
+ }
8
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "microsandbox-mcp",
3
+ "version": "0.3.8",
4
+ "description": "MCP server for microsandbox — manage microVM sandboxes from any AI agent",
5
+ "type": "module",
6
+ "bin": {
7
+ "microsandbox-mcp": "./bin/microsandbox-mcp.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "files": [
11
+ "dist",
12
+ "bin",
13
+ "postinstall.cjs"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsc --watch",
18
+ "start": "node dist/index.js",
19
+ "postinstall": "node postinstall.cjs"
20
+ },
21
+ "dependencies": {
22
+ "@modelcontextprotocol/sdk": "^1.29.0",
23
+ "microsandbox": "^0.3.8",
24
+ "zod": "^4.3.6"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "^5.8.0",
28
+ "@types/node": "^22.0.0"
29
+ },
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "license": "Apache-2.0",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/superradcompany/microsandbox-mcp"
37
+ },
38
+ "keywords": [
39
+ "mcp",
40
+ "model-context-protocol",
41
+ "microsandbox",
42
+ "sandbox",
43
+ "microvm",
44
+ "ai-agent"
45
+ ]
46
+ }
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Re-exports the microsandbox SDK postinstall to ensure msb + libkrunfw are available.
4
+ // The microsandbox npm package already handles this in its own postinstall, but when
5
+ // installed via npx (which may use a cache), the postinstall might not re-run.
6
+ // This script ensures the runtime dependencies are always present.
7
+
8
+ const { execFileSync } = require("child_process");
9
+ const fs = require("fs");
10
+ const os = require("os");
11
+ const path = require("path");
12
+
13
+ const BASE_DIR = path.join(os.homedir(), ".microsandbox");
14
+ const BIN_DIR = path.join(BASE_DIR, "bin");
15
+ const MSB_PATH = path.join(BIN_DIR, "msb");
16
+
17
+ function isInstalled() {
18
+ if (!fs.existsSync(MSB_PATH)) return false;
19
+ try {
20
+ execFileSync(MSB_PATH, ["--version"], { encoding: "utf8", stdio: "pipe" });
21
+ return true;
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+
27
+ if (!isInstalled()) {
28
+ // Delegate to the microsandbox SDK's postinstall by requiring it directly.
29
+ try {
30
+ const sdkPostinstall = require.resolve("microsandbox/postinstall.js");
31
+ require(sdkPostinstall);
32
+ } catch {
33
+ console.error(
34
+ "microsandbox-mcp: msb runtime not found. Install manually:\n" +
35
+ " curl -fsSL https://install.microsandbox.dev | sh"
36
+ );
37
+ // Don't fail npm install.
38
+ }
39
+ }