Skip to content
Conduit

mcp server

cyber-mcp-public

Securing Agentic AI: Using MCP to enforce policies on sensitive tool usage.

stoikio/cyber-mcp-publiccommunitylistedunreviewed

Set up

Runs on your computer. Pick your agent and operating system.

This project does not publish an install method we can turn into a config. Follow the README instead.

README

synced Oct 23, 2026

Secure MCP Gateway

A security proxy that exposes Gmail, Slack, Google Calendar, and Notion to AI agents via the Model Context Protocol (MCP).

Every tool call goes through a full security pipeline before reaching the backend API:

Authentication (JWT / API key) → Policy check (PG) → Rate limit (Redis) → Backend logic → Audit (PG + file)

Features

  • OAuth2 + PKCE — Google Workspace login with per-user token isolation
  • API key auth — SHA-256 hashed keys with expiration and revocation
  • Policy engine — configurable rules (block, warn, log) evaluated before each tool call
  • Rate limiting — Redis-backed sliding window per user
  • Audit trail — every action logged to PostgreSQL (+ optional file)
  • Sensitive email filtering — blocks password resets, OTP codes, magic links from AI agents
  • Admin panel — React SPA + FastAPI backend for managing policies, keys, integrations
  • Docker-ready — multi-stage Dockerfile with PostgreSQL 17 + Redis 8

Quick start

1. Prerequisites

  • Python 3.11+
  • Node.js 22+ (for admin frontend build)
  • Docker & Docker Compose (for PostgreSQL + Redis)

2. Setup

# Clone the repo
git clone https://github.com/stoikio/cyber-mcp-public.git
cd cyber-mcp-public

# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements_mcp.txt

# Copy and configure environment
cp .env.example .env
# Edit .env with your settings (GOOGLE_CLIENT_ID, JWT_SECRET, etc.)

3. Start infrastructure

docker compose up -d   # PostgreSQL + Redis

4. Initialize database

alembic upgrade head          # Run migrations
python3 seed_policies.py      # Load default security policies

5. Create an API key

python3 migrate_security.py --generate-encryption-key  # Add ENCRYPTION_KEY to .env
python3 migrate_security.py --generate-jwt-secret       # Add JWT_SECRET to .env
python3 migrate_security.py --add-key your-email@example.com

6. Start the gateway

python3 mcp_secure_gateway.py
# Gateway available at http://localhost:8000/mcp

7. Connect from Claude Desktop

{
  "mcpServers": {
    "secure-mcp-gateway": {
      "url": "http://localhost:8000/mcp",
      "headers": { "X-API-Key": "YOUR_API_KEY" }
    }
  }
}

Or run ./setup_claude_desktop.sh for automatic configuration.

Docker deployment

# Build the image
docker build -t secure-mcp-gateway .

# Run (adjust env vars as needed)
docker run -p 8000:8000 -p 8001:8001 \
  --env-file .env \
  -e ENABLE_ADMIN=true \
  secure-mcp-gateway

The entrypoint automatically runs migrations, seeds policies, and starts the gateway.

Admin panel

The admin panel provides a web UI for managing:

  • Security policies (create, edit, toggle)
  • API keys (create, revoke, list)
  • Blocked email patterns
  • Slack channel configurations
  • Integration tokens (Slack, Notion)
  • OAuth clients
  • Audit log viewer
  • Dashboard with usage stats

Run locally

./start_admin.sh
# Admin panel at http://localhost:8001

Run in Docker

Set ENABLE_ADMIN=true in your environment to start the admin panel alongside the gateway.

MCP Tools (15 tools)

Gmail (5)

ToolDescription
read_inboxRead recent emails (sensitive emails auto-filtered)
read_emailRead a specific email by ID
search_emailsSearch emails with Gmail query syntax
create_draftCreate a Gmail draft (human-in-the-loop)
send_emailSend an email (blocked by default policy)

Slack (4)

ToolDescription
send_slack_dmSend a direct message to a user
send_slack_messageSend a message to a channel (blocked by default policy)
list_slack_channelsList available Slack channels
read_slack_channelRead messages from a channel

Google Calendar (3)

ToolDescription
list_calendar_eventsList events for a date range
check_availabilityCheck available time slots
create_calendar_eventCreate an event with attendees

Notion (3)

ToolDescription
notion_searchSearch pages and databases
notion_read_pageRead a page's content
notion_query_databaseQuery a database with filters

send_email and send_slack_message are blocked by default policies — use create_draft and send_slack_dm for safer alternatives.

Security policies

Default policies include:

  • Block direct email sending (force draft workflow)
  • Warn on external recipients
  • Block sensitive data in message bodies (passwords, API keys, private keys)
  • Filter sensitive emails (password resets, OTP codes, magic links)
  • Block automated recipient patterns (prevent agent loops)
  • Cap result counts and date ranges
  • Audit all tool calls

Edit policies via the admin panel or directly in policies.json.

Project structure

├── mcp_secure_gateway.py       # MCP gateway entrypoint
├── gateway/                    # Core Python package
│   ├── config.py               # Environment configuration
│   ├── db.py                   # SQLAlchemy models + async engine
│   ├── crypto.py               # Fernet encryption helpers
│   ├── redis_client.py         # Async Redis client
│   ├── auth/                   # JWT, middleware, OAuth2 flow
│   ├── security/               # Policies, audit, rate limiting
│   ├── backends/               # Gmail, Slack, Calendar, Notion adapters
│   └── tools/                  # MCP tool registrations
├── admin/                      # Admin panel
│   ├── backend/                # FastAPI REST API
│   └── frontend/               # React + Vite + Tailwind SPA
├── alembic/                    # Database migrations
├── policies.json               # Default security policies
├── requirements_mcp.txt        # Python dependencies
├── Dockerfile                  # Container build
├── docker-compose.yaml         # Local PostgreSQL + Redis
└── .env.example                # Environment variable template

Environment variables

VariableRequiredDescription
ENCRYPTION_KEYYesFernet key for token encryption
JWT_SECRETYes (prod)HMAC secret for JWT signing
GOOGLE_CLIENT_IDFor OAuthGoogle OAuth 2.0 client ID
GOOGLE_CLIENT_SECRETFor OAuthGoogle OAuth 2.0 client secret
GATEWAY_DOMAINFor OAuthPublic domain for OAuth callbacks
ALLOWED_EMAIL_DOMAINOptionalRestrict login to a domain
DATABASE_URLYesPostgreSQL connection string
REDIS_URLYesRedis connection string
ADMIN_EMAILSFor adminComma-separated admin email list
DEV_MODENoSkip auth (dev only, never in prod)

License

This project is licensed under the GNU General Public License v3.0.

↑↓ navigate openesc close