SSE MCP Server with JWT Authentication
🔐 带有 JWT 身份验证的 SSE MCP 服务器
这是一个基于 JWT 身份验证的模型上下文协议 (MCP) SSE 服务器。
它允许您通过 SSE 传输公开多个 AI 工具,并通过安全的 Bearer Token 流进行保护。
内置:
🚀 Node.js + Express
🧩@modelcontextprotocol/sdk
🔒 JSON Web Tokens(JWT)用于身份验证
⚙️ Zod 用于输入验证
✅ 已通过
@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!Related MCP server: MCP Boilerplate
✨ 特点
✅ 使用 Bearer JWT 令牌保护 SSE 连接
✅ 动态工具注册(回声、时间、随机数等)
✅ 经过 MCP Inspector 测试
✅ 记录所有请求生命周期事件
✅ /message 端点的会话管理
🚀 准备扩展用于生产用途
⚙️ 设置
1. 克隆存储库
git clone https://github.com/anisirji/mcp-server-remote-setup-with-jwt-auth.git
cd mcp-server-remote-setup-with-jwt-auth2.安装依赖项
npm install3.创建.env文件
echo "JWT_SECRET=your-secret-key" > .env4.运行服务器
npm run dev✅ 服务器将运行于:
http://localhost:3001/sse🧪 使用 MCP Inspector 测试服务器
步骤 1 — 安装 MCP Inspector
📖 官方文档: MCP Inspector
npx @modelcontextprotocol/inspector步骤 2 — 生成令牌
使用 cURL 获取您的 JWT 令牌:
curl "http://localhost:3001/auth/token?username=aniket&scope=mcp:access"✅ 示例响应:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}步骤 3 — 连接 MCP Inspector
打开检查器用户界面
设置传输类型: SSE
网址:
http://localhost:3001/sse添加授权标头:
Authorization: Bearer <your-token>单击**“连接”**
🎉 成功!您的服务器现已连接。
步骤 4 — 测试工具
转到检查器中的**“工具”选项卡,然后单击“列出工具”** 。
您将看到:
✅
test✅
echo✅
get-time✅
random-number
测试它们并享受吧!
📖 API 参考
🔑 生成令牌
GET /auth/token?username=<username>&scope=mcp:access🔌 SSE 端点(需要令牌)
GET /sse
Authorization: Bearer <token>📩 向活动会话发送消息
POST /message?sessionId=<sessionId>
Authorization: Bearer <token>🧩 工具参考
工具名称 | 描述 |
| 测试连接(安全检查) |
| 回显提供的消息 |
| 返回当前服务器时间 |
| 返回随机数(最小/最大) |
🗓️ 即将发生的变化
[ ] 令牌撤销列表(黑名单)
[ ] 基于角色的工具访问(范围检查)
[ ] 会话心跳/保持活动
[ ] 速率限制和日志记录
[ ] Docker化部署
📚 有用的资源
👨💻 维护者
阿尼克特
📄 许可证
该项目是开源的,可以免费使用。
🚀 构建。 安全。 赋能。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA high-performance Model Context Protocol (MCP) server designed for large language models, enabling real-time communication between AI models and applications with support for session management and intelligent tool registration.2MIT
- AlicenseNot gradedqualityDmaintenanceA server that implements the Model Context Protocol, providing a standardized way to connect AI models to different data sources and tools.1011MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server with HTTP transport that implements JWT authentication, allowing secure tool execution and prompt handling with role-based access control.61
- FlicenseNot gradedqualityNot gradedmaintenanceA Model Context Protocol (MCP) server implementation that uses Server-Sent Events (SSE) to enable real-time, server-pushed updates between AI models and tools over HTTP connections.1
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/anisirji/mcp-server-remote-setup-with-jwt-auth'
If you have feedback or need assistance with the MCP directory API, please join our Discord server