Track MCP LogoTrack MCP
Track MCP LogoTrack MCP

The world's largest repository of Model Context Protocol servers. Discover, explore, and submit MCP tools.

Product

  • Categories
  • Top MCP
  • New & Updated
  • Submit MCP

Company

  • About

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy

© 2026 TrackMCP. All rights reserved.

Built with ❤️ by Krishna Goyal

    Mcp Server 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.

    4 stars
    TypeScript
    Updated Jul 11, 2025

    Table of Contents

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

    Table of Contents

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

    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](https://modelcontextprotocol.github.io/inspector)

    📂 Project Structure

    code
    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

    bash
    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

    bash
    npm install

    3. Create .env file

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

    4. Run the server

    bash
    npm run dev

    ✅ Server will run on:

    code
    http://localhost:3001/sse

    🧪 Testing the server with MCP Inspector

    Step 1 — Install MCP Inspector

    📖 Official Docs: MCP Inspector

    bash
    npx @modelcontextprotocol/inspector

    Step 2 — Generate a token

    Use cURL to get your JWT token:

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

    ✅ Example response:

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

    Step 3 — Connect MCP Inspector

    1. Open Inspector UI

    2. Set Transport Type: SSE

    3. URL:

    code
    http://localhost:3001/sse

    4. Add Authorization Header:

    code
    Authorization: Bearer

    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

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

    🔌 SSE Endpoint (requires token)

    code
    GET /sse
    Authorization: Bearer

    📩 Send Message to active session

    code
    POST /message?sessionId=
    Authorization: Bearer

    🧩 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.

    Similar MCP

    Based on tags & features

    • GL

      Glm Mcp Server

      TypeScript·
      3
    • NS

      Ns Private Access Mcp

      TypeScript·
      3
    • MC

      Mcp Server Aws Sso

      TypeScript·
      6
    • MC

      Mcp Wave

      TypeScript00

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k
    View All MCP Servers

    Similar MCP

    Based on tags & features

    • GL

      Glm Mcp Server

      TypeScript·
      3
    • NS

      Ns Private Access Mcp

      TypeScript·
      3
    • MC

      Mcp Server Aws Sso

      TypeScript·
      6
    • MC

      Mcp Wave

      TypeScript00

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k