Analytics · MODEL CONTEXT PROTOCOL
anisirji 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.
连接能力
anisirji mcp server remote setup with jwt auth 为 AI Agent 提供什么
来源目录未提供结构化功能列表,请在使用前阅读源仓库文档。
安全
MCP 收录不等于安全审核
MCP 服务器可能获得模型上下文、凭据、本地文件或调用外部系统的权限。连接 Agent 前,请检查代码、环境变量、网络行为、软件包来源与维护状态。
README
仓库文档
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
server/
├── index.ts # Main Express + MCP server
├── .env # Environment variables
├── package.json # Project metadata & scripts
├── tsconfig.json # TypeScript config
└── README.md # You are here!
- ✅ 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
git clone https://github.com/anisirji/mcp-server-remote-setup-with-jwt-auth.git
cd mcp-server-remote-setup-with-jwt-authnpm installecho "JWT_SECRET=your-secret-key" > .envnpm run dev✅ Server will run on:
http://localhost:3001/sse
📖 Official Docs: MCP Inspector
npx @modelcontextprotocol/inspectorUse cURL to get your JWT token:
curl "http://localhost:3001/auth/token?username=aniket&scope=mcp:access"✅ Example response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}- Open Inspector UI
- Set Transport Type: SSE
- URL:
http://localhost:3001/sse - Add Authorization Header:
Authorization: Bearer <your-token> - Click Connect
🎉 Success! Your server is now connected.
Go to Tools tab in Inspector and click List Tools.
You will see:
- ✅
test - ✅
echo - ✅
get-time - ✅
random-number
Test them and enjoy!
GET /auth/token?username=<username>&scope=mcp:access
GET /sse
Authorization: Bearer <token>
POST /message?sessionId=<sessionId>
Authorization: Bearer <token>
| 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) |
- Token revocation list (blacklist)
- Role-based tool access (scope checks)
- Session heartbeat / keep-alive
- Rate limiting & logging
- Dockerization for deployment
Aniket
This project is open-source and free to use.
社区