Skip to content

Commit f6951f4

Browse files
authored
Making the MCP server handler conditional based on whether tool registration is provided (#100)
* making the MCP server handler conditional based on whether tool registration is provided * lint
1 parent 4f7202d commit f6951f4

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/router.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,23 @@ export function descopeMcpAuthRouter(
4444
protectedResourceHandler(authProvider),
4545
);
4646

47-
// MCP server endpoint - always enabled with authentication
48-
router.post(
49-
"/mcp",
50-
descopeMcpBearerAuth(authProvider),
51-
createMcpServerHandler(
52-
{
53-
name: "descope-mcp-server",
54-
version: "1.0.0",
55-
},
56-
toolRegistration,
57-
authProvider.options,
58-
),
59-
);
47+
// MCP server endpoint - bearer auth always enabled, server handler only when tools are registered
48+
if (toolRegistration) {
49+
router.post(
50+
"/mcp",
51+
descopeMcpBearerAuth(authProvider),
52+
createMcpServerHandler(
53+
{
54+
name: "descope-mcp-server",
55+
version: "1.0.0",
56+
},
57+
toolRegistration,
58+
authProvider.options,
59+
),
60+
);
61+
} else {
62+
router.use("/mcp", descopeMcpBearerAuth(authProvider));
63+
}
6064

6165
// Authorization Server endpoints are disabled by default
6266
// Enable them only if explicitly configured

0 commit comments

Comments
 (0)