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

๐ 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-auth2. Install dependencies
npm install3. Create `.env` file
echo "JWT_SECRET=your-secret-key" > .env4. 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/inspectorStep 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/sse4. Add Authorization Header:
Authorization: Bearer5. 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=&scope=mcp:access๐ SSE Endpoint (requires token)
GET /sse
Authorization: Bearer๐ฉ Send Message to active session
POST /message?sessionId=
Authorization: Bearer๐งฉ Tools Reference
| Tool Name | Description |
|---|---|
| `test` | Test connection (security check) |
| `echo` | Echo back provided message |
| `get-time` | Returns current server time |
| `random-number` | Returns 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.
Frequently asked questions
What is mcp-server-remote-setup-with-jwt-auth?
mcp-server-remote-setup-with-jwt-auth is 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.
How do I install mcp-server-remote-setup-with-jwt-auth?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-server-remote-setup-with-jwt-auth open source?
Yes โ it is hosted on GitHub at https://github.com/anisirji/mcp-server-remote-setup-with-jwt-auth and has 4 stars.
Related MCP tools
๐ Cherry Studio is a desktop client that supports for multiple LLM providers. Built for the Model Context Protocol to enhance AI capabilities.
Enhanced ChatGPT Clone: Features Agents, MCP, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini...
FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, ...
Composio equips your AI agents & LLMs with 100+ high-quality integrations via function calling for the Model Context Protocol. Enhance AI assistants with powerf
๐ฆ Repomix is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Lan...
AI Agents & MCPs & AI Workflow Automation โข (~400 MCP servers for AI agents) โข AI Automation / AI Agent with MCPs โข AI Workflows & AI Agents โข MCPs for AI Ag...
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP