@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/mcp-app.ts +16 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casys/mcp-server",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "Production-ready MCP server framework with concurrency control, auth, and observability",
5
5
  "type": "module",
6
6
  "main": "mod.ts",
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
- // Initialize - create session and return session ID
1437
- // Note: initialize is NOT auth-gated (client needs to discover capabilities first)
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-03-26",
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: all other methods after initialize require valid token (if auth configured)
1580
- // (tools/call is handled above via the middleware pipeline which includes auth)
1581
- const authDenied = await verifyHttpAuth(c.req.raw);
1582
- if (authDenied) return authDenied;
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") {