@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.
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +10 -627
- package/esm/mod.d.ts +1 -0
- package/esm/mod.js +1 -0
- package/package.json +28 -25
- package/mod.ts +0 -302
- package/src/auth/as-metadata-proxy.ts +0 -288
- package/src/auth/config.ts +0 -368
- package/src/auth/jwt-provider.ts +0 -327
- package/src/auth/middleware.ts +0 -257
- package/src/auth/mod.ts +0 -89
- package/src/auth/multi-tenant-middleware.ts +0 -236
- package/src/auth/presets.ts +0 -351
- package/src/auth/provider.ts +0 -49
- package/src/auth/scope-middleware.ts +0 -59
- package/src/auth/static-token-provider.ts +0 -197
- package/src/auth/types.ts +0 -207
- package/src/client-auth/callback-server.ts +0 -166
- package/src/client-auth/client-id-metadata.ts +0 -260
- package/src/client-auth/connect.ts +0 -72
- package/src/client-auth/mod.ts +0 -44
- package/src/client-auth/provider.ts +0 -300
- package/src/client-auth/token-store/file-store.ts +0 -73
- package/src/client-auth/token-store/memory-store.ts +0 -32
- package/src/client-auth/types.ts +0 -95
- package/src/concurrency/rate-limiter.ts +0 -190
- package/src/concurrency/request-queue.ts +0 -140
- package/src/http/body.ts +0 -72
- package/src/http/request-guards.ts +0 -137
- package/src/http/wire.ts +0 -41
- package/src/inspector/launcher.ts +0 -131
- package/src/mcp-app.ts +0 -4595
- package/src/middleware/backpressure.ts +0 -36
- package/src/middleware/mod.ts +0 -21
- package/src/middleware/rate-limit.ts +0 -45
- package/src/middleware/runner.ts +0 -63
- package/src/middleware/types.ts +0 -104
- package/src/middleware/validation.ts +0 -28
- package/src/mrtr/capability-check.ts +0 -303
- package/src/mrtr/mod.ts +0 -54
- package/src/mrtr/replay-store.ts +0 -103
- package/src/mrtr/request-state.ts +0 -435
- package/src/mrtr/retry-guard.ts +0 -110
- package/src/mrtr/types.ts +0 -107
- package/src/observability/metrics.ts +0 -336
- package/src/observability/mod.ts +0 -21
- package/src/observability/otel.ts +0 -330
- package/src/runtime/runtime.deno.ts +0 -149
- package/src/runtime/runtime.node.ts +0 -324
- package/src/runtime/runtime.ts +0 -50
- package/src/runtime/types.ts +0 -130
- package/src/security/channel-hmac.ts +0 -140
- package/src/security/csp.ts +0 -89
- package/src/security/message-signer.ts +0 -223
- package/src/subscriptions/subscription-registry.ts +0 -558
- package/src/tasks/mod.ts +0 -33
- package/src/tasks/task-store.ts +0 -1014
- package/src/transport/request-headers.ts +0 -661
- package/src/types.ts +0 -908
- package/src/ui/viewer-utils.ts +0 -117
- 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
|
-
}
|