CoolFace
Apppublic

MCP-1st-Birthday/mcp-security-dashboard

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

πŸ“Š MCP Security Dashboard (Hugging Face Space)

Real‑time visibility into requests flowing through your MCP Security Gateway:

  • β€”System health & downstream service latency
  • β€”Live audit stream (auto-refresh) with execution times
  • β€”Tool & server performance metrics
  • β€”User activity & block rates
  • β€”High‑risk / jailbreak attempt listing
  • β€”Manual LLM tool-call tester
  • β€”AI Analytics and Insights by Claude
  • β€” ---

πŸš€ Quick Deploy (Web UI)

  1. 1.Go to https://huggingface.co/new-space
  2. 2.Name: mcp-security-dashboard | SDK: Gradio | Hardware: CPU basic
  3. 3.Upload from dashboard/:
  4. 4.app.py
  5. 5.requirements.txt
  6. 6.Set Space variable (Settings β†’ Variables & secrets):
   MCP_HOST=https://yukisui22--security-mcp-gateway-gateway.modal.run
  1. 1.Save. Build completes in ~2–3 minutes.
  2. 2.Open the Space β†’ click "πŸ”„ Refresh Health Status".

πŸ”Œ Prerequisites

  • β€”Deployed Modal gateway with URL (e.g. https://yukisui22--security-mcp-gateway-gateway.modal.run)
  • β€”Gateway logging enabled (writes audit lines to /tmp/audit.log.jsonl)
  • β€”Gateway exposes GET /audit/latest?limit=500 (added in modal/gateway.py).

πŸ” Environment Variables

NamePurposeRequired
MCP_HOSTBase URL of your Security Gatewayβœ…
GRADIO_PORTOverride port (HF sets automatically)❌
AUDIT_LOG_PATHLocal fallback path (rarely needed)❌

If MCP_HOST is set, the dashboard fetches remote audit data from MCP_HOST/audit/latest. If not set, it falls back to a local audit.log.jsonl file (useful for local dev).


πŸ—‚ Features

PanelDescription
System HealthStatus, tool counts, per-server latency & errors
Live Audit StreamAuto-refresh (2s) formatted chronological records
Tool & Server StatsAggregated counts, avg risk, block rate, avg exec time
User ActivityPer-user volume, blocks, last seen timestamp
High-Risk / JailbreakSorted list of top-risk or flagged attempts
LLM TesterManual POST to /tools/secure_call for experiments

πŸ‘₯ Team

Team Name: MemKrew

Team Members:


πŸ§ͺ Manual Test (LLM Tester Tab)

Paste a JSON payload like:

json
{
  "user_id": "tester",
  "server": "fetch",
  "tool": "fetch",
  "arguments": {"url": "https://example.com", "max_length": 300},
  "llm_context": "Basic demo"
}

Click "Send" β†’ check Live Audit Stream.


πŸ‘©β€πŸ’» Git Workflow (Alternative)

bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/mcp-security-dashboard
cd mcp-security-dashboard
cp ../security-mcp/dashboard/app.py .
cp ../security-mcp/dashboard/requirements.txt .
cat > README.md <<'EOF'
---
title: MCP Security Dashboard
emoji: πŸ“Š
colorFrom: purple
colorTo: indigo
sdk: gradio
app_file: app.py
pinned: false
---
# MCP Security Dashboard
Visualize health, audit logs, and security activity from your Security MCP Gateway.
EOF
git add .
git commit -m "Initial dashboard"
git push

Then set MCP_HOST in Space Settings.


πŸ›  Troubleshooting

SymptomResolution
Health shows errorVerify MCP_HOST reachable; curl /health manually
Audit emptyGenerate traffic via Playground or LLM Tester tab
High-Risk tab blankNo threats yet (good!) or risk thresholds not met
CORS errorsGateway already adds permissive CORS; recheck URL correctness
Slow updatesReduce request frequency (audit stream interval)

πŸ“¦ Dependencies

Minimal runtime in requirements.txt:

gradio>=4.0.0
requests>=2.31.0

πŸ”’ Privacy & Logs

Audit entries may include user IDs and arguments. For public demos, avoid real PII in prompts.


πŸ“ License

MIT (matches project). You may fork and adapt for your own MCP gateway variants.


🌟 Next Enhancements

  • β€”Pagination for large audit sets
  • β€”WebSocket streaming
  • β€”Role-based filtering / access control
  • β€”Graph visualizations for risk trends

Made for the MCP Hackathon 2025 Β· Secure by design.

Prerequisites

  • β€”Modal-deployed gateway URL (example):
  • β€”https://yukisui22--security-mcp-gateway-gateway.modal.run
  • β€”The gateway writes audit logs to /tmp/audit.log.jsonl (already configured in modal/gateway.py).
  • β€”This repo change adds a new endpoint on the gateway: GET /audit/latest?limit=500 which serves recent audit records as JSON for the dashboard.

Quick Deploy (Web UI)

  1. 1.Create a new Space: https://huggingface.co/new-space
  2. 2.Name: mcp-security-dashboard
  3. 3.SDK: Gradio
  4. 4.Hardware: CPU basic
  1. 1.Upload these files from dashboard/:
  2. 2.app.py
  3. 3.requirements.txt
  1. 1.Set the environment variable (Settings β†’ Variables & secrets):
  2. 2.MCP_HOST = https://yukisui22--security-mcp-gateway-gateway.modal.run
  1. 1.Save and wait for the Space to build.
  1. 1.Open the Space and click "πŸ”„ Refresh Health Status"; you should see status and downstream info.
  1. 1.The Live Audit Stream will auto-refresh and fetch recent entries from /audit/latest on the gateway.

Git Workflow

bash
# Create Space repo first (via HF UI) then locally:
 git clone https://huggingface.co/spaces/YOUR_USERNAME/mcp-security-dashboard
 cd mcp-security-dashboard
 
 # Copy files
 cp ../security-mcp/dashboard/app.py .
 cp ../security-mcp/dashboard/requirements.txt .
 
 # Optional: Add a README.md with frontmatter
 cat > README.md << 'EOF'
 ---
 title: MCP Security Dashboard
 emoji: πŸ“Š
 colorFrom: purple
 colorTo: indigo
 sdk: gradio
 app_file: app.py
 pinned: false
 ---
 
 # MCP Security Dashboard
 Visualize health, audit logs, and security activity from your Security MCP Gateway.
 EOF
 
 git add .
 git commit -m "Initial dashboard"
 git push

Then set the Space variable MCP_HOST in the Space settings to your Modal gateway URL.

Troubleshooting

  • β€”Live Audit shows "No audit records yet": send some traffic from the Playground or LLM Tester tab. The gateway must write audit logs.
  • β€”Health check fails: verify the gateway URL and that it's reachable from the Internet.
  • β€”CORS: Gateway already enables CORS; if issues persist, check DevTools β†’ Network.