AA

aegisgatesecurity/aegisgate-mcp

Developer tools
0 stars 0 forks 품질 83 트렌드 20Apache-2.0

AegisGate MCP — Standalone Model Context Protocol security server with 23 security layers, vendored ONNX runtime, neural threat detection (L3). SSE streaming. Session management.

개요

A hardened, zero-dependency MCP server written in pure Go. Build your MCP server on a foundation that has security built in from line one — not bolted on after a breach. Apache 2.0 · 23 security layers · 79 regex patterns + CharCNN-BiLSTM (v13) ML detection · Zero CVEs · Zero external module dependencies is a trademark of AegisGate Security, LLC, filed with the USPTO. "AegisGate MCP" is an unregistered product name. See Trademark below. The official MCP SDKs give you the protocol. They don't give you security. No authentication. No audit logging. No threat detection. No rate limiting. No RBAC. Every server built on a bare SDK starts with a blank security posture and it's on you to build it — or skip it, as 38% of servers do. Build your MCP server on a foundation that has security built in from line one — not bolted on after a breach. Need proxy mode, OAuth, SIEM, or compliance frameworks?

README

AegisGate Security™ is a trademark of AegisGate Security, LLC, filed with the USPTO. “AegisGate MCP” is an unregistered product name. See Trademark below.


Why AegisGate MCP?

38% of MCP servers have no authentication. 590+ security advisories. 3 critical CVEs in the official MCP SDKs in 6 months — including CVSS 9.8 remote code execution and the “Mother of All AI Supply Chains” flaw affecting 150M+ downloads.

The official MCP SDKs give you the protocol. They don’t give you security. No authentication. No audit logging. No threat detection. No rate limiting. No RBAC. Every server built on a bare SDK starts with a blank security posture and it’s on you to build it — or skip it, as 38% of servers do.

AegisGate MCP is the secure alternative. Build your MCP server on a foundation that has security built in from line one — not bolted on after a breach.

Official MCP SDKs AegisGate MCP
Authentication ❌ Bring your own ✅ Bearer tokens + API keys + lockout
Authorization ❌ Nothing ✅ 4-tier RBAC with per-tool permissions
Audit logging ❌ Nothing ✅ Tamper-evident SHA-256 hash chain
Threat detection ❌ Nothing ✅ 79 regex patterns + neural ML (<1ms)
Supply chain risk ❌ npm/PyPI deps ✅ Zero dependencies (Go stdlib only)
CVEs 3 critical in 6 months Zero. Ever.
License MIT Apache 2.0

23 security layers. 79 regex patterns. Zero dependencies. Zero CVEs. Apache 2.0.

Need proxy mode, OAuth, SIEM, or compliance frameworks? See When to Upgrade to AegisGate Platform below — or explore AegisGate Rampart for local AI API proxy protection.


Overview

AegisGate MCP is a hardened, zero-dependency MCP server written in pure Go. It sits between AI agents and the tools they call, applying 23 layers of defense to every request — from authentication and RBAC to neural threat detection and chain analysis.

Standard MCP servers assume a trusted local environment. In production — whether that’s a cloud SaaS platform, an enterprise data pipeline, or an air-gapped plant network — agents may execute commands, query databases, or interact with critical systems. A single unauthorized or malicious tool call can cause data exfiltration, process disruption, or worse. AegisGate MCP wraps every tool call in defense-in-depth, all with zero external module dependencies so it can run air-gapped.

Version 1.6.0
License Apache-2.0
Go version 1.26+
Module deps Zero (no require directives — all third-party code vendored)
Docker image ML: debian:bookworm-slim (gnutls purged), ~127 MB, 0 CVEs · Lite: distroless/static-debian12, ~10 MB, 0 CVEs
Architectures amd64, arm64
ML model CharCNN-BiLSTM v13, 1.6M params, <1ms CPU inference
Tests 611 unit/integration + 32 load/stress = 643 total, 14 benchmarks, 3 fuzz targets, 92.0% coverage (non-CGO) / 91.9% (CGO)

Quick Start

Build

go build -o mcp-server ./cmd/mcp-server

Run

# Basic TCP server on :8081
./mcp-server

# With authentication and audit logging
./mcp-server --token my-secret --audit /var/log/mcp-audit.json

# With demo tools (ping, system_info, echo)
./mcp-server --demo

# stdio mode for local MCP clients (Claude Desktop, Cursor)
./mcp-server --transport stdio --demo

# Streamable HTTP mode (MCP 2025-06-18)
./mcp-server --transport http --addr :8081 --demo

# TLS + mutual TLS
./mcp-server --tls --tls-cert server.pem --tls-key server.key --tls-client-ca ca.pem

# Config file + health endpoint
./mcp-server --config /etc/mcp/config.json --health-addr :8082

Docker

# Build and run (ML-enabled, ~127 MB, 0 CVEs)
docker build --target ml -t aegisgate-mcp .
docker run -p 8081:8081 aegisgate-mcp --demo

# With authentication and audit logging
docker run -p 8081:8081 \
  -e MCP_AUTH_TOKEN=your-secret-token \
  -e MCP_DEMO_TOOLS=true \
  aegisgate-mcp

# Distroless heuristic-only build (~10 MB, 0 CVEs, zero OS packages)
docker build --build-arg CGO_ENABLED=0 --target lite -t aegisgate-mcp:lite .
docker run -p 8081:8081 aegisgate-mcp:lite --demo

The ML image uses debian:bookworm-slim with libgnutls30 purged (shared libraries and dpkg metadata removed), eliminating all 6 Trivy CVEs while keeping the glibc and ONNX Runtime dependencies required for neural inference. The lite image is true distroless (gcr.io/distroless/static-debian12:nonroot) — zero OS packages, zero CVEs, ~10 MB. Both targets include a built-in --health-check flag for Docker HEALTHCHECK (no wget/curl needed). Multi-arch builds support both linux/amd64 and linux/arm64.

ML Threat Detection (L3)

AegisGate MCP includes the same CharCNN-BiLSTM v13 neural model used by AegisGate Platform and Rampart — vendored with zero external module dependencies. The model provides:

  • Semantic attack detection — catches prompt injection and jailbreak attempts that bypass regex pattern matching
  • Evasion resistance — detects obfuscation techniques (leetspeak, Unicode homoglyphs, character transposition, vowel deletion, word reversal)
  • Two-tier blocking — scores ≥0.95 block independently; scores 0.50–0.94 block only if L1 (regex) or L2 (input scanner) corroboration is present
  • Shadow mode — log predictions without blocking (for calibration)
  • Heuristic fallback — when CGO is unavailable, heuristic scoring provides baseline detection without ONNX
Flag Env Var Default Description
--ml MCP_ML_ENABLED false (CLI) / true (Docker) Enable neural threat detection
--ml-shadow MCP_ML_SHADOW false Log predictions but never block
--ml-threshold MCP_ML_THRESHOLD 0.50 Threat score threshold (0.0–1.0)
--ml-model MCP_ML_MODEL ./models/threat_cnn_bilstm.onnx Path to ONNX model file

Library Usage

AegisGate MCP can be embedded as a Go library:

package main

import (
    "context"
    "log"
    mcp "github.com/aegisgatesecurity/aegisgate-mcp"
)

func main() {
    cfg := mcp.DefaultServerConfig()
    cfg.AuthToken = "my-secret-token"
    cfg.AuditLogPath = "/var/log/mcp-audit.json"
    cfg.RateLimitRPM = 120
    cfg.ScanResponses = true

    server, err := mcp.NewSecuredMCPServer(cfg)
    if err != nil {
        log.Fatal(err)
    }

    // Register a custom tool
    // Note: tools are automatically scanned for prompt-injection poisoning
    // at registration time. If the description or inputSchema contains
    // malicious patterns, RegisterTool returns *ToolPoisoningError.
    server.RegisterTool("my_tool", "Does something useful", 40, map[string]interface{}{
        "type": "object",
        "properties": map[string]interface{}{
            "param1": map[string]interface{}{"type": "string"},
        },
        "required": []interface{}{"param1"},
    })
    server.RegisterToolHandler("my_tool", func(ctx context.Context, params map[string]interface{}) (interface{}, error) {
        return "result", nil
    })

    // Register a resource (MCP resources/list, resources/read)
    server.RegisterResource("config://app/info", "App Info", "App config as JSON", "application/json",
        func(ctx context.Context, uri string) (*mcp.ResourceContent, error) {
            return &mcp.ResourceContent{URI: uri, Text: `{"version":"1.0"}`, MimeType: "application/json"}, nil
        })

    // Register a prompt (MCP prompts/list, prompts/get)
    server.RegisterPrompt("code_review", "Generate a code review prompt",
        []mcp.PromptArgument{{Name: "filename", Required: true}},
        func(ctx context.Context, args map[string]string) (*mcp.GetPromptResult, error) {
            return &mcp.GetPromptResult{
                Messages: []mcp.PromptMessage{{Role: "user", Content: "Review " + args["filename"]}},
            }, nil
        })

    // Load built-in policy rules
    server.LoadDefaultPolicies()

    // Start the server
    if err := server.Start(context.Background()); err != nil {
        log.Fatal(err)
    }
    defer server.Stop()
}

See examples/simple-server/ for a complete working example that registers a tool, resource, and prompt.

ML Model Hot-Swap

Reload the neural threat detection model at runtime without restarting the server:

// Swap to a new ONNX model file (verifies SHA-256 hash)
err := server.ReloadMLModel("/path/to/new_model.onnx")
if err != nil {
    log.Printf("model reload failed: %v", err)
}

Tool Poisoning Detection

All tools registered via RegisterTool() are automatically scanned for prompt injection in their descriptions and inputSchema. To scan manually:

err := server.ScanToolForPoisoning("my_tool", description, inputSchema)
if err != nil {
    // err is *ToolPoisoningError — do not register this tool
}

Security Layers

AegisGate MCP applies 23 security layers to every request, in order:

# Layer Description Source
1 Authentication Bearer token + API key, constant-time comparison, automatic lockout on repeated failures auth.go
2 Signature Verification ECDSA P-256 anti-forgery — verifies message signatures against trusted public keys auth.go
3 Session Management 256-bit cryptographically random session IDs, expiry, anti-hijacking checks session.go
4 RBAC 4-tier role hierarchy (restricted → standard → privileged → admin), per-tool permissions rbac.go
5 Policy Engine Allow/deny rules with conditions, priorities, time windows, and parameter patterns policy.go
6 Guardrails Per-session tool call limits and rate limiting guardrails.go
7 Chain Analysis Detects privilege escalation, data exfiltration chains, and repeated dangerous tool calls guardrails.go
8 Token Bucket Rate Limiting Sliding-window rate limiting with token bucket algorithm (RPM + burst capacity) guardrails.go
9 Input Scanning Scans tool parameters for prompt injection before execution (~79 patterns) handler.go, scanner.go
10 Response Scanning Scans tool responses for PII, secrets, XSS, and prompt injection (~79 detection patterns) scanner.go
11 Secret Redaction Scrubs sensitive data (PII, secrets) from responses before returning to the client scanner.go
12 Tool Execution Timeout Configurable per-call timeout prevents hanging or runaway tools handler.go
13 STDIO Validation Shell injection prevention via allowlist + blocklist for stdio transport commands stdio_guard.go
14 Audit Logging All MCP actions logged to file + in-memory, queryable for compliance, tamper-evident hash chain audit.go
15 TLS / mTLS Transport Encrypted TCP connections with optional mutual TLS config.go, server.go
16 stdio Transport Standard MCP client transport for Claude Desktop, Cursor, and other local integrations transport.go
17 Health Endpoint HTTP /healthz, /readyz, /stats endpoints on a separate listener transport.go
18 Parameter Validation Required fields checked against each tool’s inputSchema before execution handler.go
19 Neural Threat Detection (L3) CharCNN-BiLSTM v13 model scores semantic attacks and evasion variants that regex misses. Two-tier blocking: ≥0.95 blocks independently, 0.50–0.94 requires L1/L2 corroboration internal/ml/
20 Heuristic Evasion Detection Detects transposition, vowel deletion, word reversal, leetspeak, encoding, splitting, and zero-width character obfuscation internal/ml/evasion_resistance.go
21 NFKC Unicode Normalization Maps Unicode compatibility characters to canonical forms before scanning — defeats homoglyph and ligature attacks (full-width Ignore → ignore) internal/ml/normalizer.go
22 Tool Poisoning Detection Scans tool descriptions and inputSchema recursively for prompt injection (34 dangerous function patterns from AegisGate Scanner) at registration time — rejects poisoned tools before they’re callable. Maps to OWASP MCP Top 10 M1 handler.go
23 Evasion Detection (L2.5) 15 regex patterns detecting encoding (base64, URL, unicode, HTML entities), splitting (zero-width chars, interleaving), obfuscation (leet speak, padding, markup), and semantic evasion (role-play framing, instruction override). Score ≥ 0.8 blocks independently; ≥ 0.3 logs warning. Runs between L1 regex and L3 neural detection internal/ml/evasion_resistance.go

Detection Pattern Categories (79 patterns)

AegisGate MCP scans all tool parameters and responses with 79 regex patterns across 8 categories:

Category Patterns Examples
Prompt 25 Ignore-previous-instructions, role-play escalation, RAG smuggling, system prompt leakage, delimiter injection, base64 payloads
Dangerous Functions 34 eval(), exec(), os.system(), subprocess(shell=True), pickle.loads(), child_process.exec()
Credentials 6 AWS keys, GitHub PATs, JWT tokens, RSA private keys, generic API keys
Financial 3 Credit cards (Visa, Mastercard, Amex)
Network 3 Network addresses, OPC UA, Modbus, DNP3
PII 2 SSN, email
XSS 3 Script tags, SVG onload, image onerror
Compliance 3 OWASP LLM01/02/06








Demo Tools

Enable demo tools with the --demo flag or by calling RegisterDemoTools() in library mode. These are safe, read-only tools that do not access the filesystem, network, or any external resources.

Tool Risk Level Required Params Description
ping 10 (none) Returns "pong" — health check tool
system_info 30 (none) Returns Go version, OS, arch, CPU count, goroutine count, timestamp
echo 20 message (string) Echoes back the provided message

Example — system_info response:

{
  "go_version": "go1.26.9",
  "os": "linux",
  "arch": "amd64",
  "cpus": 8,
  "goroutines": 12,
  "timestamp": "2026-10-08T08:58:00Z"
}

Documentation

Detailed documentation is available in the docs/ directory:

Document Description
docs/getting-started.md Installation, first run, and basic configuration
docs/deployment-guide.md Production deployment: Docker, TLS, air-gapped setups
docs/admin-guide.md Administration: sessions, audit logs, RBAC management, policies
docs/how-to-guides.md Task-specific guides: custom tools, signature verification, mTLS setup
docs/building-your-first-server.md Tutorial: build a complete secure MCP server from scratch with custom tools, RBAC, and policies
docs/integrating-with-cursor.md Connect Cursor to AegisGate MCP via Streamable HTTP transport
docs/model-card.md ML model details: architecture, training data, performance metrics
docs/comparison.md Feature comparison: AegisGate MCP vs official MCP SDKs and bolt-on wrappers
docs/owasp-mcp-top-10.md OWASP MCP Top 10 risk mapping — coverage for all 10 security risks
docs/v1.3.0-roadmap.md Roadmap for SSE streaming, server-initiated notifications, resource subscriptions, and resource templates (P1–P4 complete)

Changelog

See CHANGELOG.md for version history and notable changes.


Platform Interop (Optional)

AegisGate MCP can optionally integrate with AegisGate Platform for pattern pulling and event forwarding:

  • Pattern Pull: Fetch canonical detection patterns from Platform’s telemetry endpoint with ETag caching
  • Event Forwarding: Send security events to Platform’s telemetry receiver in canonical contract format
  • Tool Description Screening: Enhanced with 34 dangerous function patterns from AegisGate Scanner

All interop features are air-gap compatible — fully disabled when platform_url is not configured. No network calls, no telemetry, no external dependencies.


When to Upgrade to AegisGate Platform

AegisGate MCP is a standalone secure MCP server framework — perfect for building and running MCP servers with security built in. It’s free, open source, and has zero external dependencies.

When your needs grow beyond a single server, AegisGate Platform is the natural upgrade path:

Need AegisGate MCP (free) AegisGate Platform
Secure MCP server framework ✅ 23 layers, zero deps ✅ Embedded MCP server
ML threat detection ✅ Capped at 100 inf/min (single-server) ✅ Unlimited, org-wide
Proxy/gateway mode ❌ Framework, not proxy ✅ Sits between clients and all AI services
OAuth 2.0 / OIDC / SSO ❌ Bearer tokens + API keys ✅ SAML, OIDC, JWT
SIEM integration ❌ File-based audit + Prometheus ✅ Splunk, Elasticsearch, QRadar, Datadog (11 platforms)
Compliance frameworks ❌ None ✅ 31 frameworks (HIPAA, PCI, SOC 2, EU AI Act, NIST, etc.)
Multi-protocol (HTTP, A2A, ACP) ❌ MCP only ✅ 6 pillars
Enterprise scale ⚠️ 250 connections, 25 sessions ✅ Unlimited

Think of it this way: AegisGate MCP is the secure foundation you build MCP servers on. AegisGate Platform is the enterprise gateway that secures all AI traffic across your organization — including MCP, HTTP, A2A, and ACP.

Other AegisGate products:

  • AegisGate Rampart — Free local proxy for developers using Claude, Cursor, or Copilot
  • AegisGate Lens — Free browser extension for everyday AI conversations

License

Apache-2.0. See LICENSE for the full text and NOTICE for attribution.

Security

See SECURITY.md for vulnerability reporting.

Contributing

See CONTRIBUTING.md. All commits must be signed off (git commit -s) per the DCO.


View this README on GitHub

설치

docker run -p 8081:8081 aegisgate-mcp --demo