SSE MCP Server with JWT Authentication

Integrations

  • Manages environment variables for server configuration, including JWT secrets.

  • Serves as the web framework for the MCP server, handling HTTP requests and SSE connections for AI tool communication.

  • Used for version control and project setup via cloning.

🔐 SSE MCP Server with JWT Authentication

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.

Built with:

  • 🚀 Node.js + Express
  • 🧩 @modelcontextprotocol/sdk
  • 🔒 JSON Web Tokens (JWT) for authentication
  • ⚙️ Zod for input validation

✅ Fully tested with @modelcontextprotocol/inspector

📂 Project Structure

server/ ├── index.ts # Main Express + MCP server ├── .env # Environment variables ├── package.json # Project metadata & scripts ├── tsconfig.json # TypeScript config └── README.md # You are here!

✨ Features

  • ✅ Secure SSE connection using Bearer JWT token
  • ✅ Dynamic Tool registration (echo, time, random number, etc.)
  • ✅ Tested with MCP Inspector
  • ✅ Logs all request lifecycle events
  • ✅ Session management for /message endpoint
  • 🚀 Ready to extend for production use

⚙️ Setup

1. Clone the repository

git clone https://github.com/anisirji/mcp-server-remote-setup-with-jwt-auth.git cd mcp-server-remote-setup-with-jwt-auth

2. Install dependencies

npm install

3. Create .env file

echo "JWT_SECRET=your-secret-key" > .env

4. Run the server

npm run dev

✅ Server will run on:

http://localhost:3001/sse

🧪 Testing the server with MCP Inspector

Step 1 — Install MCP Inspector

📖 Official Docs: MCP Inspector

npx @modelcontextprotocol/inspector

Step 2 — Generate a token

Use cURL to get your JWT token:

curl "http://localhost:3001/auth/token?username=aniket&scope=mcp:access"

✅ Example response:

{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }

Step 3 — Connect MCP Inspector

  1. Open Inspector UI
  2. Set Transport Type: SSE
  3. URL:
    http://localhost:3001/sse
  4. Add Authorization Header:
    Authorization: Bearer <your-token>
  5. Click Connect

🎉 Success! Your server is now connected.

Step 4 — Test tools

Go to Tools tab in Inspector and click List Tools.

You will see:

  • test
  • echo
  • get-time
  • random-number

Test them and enjoy!

📖 API Reference

🔑 Generate Token

GET /auth/token?username=<username>&scope=mcp:access

🔌 SSE Endpoint (requires token)

GET /sse Authorization: Bearer <token>

📩 Send Message to active session

POST /message?sessionId=<sessionId> Authorization: Bearer <token>

🧩 Tools Reference

Tool NameDescription
testTest connection (security check)
echoEcho back provided message
get-timeReturns current server time
random-numberReturns random number (min/max)

🗓️ Upcoming Changes

  • Token revocation list (blacklist)
  • Role-based tool access (scope checks)
  • Session heartbeat / keep-alive
  • Rate limiting & logging
  • Dockerization for deployment

📚 Useful Resources

👨‍💻 Maintainer

Aniket

📄 License

This project is open-source and free to use.

🚀 Build. Secure. Empower.

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A Model Context Protocol server that exposes multiple AI tools over SSE transport with JWT-based secure authentication, allowing for dynamic tool registration and session management.

  1. 📂 Project Structure
    1. ✨ Features
      1. ⚙️ Setup
        1. 1. Clone the repository
        2. 2. Install dependencies
        3. 3. Create .env file
        4. 4. Run the server
      2. 🧪 Testing the server with MCP Inspector
        1. Step 1 — Install MCP Inspector
        2. Step 2 — Generate a token
        3. Step 3 — Connect MCP Inspector
        4. Step 4 — Test tools
      3. 📖 API Reference
        1. 🔑 Generate Token
        2. 🔌 SSE Endpoint (requires token)
        3. 📩 Send Message to active session
      4. 🧩 Tools Reference
        1. 🗓️ Upcoming Changes
          1. 📚 Useful Resources
            1. 👨‍💻 Maintainer
              1. 📄 License
                1. 🚀 Build. Secure. Empower.

                  Related MCP Servers

                  • A
                    security
                    F
                    license
                    A
                    quality
                    A Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.
                    Last updated -
                    1
                    3
                    18
                    JavaScript
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A Model Context Protocol server that enables seamless execution of commands, Python code, web content fetching, and reusable task management with secure credentials handling.
                    Last updated -
                    2
                    Python
                    MIT License
                    • Apple
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.
                    Last updated -
                    16
                    TypeScript
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A Model Context Protocol server that provides AI agents with secure access to local filesystem operations, enabling reading, writing, and managing files through a standardized interface.
                    Last updated -
                    14
                    1
                    TypeScript
                    Apache 2.0

                  View all related MCP servers

                  ID: miwcfrgnmg