@el4cteo/rbx-studio-mcp 0.6.7 → 0.7.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.
@@ -0,0 +1,60 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { readFileSync } from "node:fs";
4
+ import { createServer } from "node:net";
5
+ import { dirname, join, resolve } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
8
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
9
+
10
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
11
+ const entrypoint = join(root, "dist", "index.js");
12
+ const packageVersion = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version;
13
+
14
+ for (const args of [
15
+ ["doctor", "--port"],
16
+ ["doctor", "--port", "44755oops"],
17
+ ["doctor", "--port", "12.5"],
18
+ ]) {
19
+ const result = spawnSync(process.execPath, [entrypoint, ...args], {
20
+ encoding: "utf8",
21
+ timeout: 10_000,
22
+ });
23
+ assert.equal(result.status, 1, `${args.join(" ")} must fail`);
24
+ assert.match(result.stderr, /failed to start: (Invalid port|Missing value for --port)/);
25
+ }
26
+
27
+ const port = await new Promise((resolvePort, reject) => {
28
+ const server = createServer();
29
+ server.once("error", reject);
30
+ server.listen(0, "127.0.0.1", () => {
31
+ const address = server.address();
32
+ if (address === null || typeof address === "string") {
33
+ server.close();
34
+ reject(new Error("Could not allocate a test port"));
35
+ return;
36
+ }
37
+ server.close((cause) => cause ? reject(cause) : resolvePort(address.port));
38
+ });
39
+ });
40
+
41
+ const transport = new StdioClientTransport({
42
+ command: process.execPath,
43
+ args: [entrypoint, "--port", String(port)],
44
+ cwd: root,
45
+ stderr: "pipe",
46
+ });
47
+ const client = new Client({ name: "server-metadata-test", version: "1.0.0" });
48
+
49
+ try {
50
+ await client.connect(transport);
51
+ assert.equal(
52
+ client.getServerVersion()?.version,
53
+ packageVersion,
54
+ "MCP server version must match package.json",
55
+ );
56
+ } finally {
57
+ await client.close();
58
+ }
59
+
60
+ process.stdout.write("server metadata: ok\n");