Skip to main content
Glama

SSE MCP Server with JWT Authentication

🔐 JWT 認証を備えた SSE MCP サーバー

これは、JWT ベースの認証を備えたモデル コンテキスト プロトコル (MCP) SSE サーバーです。
安全なベアラー トークン フローによって保護された SSE トランスポートを介して複数の AI ツールを公開できます。

搭載コンポーネント:

  • 🚀 Node.js + エクスプレス
  • 🧩 @modelcontextprotocol/sdk
  • 🔒 認証のためのJSON Web Token(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 インスペクター

npx @modelcontextprotocol/inspector

ステップ2 — トークンを生成する

cURL を使用して JWT トークンを取得します。

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

✅ 回答例:

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

ステップ3 - MCP Inspectorを接続する

  1. インスペクターUIを開く
  2. トランスポートタイプを設定: SSE
  3. URL:
    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化

📚 役立つリソース

👨‍💻 メンテナー

アニケット

📄 ライセンス

このプロジェクトはオープンソースであり、無料で使用できます。

🚀 構築する。保護する。強化する。

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