Get the FREE Ultimate OpenClaw Setup Guide →

mcp -remote-setup-with-jwt-auth

Secure middleware server implementing Model Context Protocol (MCP) over SSE with JWT authentication. Enables standardized communication between AI tools and clients with dynamic tool registration, request logging, and session management. Perfect for building production-ready AI systems requiring secure access patterns.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio anisirji-mcp-server-remote-setup-with-jwt-auth node server/index.js \
  --env JWT_SECRET="your-secret-key"

How to use

This MCP server exposes several AI tools over a secure Server-Sent Events (SSE) channel, protected by JWT Bearer authentication. Clients first obtain a JWT by calling the token endpoint, then connect to the SSE stream at /sse using the Authorization header with Bearer <token>. Once connected, you can dynamically interact with registered tools such as test, echo, get-time, and random-number through the MCP Inspector or any compatible client. The server supports session management for /message interactions, allowing you to send messages to the active session and receive structured tool results in real time over SSE. In short, you get a JWT-protected gateway that exposes a small suite of utility tools suitable for remote tool orchestration and testing, with lifecycle events logged for observability.

How to install

Prerequisites:

  • Node.js (LTS version) and npm installed on your system
  • Git installed
  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
  1. Install dependencies
npm install
  1. Create a .env file with a JWT secret
echo "JWT_SECRET=your-secret-key" > .env
  1. Start the server (development mode)
npm run dev
  1. Server will run on port 3001 by default, with the SSE endpoint at http://localhost:3001/sse and the auth token endpoint at http://localhost:3001/auth/token?username=<user>&scope=mcp:access

Additional notes

Tips and caveats:

  • Ensure JWT_SECRET in .env is kept secure and not checked into version control.
  • The server exposes tools like test, echo, get-time, and random-number. The Inspector can list and invoke these tools once connected.
  • If you change the port or host, update the client configuration accordingly (SSE URL and token endpoint).
  • Token retrieval uses the /auth/token endpoint; include username and scope=mcp:access in the query parameters.
  • The environment variable JWT_SECRET is required for token creation and validation.
  • For production deployment, consider TLS termination and configuring a reverse proxy in front of the Node server.

Related MCP Servers

Sponsor this space

Reach thousands of developers