Skip to main content
Glama

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!

✨ 特点

  • ✅ 使用 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-auth

2.安装依赖项

npm install

3.创建.env文件

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

4.运行服务器

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

  1. 打开检查器用户界面
  2. 设置传输类型: SSE
  3. 网址:
    http://localhost:3001/sse
  4. 添加授权标头:
    Authorization: Bearer <your-token>
  5. 单击**“连接”**

🎉 成功!您的服务器现已连接。

步骤 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>

🧩 工具参考

工具名称描述
test测试连接(安全检查)
echo回显提供的消息
get-time返回当前服务器时间
random-number返回随机数(最小/最大)

🗓️ 即将发生的变化

  • [ ] 令牌撤销列表(黑名单)
  • [ ] 基于角色的工具访问(范围检查)
  • [ ] 会话心跳/保持活动
  • [ ] 速率限制和日志记录
  • [ ] Docker化部署

📚 有用的资源

👨‍💻 维护者

阿尼克特

📄 许可证

该项目是开源的,可以免费使用。

🚀 构建。 安全。 赋能。

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

模型上下文协议服务器通过基于 JWT 的安全身份验证通过 SSE 传输公开多个 AI 工具,从而实现动态工具注册和会话管理。

  1. 📂 项目结构
    1. ✨ 特点
      1. ⚙️ 设置
        1. 克隆存储库
        2. 2.安装依赖项
        3. 3.创建.env文件
        4. 4.运行服务器
      2. 🧪 使用 MCP Inspector 测试服务器
        1. 步骤 1 — 安装 MCP Inspector
        2. 步骤 2 — 生成令牌
        3. 步骤 3 — 连接 MCP Inspector
        4. 步骤 4 — 测试工具
      3. 📖 API 参考
        1. 🔑 生成令牌
        2. 🔌 SSE 端点(需要令牌)
        3. 📩 向活动会话发送消息
      4. 🧩 工具参考
        1. 🗓️ 即将发生的变化
          1. 📚 有用的资源
            1. 👨‍💻 维护者
              1. 📄 许可证
                1. 🚀 构建。 安全。 赋能。

                  Related MCP Servers

                  • A
                    security
                    F
                    license
                    A
                    quality
                    A Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.
                    Last updated -
                    1
                    3
                    18
                    JavaScript
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A Model Context Protocol server that enables seamless execution of commands, Python code, web content fetching, and reusable task management with secure credentials handling.
                    Last updated -
                    2
                    Python
                    MIT License
                    • Apple
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.
                    Last updated -
                    16
                    TypeScript
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A Model Context Protocol server that provides AI agents with secure access to local filesystem operations, enabling reading, writing, and managing files through a standardized interface.
                    Last updated -
                    160
                    3
                    TypeScript
                    Apache 2.0

                  View all related MCP servers

                  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