atlas-mcp-server
Version:
ATLAS (Adaptive Task & Logic Automation System): An MCP server enabling LLM agents to manage projects, tasks, and knowledge via a Neo4j-backed, three-tier architecture. Facilitates complex workflow automation and project management through LLM Agents.
30 lines (29 loc) • 1.43 kB
TypeScript
/**
* @fileoverview MCP Authentication Middleware for Bearer Token Validation (JWT).
*
* This middleware validates JSON Web Tokens (JWT) passed via the 'Authorization' header
* using the 'Bearer' scheme (e.g., "Authorization: Bearer <your_token>").
* It verifies the token's signature and expiration using the secret key defined
* in the configuration (`config.mcpAuthSecretKey`).
*
* If the token is valid, an object conforming to the MCP SDK's `AuthInfo` type
* (expected to contain `token`, `clientId`, and `scopes`) is attached to `req.auth`.
* If the token is missing, invalid, or expired, it sends an HTTP 401 Unauthorized response.
*
* @see {@link https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/basic/authorization.mdx | MCP Authorization Specification}
* @module src/mcp-server/transports/authentication/authMiddleware
*/
import { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
import { NextFunction, Request, Response } from "express";
declare global {
namespace Express {
interface Request {
/** Authentication information derived from the JWT, conforming to MCP SDK's AuthInfo. */
auth?: AuthInfo;
}
}
}
/**
* Express middleware for verifying JWT Bearer token authentication.
*/
export declare function mcpAuthMiddleware(req: Request, res: Response, next: NextFunction): void;