@casys/mcp-server 0.17.1 → 0.17.2
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 +16 -7
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") {
|