@casys/mcp-server 0.9.1 → 0.10.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/mod.ts CHANGED
@@ -93,6 +93,19 @@ export {
93
93
  discoverViewers,
94
94
  } from "./src/ui/viewer-utils.js";
95
95
 
96
+ // MCP Compose — UI composition helpers (re-exported from @casys/mcp-compose)
97
+ export { composeEvents, COMPOSE_EVENT_METHOD, uiMeta } from "@casys/mcp-compose/sdk";
98
+ export type {
99
+ ComposeEventHandler,
100
+ ComposeEventPayload,
101
+ ComposeEvents,
102
+ ComposeSource,
103
+ ComposeTarget,
104
+ UiMetaOptions,
105
+ UiMetaResult,
106
+ UiMetaUi,
107
+ } from "@casys/mcp-compose/sdk";
108
+
96
109
  // Middleware pipeline
97
110
  export type {
98
111
  Middleware,
@@ -167,3 +180,7 @@ export type {
167
180
  ServeHandle,
168
181
  ServeOptions,
169
182
  } from "./src/runtime/types.js";
183
+
184
+ // Inspector — launch the MCP Inspector for interactive debugging
185
+ export { launchInspector } from "./src/inspector/launcher.js";
186
+ export type { InspectorOptions } from "./src/inspector/launcher.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casys/mcp-server",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "Production-ready MCP server framework with concurrency control, auth, and observability",
5
5
  "type": "module",
6
6
  "main": "mod.ts",
@@ -0,0 +1,119 @@
1
+ /**
2
+ * MCP Inspector Launcher
3
+ *
4
+ * Launches the official @modelcontextprotocol/inspector to debug
5
+ * and test MCP servers interactively in a browser.
6
+ *
7
+ * Usage from a server script:
8
+ * ```typescript
9
+ * import { launchInspector } from "@casys/mcp-server";
10
+ *
11
+ * if (Deno.args.includes("--inspect")) {
12
+ * await launchInspector("deno", ["run", "--allow-all", "server.ts"]);
13
+ * }
14
+ * ```
15
+ *
16
+ * @module lib/server/inspector/launcher
17
+ */
18
+
19
+ /** Options for the MCP Inspector launcher. */
20
+ export interface InspectorOptions {
21
+ /** Port for the inspector web UI (default: 6274) */
22
+ port?: number;
23
+ /** Automatically open the browser (default: true) */
24
+ open?: boolean;
25
+ /** Environment variables to pass to the MCP server process */
26
+ env?: Record<string, string>;
27
+ }
28
+
29
+ /**
30
+ * Launch the MCP Inspector to debug a server.
31
+ *
32
+ * Spawns `npx @modelcontextprotocol/inspector` which:
33
+ * 1. Starts a web UI on the given port (default 6274)
34
+ * 2. Proxies stdio to the MCP server subprocess
35
+ * 3. Allows interactive tool calls, resource browsing, etc.
36
+ *
37
+ * @param serverCommand - Command to start the MCP server (e.g. "deno", "node")
38
+ * @param serverArgs - Arguments for the server command (e.g. ["run", "--allow-all", "server.ts"])
39
+ * @param options - Inspector configuration
40
+ */
41
+ export async function launchInspector(
42
+ serverCommand: string,
43
+ serverArgs: string[],
44
+ options?: InspectorOptions,
45
+ ): Promise<void> {
46
+ const port = options?.port ?? 6274;
47
+ const shouldOpen = options?.open ?? true;
48
+
49
+ // Filter out --inspect from args to avoid recursion
50
+ const filteredArgs = serverArgs.filter((a) => a !== "--inspect");
51
+
52
+ const inspectorEnv: Record<string, string> = {
53
+ ...options?.env,
54
+ CLIENT_PORT: String(port),
55
+ };
56
+
57
+ console.error(`[mcp-inspector] Starting inspector on http://localhost:${port}`);
58
+ console.error(`[mcp-inspector] Server: ${serverCommand} ${filteredArgs.join(" ")}`);
59
+
60
+ // Use npx to run the inspector
61
+ const command = new Deno.Command("npx", {
62
+ args: [
63
+ "-y",
64
+ "@modelcontextprotocol/inspector",
65
+ serverCommand,
66
+ ...filteredArgs,
67
+ ],
68
+ env: {
69
+ ...Deno.env.toObject(),
70
+ ...inspectorEnv,
71
+ },
72
+ stdin: "inherit",
73
+ stdout: "inherit",
74
+ stderr: "inherit",
75
+ });
76
+
77
+ const process = command.spawn();
78
+
79
+ // Open browser after a short delay
80
+ if (shouldOpen) {
81
+ setTimeout(() => {
82
+ openBrowser(`http://localhost:${port}`).catch(() => {
83
+ // Ignore — user can open manually
84
+ });
85
+ }, 2000);
86
+ }
87
+
88
+ // Wait for the inspector process to exit
89
+ const status = await process.status;
90
+ if (!status.success) {
91
+ console.error(`[mcp-inspector] Inspector exited with code ${status.code}`);
92
+ Deno.exit(status.code);
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Open a URL in the default browser (cross-platform).
98
+ */
99
+ async function openBrowser(url: string): Promise<void> {
100
+ const os = Deno.build.os;
101
+ let cmd: string[];
102
+
103
+ if (os === "darwin") {
104
+ cmd = ["open", url];
105
+ } else if (os === "windows") {
106
+ cmd = ["cmd", "/c", "start", url];
107
+ } else {
108
+ cmd = ["xdg-open", url];
109
+ }
110
+
111
+ const process = new Deno.Command(cmd[0], {
112
+ args: cmd.slice(1),
113
+ stdin: "null",
114
+ stdout: "null",
115
+ stderr: "null",
116
+ });
117
+
118
+ await process.spawn().status;
119
+ }