SSE MCP Server with JWT Authentication logo

SSE MCP Server with JWT Authentication

by anisirji

This is a Model Context Protocol (MCP) SSE server with JWT-based authentication. It allows you to expose multiple AI tools over an SSE transport, protected via secure Bearer Token flow.

View on GitHub

Last updated: N/A

What is SSE MCP Server with JWT Authentication?

This is a Node.js server that implements the Model Context Protocol (MCP) over Server-Sent Events (SSE) with JSON Web Token (JWT) authentication. It provides a secure way to expose AI tools and manage sessions.

How to use SSE MCP Server with JWT Authentication?

  1. Clone the repository. 2. Install dependencies using npm install. 3. Create a .env file with a JWT_SECRET. 4. Run the server using npm run dev. 5. Generate a JWT token using the /auth/token endpoint. 6. Connect to the /sse endpoint with the Authorization header set to Bearer <token>. 7. Test the tools using MCP Inspector or by sending messages to the /message endpoint.

Key features of SSE MCP Server with JWT Authentication

  • Secure SSE connection using Bearer JWT token

  • Dynamic Tool registration

  • Tested with MCP Inspector

  • Logs all request lifecycle events

  • Session management for /message endpoint

  • Ready to extend for production use

Use cases of SSE MCP Server with JWT Authentication

  • Exposing AI models and tools securely over a network.

  • Building AI-powered applications that require authentication and authorization.

  • Creating a centralized server for managing and accessing multiple AI services.

  • Integrating AI tools into existing systems using a standardized protocol.

FAQ from SSE MCP Server with JWT Authentication

What is MCP?

MCP stands for Model Context Protocol. It is a protocol for interacting with AI models and tools.

What is SSE?

SSE stands for Server-Sent Events. It is a unidirectional communication protocol that allows a server to push data to a client over HTTP.

What is JWT?

JWT stands for JSON Web Token. It is a standard for securely transmitting information between parties as a JSON object.

How do I generate a JWT token?

You can generate a JWT token by sending a GET request to the /auth/token endpoint with a username and scope.

How do I connect to the SSE endpoint?

You can connect to the SSE endpoint by sending a GET request to /sse with the Authorization header set to Bearer <token>.