mcp-ts-template 1.5.4 → 1.5.5
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/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.typescriptlang.org/)
|
|
4
4
|
[](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
5
5
|
[](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/changelog.mdx)
|
|
6
|
-
[](./CHANGELOG.md)
|
|
7
7
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
8
|
[](https://github.com/cyanheads/mcp-ts-template/issues)
|
|
9
9
|
[](https://github.com/cyanheads/mcp-ts-template)
|
|
@@ -22,12 +22,14 @@ import { logger, requestContextService } from "../../../../../utils/index.js";
|
|
|
22
22
|
import { BaseErrorCode, McpError } from "../../../../../types-global/errors.js";
|
|
23
23
|
import { authContext } from "../../core/authContext.js";
|
|
24
24
|
// Startup Validation: Validate secret key presence on module load.
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
if (config.mcpAuthMode === "jwt") {
|
|
26
|
+
if (environment === "production" && !config.mcpAuthSecretKey) {
|
|
27
|
+
logger.fatal("CRITICAL: MCP_AUTH_SECRET_KEY is not set in production environment for JWT auth. Authentication cannot proceed securely.");
|
|
28
|
+
throw new Error("MCP_AUTH_SECRET_KEY must be set in production environment for JWT authentication.");
|
|
29
|
+
}
|
|
30
|
+
else if (!config.mcpAuthSecretKey) {
|
|
31
|
+
logger.warning("MCP_AUTH_SECRET_KEY is not set. JWT auth middleware will bypass checks (DEVELOPMENT ONLY). This is insecure for production.");
|
|
32
|
+
}
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Hono middleware for verifying JWT Bearer token authentication.
|
|
@@ -41,6 +43,10 @@ export async function mcpAuthMiddleware(c, next) {
|
|
|
41
43
|
});
|
|
42
44
|
logger.debug("Running MCP Authentication Middleware (Bearer Token Validation)...", context);
|
|
43
45
|
const reqWithAuth = c.env.incoming;
|
|
46
|
+
// If JWT auth is not enabled, skip the middleware.
|
|
47
|
+
if (config.mcpAuthMode !== "jwt") {
|
|
48
|
+
return await next();
|
|
49
|
+
}
|
|
44
50
|
// Development Mode Bypass
|
|
45
51
|
if (!config.mcpAuthSecretKey) {
|
|
46
52
|
if (environment !== "production") {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
11
11
|
import { config } from "../../../../../config/index.js";
|
|
12
12
|
import { BaseErrorCode, McpError } from "../../../../../types-global/errors.js";
|
|
13
|
-
import { ErrorHandler } from "../../../../../utils/internal/errorHandler.js";
|
|
14
13
|
import { logger, requestContextService } from "../../../../../utils/index.js";
|
|
14
|
+
import { ErrorHandler } from "../../../../../utils/internal/errorHandler.js";
|
|
15
15
|
import { authContext } from "../../core/authContext.js";
|
|
16
16
|
// --- Startup Validation ---
|
|
17
17
|
// Ensures that necessary OAuth configuration is present when the mode is 'oauth'.
|
|
@@ -57,6 +57,10 @@ if (config.mcpAuthMode === "oauth" && config.oauthIssuerUrl) {
|
|
|
57
57
|
* @param next - The function to call to proceed to the next middleware.
|
|
58
58
|
*/
|
|
59
59
|
export async function oauthMiddleware(c, next) {
|
|
60
|
+
// If OAuth is not the configured auth mode, skip this middleware.
|
|
61
|
+
if (config.mcpAuthMode !== "oauth") {
|
|
62
|
+
return await next();
|
|
63
|
+
}
|
|
60
64
|
const context = requestContextService.createRequestContext({
|
|
61
65
|
operation: "oauthMiddleware",
|
|
62
66
|
httpMethod: c.req.method,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ts-template",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.5.5",
|
|
4
|
+
"description": "Jumpstart Model Context Protocol (MCP) development with this production-ready TypeScript template. Build robust MCP servers and clients with built-in utilities, authentication, and service integrations.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|