notifications-mcp
Streamable HTTP + SSE MCP サーバー
本番環境対応 Model Context Protocol (MCP) サーバー。Streamable HTTP + SSE、Bearer 認証、厳格なセッション ID バインディング、プロンプトインジェクションガードレール、受信者許可リスト、レート制限を備えています。
👥 作業分担と責任範囲
担当者 | 領域と成果物 |
@Vinod | サーバースキャフォールディング、Streamable HTTP( |
@Vishal | ツールハンドラー( |
Related MCP server: Gmail MCP Server
🌟 コア機能と標準
公式 MCP 仕様準拠: JSON-RPC 2.0 トランスポート(Streamable HTTP、
POST /mcpおよびGET /mcpSSE)。セッションセキュリティと再開機能:
Mcp-Session-Id: 認証された呼び出し元 ID に厳密に紐付けられた UUID セッション。Last-Event-ID: 再接続時のイベントリプレイ用 SSE イベントリングバッファ。
セキュリティガードレール:
認証強制: すべての
/mcpリクエストに有効な Bearer トークンまたは API キーが必要。セッションハイジャック対策: セッション ID を異なる ID 間で共有不可。
プロンプトインジェクション対策: メールフィールドをスキャンする正規表現およびヒューリスティック分析器とセキュリティ監査ログ。
受信者許可リスト&レート制限: 不正なメール流出と過剰送信を防止。
クリーンなエラーサニタイズ: 汎用的で安全な JSON-RPC エラー(スタックトレース漏洩なし)。
モックツール:
get_current_datetime(timezone?): IANA タイムゾーン検証付きシステム日時。send_email(to, subject, body): 安全なシミュレーションデモモード付きサーバー SMTP。
📁 リポジトリ構造
Custom_MCP_Server/
├── config.yaml # Server, auth tokens, allowlists, rate limits, and SMTP config
├── pyproject.toml # Package definition & dependencies
├── requirements.txt # Dependencies
├── README.md # Documentation & demo checklist
├── scripts/
│ ├── run_tunnel.py # Hosting / tunnel launcher (Cloudflared, Ngrok, Localtunnel, Local)
│ └── test_demo_cases.py # Automated verification suite for the 6 Live Demo test cases
├── src/
│ ├── __init__.py
│ ├── config.py # Typed configuration models
│ ├── server.py # Starlette Streamable HTTP + SSE application
│ ├── registry.py # MCP tools registration & dispatcher
│ ├── auth/
│ │ ├── __init__.py
│ │ ├── middleware.py # Auth, Origin, and session validation middleware
│ │ └── session_manager.py # UUID session manager with Last-Event-ID buffer
│ ├── security/
│ │ ├── __init__.py
│ │ ├── injection_detector.py # Prompt injection detector & audit logger
│ │ ├── allowlist.py # Email recipient & domain allowlist validator
│ │ └── rate_limiter.py # Sliding-window rate limiter per caller
│ ├── common/
│ │ ├── __init__.py
│ │ ├── errors.py # JSON-RPC 2.0 error codes and builders
│ │ └── logging.py # Structured JSON logger with security tags
│ └── tools/
│ ├── __init__.py
│ ├── datetime_tool.py # get_current_datetime tool handler
│ └── email_tool.py # send_email tool handler with SMTP/demo mode
└── tests/
├── __init__.py
├── conftest.py
├── test_datetime_tool.py # Datetime unit tests
├── test_email_tool.py # Email & security guardrail tests
├── test_security_auth.py # Auth & session isolation tests
└── test_streamable_http.py # Streamable HTTP / SSE transport tests🚀 クイックスタートガイド
1. 前提条件
Python 3.10+
Node.js(オプション、MCP Inspector 用)
2. 依存関係のインストール
pip install -r requirements.txt3. サーバーの起動
python -m src.server次のように表示されます:
{"timestamp": "...", "level": "INFO", "message": "Starting Streamable MCP Server | host=0.0.0.0 | port=8100"}
{"timestamp": "...", "level": "INFO", "message": "MCP POST/GET endpoint → http://localhost:8100/mcp"}
{"timestamp": "...", "level": "INFO", "message": "Health check probe → http://localhost:8100/health"}⚙️ 設定 (config.yaml)
server:
host: "0.0.0.0"
port: 8100
allowed_origins:
- "http://localhost:8100"
- "*"
auth:
enabled: true
tokens:
"agent-token-alpha": "agent_alpha"
"agent-token-beta": "agent_beta"
"vishal-test-token": "vishal_engineer"
"vinod-test-token": "vinod_engineer"
security:
email:
allowlist:
- "ops@company.com"
- "manager@company.com"
- "vishal@company.com"
- "vinod@company.com"
- "*@trusteddomain.com"
rate_limit:
max_calls: 10
window_seconds: 60
prompt_injection_guard:
enabled: true
smtp:
mode: "simulation" # "simulation" (safe for testing/demos) or "smtp" (live server)
host: "smtp.example.com"
port: 587
sender_address: "notifications@company.com"🛠️ ツールスキーマ
ツール 1: get_current_datetime
説明: オプションの IANA タイムゾーン変換付きで、現在のホストシステム日時を返します。
パラメーター:
{ "type": "object", "properties": { "timezone": { "type": "string", "description": "Optional IANA timezone name (e.g. 'UTC', 'America/New_York', 'Asia/Kolkata')." } }, "required": [] }
ツール 2: send_email
説明: 厳格なセキュリティガードレール付きで、サーバー SMTP 経由でメール通知を送信します。
パラメーター:
{ "type": "object", "properties": { "to": { "type": "string", "description": "Recipient email address. Must be in the authorized allowlist." }, "subject": { "type": "string", "description": "Email subject line." }, "body": { "type": "string", "description": "Email body content." } }, "required": ["to", "subject", "body"] }
🔌 MCP Inspector と cURL での接続
MCP Inspector 経由で接続:
npx @modelcontextprotocol/inspectorURL: http://localhost:8100/mcp に接続し、カスタムヘッダー: Authorization: Bearer vishal-test-token を設定します。
サンプル cURL 呼び出し:
1. get_current_datetime の呼び出し:
curl -X POST http://localhost:8100/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer vishal-test-token" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_current_datetime",
"arguments": {"timezone": "Asia/Kolkata"}
}
}'2. send_email の呼び出し:
curl -X POST http://localhost:8100/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer vishal-test-token" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "send_email",
"arguments": {
"to": "ops@company.com",
"subject": "System Status",
"body": "All services operating normally."
}
}
}'🌐 ホスティング&トンネル設定
MCP サーバーを公開 URL / クラウドデモに公開するには:
# Option 1: Direct Local / VM binding
python scripts/run_tunnel.py --mode local --port 8100
# Option 2: Cloudflare Tunnel (Free, no port-forwarding needed)
python scripts/run_tunnel.py --mode cloudflared --port 8100
# Option 3: Ngrok
python scripts/run_tunnel.py --mode ngrok --port 8100
# Option 4: Localtunnel
python scripts/run_tunnel.py --mode localtunnel --port 8100🧪 ライブデモチェックリスト(6 テストケース)
自動テストランナーを実行して、6 つのデモケースすべてを 1 コマンドで確認:
python scripts/test_demo_cases.pyまたは pytest で実行:
pytest -v確認済みテストケース:
ケース 1: 各ツールへの認証済み呼び出しが成功する(
get_current_datetimeとsend_emailの両方)。ケース 2: 未認証の呼び出し元は汎用エラーを受け取る(HTTP 401、エラーコード
-32001)。ケース 3: 不正な入力はクリーンなバリデーションエラーを返す(無効なタイムゾーンやスキーマフィールドの欠落)。
ケース 4: メール内のプロンプトインジェクション試行はブロックされログに記録される(例: システムプロンプトの上書き)。
ケース 5: 許可リストにないメールアドレスへの送信は拒否される(外部/不正なアドレスをブロック)。
ケース 6: 異なる ID 間でのセッション ID 再利用は拒否される(HTTP 403、エラーコード
-32005)。
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Unified MCP Server is a remote MCP connector for AI agents and vertical AI products that provides access to 22,000+ authorized SaaS tools across 400+ integrations and 24 categories directly inside LLMs (Claude, GPT, Gemini, Cohere). Tools operate only on explicitly authorized customer connections, enabling agents to safely read and write against live third-party systems.
The Mobile Text Alerts SMS MCP server enables your AI to send SMS messages & manage contacts
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides AI applications with a toolset for an Artificial Virtual Assistant (AVA) integrated with the Gmail API. It enables users to automate email management and personal tasks through secure Google OAuth authentication.1Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA Node.js server that connects MCP to Gmail, enabling LLMs to send, read, and manage emails securely using the Gmail API.184 npm2MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Gmail through a standardized MCP server interface, allowing for natural language email management and automation.-
- FlicenseNot gradedqualityDmaintenanceProduction-ready MCP server for Gmail, enabling AI agents to search, read, send, draft, and manage emails, labels, and attachments via the Google Gmail API.-