@casys/mcp-server 0.17.1 → 0.17.3
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/package.json +1 -1
- package/src/mcp-app.ts +18 -8
- package/src/ui/viewer-utils.ts +16 -0
package/package.json
CHANGED
package/src/mcp-app.ts
CHANGED
|
@@ -1433,8 +1433,17 @@ export class McpApp {
|
|
|
1433
1433
|
const { id, method, params } = body;
|
|
1434
1434
|
requestId = id ?? null;
|
|
1435
1435
|
|
|
1436
|
-
//
|
|
1437
|
-
//
|
|
1436
|
+
// Auth gate: when requireAuth is configured, ALL requests (including
|
|
1437
|
+
// initialize) must be authenticated per MCP spec 2025-06-18. The 401
|
|
1438
|
+
// response with WWW-Authenticate triggers OAuth discovery in MCP
|
|
1439
|
+
// clients (Claude.ai, Cursor). Without this, clients receive a 200 on
|
|
1440
|
+
// initialize and never attempt the OAuth/DCR flow.
|
|
1441
|
+
if (this.authProvider) {
|
|
1442
|
+
const authDenied = await verifyHttpAuth(c.req.raw);
|
|
1443
|
+
if (authDenied) return authDenied;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// Initialize - create session and return session ID (now auth-verified)
|
|
1438
1447
|
if (method === "initialize") {
|
|
1439
1448
|
// Per-IP rate limit on initialize to prevent session exhaustion attacks
|
|
1440
1449
|
const clientIp = getClientIpFromHeaders(c.req.raw.headers);
|
|
@@ -1472,7 +1481,7 @@ export class McpApp {
|
|
|
1472
1481
|
jsonrpc: "2.0",
|
|
1473
1482
|
id,
|
|
1474
1483
|
result: {
|
|
1475
|
-
protocolVersion: "2025-
|
|
1484
|
+
protocolVersion: "2025-06-18",
|
|
1476
1485
|
capabilities: {
|
|
1477
1486
|
tools: {},
|
|
1478
1487
|
resources: this.resources.size > 0 ? {} : undefined,
|
|
@@ -1576,10 +1585,10 @@ export class McpApp {
|
|
|
1576
1585
|
}
|
|
1577
1586
|
}
|
|
1578
1587
|
|
|
1579
|
-
// Auth gate
|
|
1580
|
-
//
|
|
1581
|
-
|
|
1582
|
-
|
|
1588
|
+
// Auth gate already applied above (covers all methods including tools/call, tools/list, etc.)
|
|
1589
|
+
// Note: tools/call also runs auth again in the middleware pipeline (createAuthMiddleware),
|
|
1590
|
+
// which provides per-tool scope enforcement. The top-level check above is the gate
|
|
1591
|
+
// that triggers OAuth discovery (401 with WWW-Authenticate).
|
|
1583
1592
|
|
|
1584
1593
|
// Tools list
|
|
1585
1594
|
if (method === "tools/list") {
|
|
@@ -2288,7 +2297,8 @@ export interface RegisterViewersConfig {
|
|
|
2288
2297
|
prefix: string;
|
|
2289
2298
|
/** import.meta.url of the consumer's server.ts (for resolving dist paths) */
|
|
2290
2299
|
moduleUrl: string;
|
|
2291
|
-
/** Check if a filesystem path
|
|
2300
|
+
/** Check if a path or URL exists. Receives a filesystem path for local
|
|
2301
|
+
* modules (file://) or an HTTPS URL for remote modules (JSR, CDN). */
|
|
2292
2302
|
exists: (path: string) => boolean;
|
|
2293
2303
|
/** Read a file and return its content as string */
|
|
2294
2304
|
readFile: (path: string) => string | Promise<string>;
|
package/src/ui/viewer-utils.ts
CHANGED
|
@@ -46,6 +46,22 @@ export function resolveViewerDistPath(
|
|
|
46
46
|
viewerName: string,
|
|
47
47
|
exists: (path: string) => boolean,
|
|
48
48
|
): string | null {
|
|
49
|
+
// When consumed from JSR or any remote registry, import.meta.url is an
|
|
50
|
+
// HTTPS URL. fileUrlToPath() only handles file:// — passing an HTTPS URL
|
|
51
|
+
// produces a broken UNC-like path ("//jsr.io/..."). Return the raw resolved
|
|
52
|
+
// URL string instead; the caller's exists/readFile callbacks are responsible
|
|
53
|
+
// for handling remote URLs (e.g., via fetch()).
|
|
54
|
+
if (moduleUrl.startsWith("https://") || moduleUrl.startsWith("http://")) {
|
|
55
|
+
const candidates = [
|
|
56
|
+
new URL(`./src/ui/dist/${viewerName}/index.html`, moduleUrl).href,
|
|
57
|
+
new URL(`./ui-dist/${viewerName}/index.html`, moduleUrl).href,
|
|
58
|
+
];
|
|
59
|
+
for (const candidate of candidates) {
|
|
60
|
+
if (exists(candidate)) return candidate;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
49
65
|
const candidates = [
|
|
50
66
|
fileUrlToPath(new URL(`./src/ui/dist/${viewerName}/index.html`, moduleUrl)),
|
|
51
67
|
fileUrlToPath(new URL(`./ui-dist/${viewerName}/index.html`, moduleUrl)),
|