@casys/mcp-server 0.26.1 → 0.27.1

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 (62) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +10 -627
  4. package/esm/mod.d.ts +1 -0
  5. package/esm/mod.js +1 -0
  6. package/package.json +28 -25
  7. package/mod.ts +0 -302
  8. package/src/auth/as-metadata-proxy.ts +0 -288
  9. package/src/auth/config.ts +0 -368
  10. package/src/auth/jwt-provider.ts +0 -327
  11. package/src/auth/middleware.ts +0 -257
  12. package/src/auth/mod.ts +0 -89
  13. package/src/auth/multi-tenant-middleware.ts +0 -236
  14. package/src/auth/presets.ts +0 -351
  15. package/src/auth/provider.ts +0 -49
  16. package/src/auth/scope-middleware.ts +0 -59
  17. package/src/auth/static-token-provider.ts +0 -197
  18. package/src/auth/types.ts +0 -207
  19. package/src/client-auth/callback-server.ts +0 -166
  20. package/src/client-auth/client-id-metadata.ts +0 -260
  21. package/src/client-auth/connect.ts +0 -72
  22. package/src/client-auth/mod.ts +0 -44
  23. package/src/client-auth/provider.ts +0 -300
  24. package/src/client-auth/token-store/file-store.ts +0 -73
  25. package/src/client-auth/token-store/memory-store.ts +0 -32
  26. package/src/client-auth/types.ts +0 -95
  27. package/src/concurrency/rate-limiter.ts +0 -190
  28. package/src/concurrency/request-queue.ts +0 -140
  29. package/src/http/body.ts +0 -72
  30. package/src/http/request-guards.ts +0 -137
  31. package/src/http/wire.ts +0 -41
  32. package/src/inspector/launcher.ts +0 -131
  33. package/src/mcp-app.ts +0 -4595
  34. package/src/middleware/backpressure.ts +0 -36
  35. package/src/middleware/mod.ts +0 -21
  36. package/src/middleware/rate-limit.ts +0 -45
  37. package/src/middleware/runner.ts +0 -63
  38. package/src/middleware/types.ts +0 -104
  39. package/src/middleware/validation.ts +0 -28
  40. package/src/mrtr/capability-check.ts +0 -303
  41. package/src/mrtr/mod.ts +0 -54
  42. package/src/mrtr/replay-store.ts +0 -103
  43. package/src/mrtr/request-state.ts +0 -435
  44. package/src/mrtr/retry-guard.ts +0 -110
  45. package/src/mrtr/types.ts +0 -107
  46. package/src/observability/metrics.ts +0 -336
  47. package/src/observability/mod.ts +0 -21
  48. package/src/observability/otel.ts +0 -330
  49. package/src/runtime/runtime.deno.ts +0 -149
  50. package/src/runtime/runtime.node.ts +0 -324
  51. package/src/runtime/runtime.ts +0 -50
  52. package/src/runtime/types.ts +0 -130
  53. package/src/security/channel-hmac.ts +0 -140
  54. package/src/security/csp.ts +0 -89
  55. package/src/security/message-signer.ts +0 -223
  56. package/src/subscriptions/subscription-registry.ts +0 -558
  57. package/src/tasks/mod.ts +0 -33
  58. package/src/tasks/task-store.ts +0 -1014
  59. package/src/transport/request-headers.ts +0 -661
  60. package/src/types.ts +0 -908
  61. package/src/ui/viewer-utils.ts +0 -117
  62. package/src/validation/schema-validator.ts +0 -307
@@ -1,131 +0,0 @@
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
- * Runtime-agnostic: process spawning goes through `node:` builtins, which
8
- * both Deno (via its Node compat layer) and Node.js support — one code path
9
- * instead of a per-runtime adapter. The `node:` modules are imported
10
- * dynamically inside the function bodies so nothing process-related enters
11
- * the module graph at load time (mod.ts re-exports this module, and its
12
- * import must stay side-effect free on constrained runtimes like
13
- * Deno Deploy).
14
- *
15
- * Usage from a server script:
16
- * ```typescript
17
- * import { launchInspector } from "@casys/mcp-server";
18
- *
19
- * if (Deno.args.includes("--inspect")) {
20
- * await launchInspector("deno", ["run", "--allow-all", "server.ts"]);
21
- * }
22
- * ```
23
- *
24
- * @module lib/server/inspector/launcher
25
- */
26
-
27
- /** Options for the MCP Inspector launcher. */
28
- export interface InspectorOptions {
29
- /** Port for the inspector web UI (default: 6274) */
30
- port?: number;
31
- /** Automatically open the browser (default: true) */
32
- open?: boolean;
33
- /** Environment variables to pass to the MCP server process */
34
- env?: Record<string, string>;
35
- }
36
-
37
- /**
38
- * Launch the MCP Inspector to debug a server.
39
- *
40
- * Spawns `npx @modelcontextprotocol/inspector` which:
41
- * 1. Starts a web UI on the given port (default 6274)
42
- * 2. Proxies stdio to the MCP server subprocess
43
- * 3. Allows interactive tool calls, resource browsing, etc.
44
- *
45
- * @param serverCommand - Command to start the MCP server (e.g. "deno", "node")
46
- * @param serverArgs - Arguments for the server command (e.g. ["run", "--allow-all", "server.ts"])
47
- * @param options - Inspector configuration
48
- */
49
- export async function launchInspector(
50
- serverCommand: string,
51
- serverArgs: string[],
52
- options?: InspectorOptions,
53
- ): Promise<void> {
54
- const { spawn } = await import("node:child_process");
55
- const { env, exit } = await import("node:process");
56
-
57
- const port = options?.port ?? 6274;
58
- const shouldOpen = options?.open ?? true;
59
-
60
- // Filter out --inspect from args to avoid recursion
61
- const filteredArgs = serverArgs.filter((a) => a !== "--inspect");
62
-
63
- const inspectorEnv: Record<string, string> = {
64
- ...options?.env,
65
- CLIENT_PORT: String(port),
66
- };
67
-
68
- console.error(
69
- `[mcp-inspector] Starting inspector on http://localhost:${port}`,
70
- );
71
- console.error(
72
- `[mcp-inspector] Server: ${serverCommand} ${filteredArgs.join(" ")}`,
73
- );
74
-
75
- // Use npx to run the inspector
76
- const child = spawn(
77
- "npx",
78
- [
79
- "-y",
80
- "@modelcontextprotocol/inspector",
81
- serverCommand,
82
- ...filteredArgs,
83
- ],
84
- {
85
- env: { ...env, ...inspectorEnv },
86
- stdio: "inherit",
87
- },
88
- );
89
-
90
- // Open browser after a short delay
91
- if (shouldOpen) {
92
- setTimeout(() => {
93
- openBrowser(`http://localhost:${port}`).catch(() => {
94
- // Ignore — user can open manually
95
- });
96
- }, 2000);
97
- }
98
-
99
- // Wait for the inspector process to exit
100
- const code = await new Promise<number>((resolve, reject) => {
101
- child.on("error", reject);
102
- child.on("exit", (exitCode) => resolve(exitCode ?? 1));
103
- });
104
- if (code !== 0) {
105
- console.error(`[mcp-inspector] Inspector exited with code ${code}`);
106
- exit(code);
107
- }
108
- }
109
-
110
- /**
111
- * Open a URL in the default browser (cross-platform).
112
- */
113
- async function openBrowser(url: string): Promise<void> {
114
- const { spawn } = await import("node:child_process");
115
- const { platform } = await import("node:process");
116
-
117
- let cmd: string[];
118
- if (platform === "darwin") {
119
- cmd = ["open", url];
120
- } else if (platform === "win32") {
121
- cmd = ["cmd", "/c", "start", url];
122
- } else {
123
- cmd = ["xdg-open", url];
124
- }
125
-
126
- const child = spawn(cmd[0], cmd.slice(1), { stdio: "ignore" });
127
- await new Promise<void>((resolve, reject) => {
128
- child.on("error", reject);
129
- child.on("exit", () => resolve());
130
- });
131
- }