JUHE API Marketplace
anisirji avatar
MCP Server

SSE MCP Server with JWT Authentication

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.

4
GitHub Stars
11/17/2025
Last Updated
No Configuration
Please check the documentation below.
  1. Home
  2. MCP Servers
  3. mcp-server-remote-setup-with-jwt-auth

README Documentation

MseeP.ai Security Assessment Badge

๐Ÿ” 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

  • Model Context Protocol Introduction
  • MCP Inspector Docs
  • JWT.io Debugger
  • Zod Validation Docs

๐Ÿ‘จโ€๐Ÿ’ป Maintainer

Aniket

๐Ÿ“„ License

This project is open-source and free to use.

๐Ÿš€ Build. Secure. Empower.

Quick Actions

View on GitHubView All Servers

Key Features

Model Context Protocol
Secure Communication
Real-time Updates
Open Source

Boost your projects with Wisdom Gate LLM API

Supporting GPT-5, Claude-4, DeepSeek v3, Gemini and more.

Enjoy a free trial and save 20%+ compared to official pricing.

Learn More
JUHE API Marketplace

Accelerate development, innovate faster, and transform your business with our comprehensive API ecosystem.

JUHE API VS

  • vs. RapidAPI
  • vs. API Layer
  • API Platforms 2025
  • API Marketplaces 2025
  • Best Alternatives to RapidAPI

For Developers

  • Console
  • Collections
  • Documentation
  • MCP Servers
  • Free APIs
  • Temp Mail Demo

Product

  • Browse APIs
  • Suggest an API
  • Wisdom Gate LLM
  • Global SMS Messaging
  • Temp Mail API

Company

  • What's New
  • Welcome
  • About Us
  • Contact Support
  • Terms of Service
  • Privacy Policy
Featured on Startup FameFeatured on Twelve ToolsFazier badgeJuheAPI Marketplace - Connect smarter, beyond APIs | Product Huntai tools code.marketDang.ai
Copyright ยฉ 2025 - All rights reserved