mastyf-ai/mastyf.ai

🔒 Security
0 Views
0 Installs

📇 🏠 🍎 🪟 🐧 - Open-source runtime security proxy for MCP. Transparently intercepts every tools/call through an 18-class attack defense pipeline (prompt injection, SSRF, shell injection, SQL injection, credential exfil, polyglot attacks) with a YAML policy engine and 304-entry adversarial corpus. Trust scoring for npm MCP packages with 0-100 badges. Cloud dashboard, Docker image, Python SDK. MIT.

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "mastyf-ai-mastyf-ai": {
      "command": "npx",
      "args": [
        "-y",
        "mastyf-ai-mastyf-ai"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

mastyf.ai logo

mastyf.ai

Perimeter security for your AI.

Runtime enforcement, policy control, and full audit trail for every AI action.

Website · Quick start · Policy · Dashboard · GitHub

License CI Version TypeScript npm


The problem

AI agents can read your files, push code, query databases, execute shell commands, and call external APIs. They do it autonomously, at machine speed.

Traditional security controls weren't built for that.

Mastyf.ai acts as a perimeter security layer for AI. It intercepts every tool call, evaluates it against your security policies using multi-agent swarm analysis, and blocks malicious or unauthorized actions before they execute.

Every decision is enforced, logged, and auditable.


What it stops

ThreatWhat it looks like
Prompt injectionMalicious instructions embedded in tool arguments to hijack agent behavior
Path traversalAttempts to access /etc/passwd, .ssh/id_rsa, .aws/credentials
Secret exfiltrationAPI keys and tokens leaking through tool arguments
Shell injectionReverse shells, rm -rf, encoded PowerShell commands
Data exfiltrationBulk SQL dumps, git push, aws s3 cp, unauthorized file transfers
SSRFCalls to metadata endpoints, localhost, and private IP ranges
Encoding evasionBase64 blobs and Unicode homoglyphs used to bypass pattern detection
Cost abuseRunaway agent loops burning through token budgets
Rug-pull attacksTool definitions that silently change mid-session

Quick start

Build from source

Clone the repository and run the setup script.

Requirements:

  • Git
  • Linux (the setup script installs Nix automatically if needed)
git clone https://github.com/mastyf-ai/mastyf.ai.git
cd mastyf.ai
chmod +x setup.sh
./setup.sh

The setup script automatically:

  • Installs Nix (if required)
  • Enables Nix flakes
  • Creates the development environment
  • Installs all project dependencies
  • Rebuilds native packages
  • Builds the entire project
  • Adds a convenient mastyf shell alias

Once installation completes, start the proxy and dashboard:

node dist/cli.js start

Or simply use the alias after opening a new terminal:

mastyf

The dashboard will be available at:


Test the installation

If the dashboard is running, verify the HTTP bridge:

curl -X POST http://localhost:4000/mcp -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}'

Dashboard

Full visibility into every action your AI takes.

20260628-1234-42 0110563
SectionWhat you see
ProtectionBlock rate, top triggered rules, live threat feed
ActivityEvery tool call with full arguments, allow or block status, timestamp
PolicyLive rule editor with hot-reload from YAML
Threat LabAI-suggested attack tests, reviewed and approved before anything applies
CostToken usage and cost estimates broken down per tool call

Do not expose port 4000 publicly without enabling dashboard auth. The default local dev config has DASHBOARD_AUTH_DISABLED=true.


How enforcement works

Every tool call passes through three layers before it reaches your infrastructure.

Layer 1 - Pattern detection Regex-based scanning for injection, dangerous paths, leaked secrets, shell commands, and encoding tricks. Runs in microseconds with no external dependencies.

Layer 2 - Schema validation Rejects malformed payloads, oversized arguments, and JSON-RPC violations before they reach policy evaluation.

Layer 3 - Semantic review An optional local LLM (Ollama) or cloud model evaluates borderline calls that pass pattern checks. Falls back to heuristics if no model is configured.

Anything that fails is blocked. The tool never runs. Everything is logged.

image

Policy

Your rules live in default-policy.yaml. You own them. mastyf.ai enforces them.

policy:
  mode: block
  default_action: pass
  unicode_strict: true
  rules:
    - name: block-sensitive-paths
      action: block
      argPatterns:
        - field: path
          patterns: ['^/etc/', '/\.ssh', '/\.aws/credentials']

    - name: rate-limit-tool-calls
      action: block
      maxCallsPerMinute: 120

    - name: block-shell-injection
      action: block
      patterns: ['rm\s+-rf', 'curl\s', 'wget\s', '`[^`]+`']

Roll out safely with three enforcement modes:

ModeBehaviorWhen to use
auditLog everything, block nothingFirst week, understand what your AI does
warnLog and flag, still forwardsTuning phase before enforcement
blockStops violations before executionProduction

Pre-built templates for HIPAA, PCI-DSS, GxP, and data residency are in policy-templates/.

image

Architecture

mastyf.ai runs two coordinated swarms. The CI Swarm attacks your policy before code ships. The Runtime Swarm enforces and learns from every live tool call in production. Four feedback loops connect them so the system gets harder to bypass over time.

flowchart TB

  AI["🤖 AI Clients\nCursor · Claude Desktop · Cline"]

  subgraph CI["🔵 CI Swarm (PR + Nightly)"]
    direction LR
    Scout["🔍 Scout Agent\nSAST, deps, config scan"]
    Corpus["📋 Corpus Agent\n228 fixtures eval"]
    Evasion["⚡ Evasion Agent\n120+ probes + generate new"]
    Parity["🔄 Parity Agent\nNode vs Python"]
    ProxyA["🖥️ Proxy Agent\nLive stdio MCP tests"]
    Report["📊 Report Agent\nsecurity-swarm/latest.json"]
    Scout --> Corpus --> Evasion --> Parity --> ProxyA --> Report
  end

  subgraph Runtime["🟢 Runtime Swarm (Production Proxy)"]
    direction LR
    BG["🛡️ BlockGuard\nsync policy"]
    IL["📈 InstantLearner\nper-block stats + suggestions"]
    SA["🧠 SemanticAuditor\nasync LLM, optional"]
    PS["🔗 PatternSynthesizer\nbatch suggestions"]
    Cal["⚙️ Calibrator\nlabels + thresholds"]
    BG --> IL --> PS --> Cal
    BG --> SA --> PS
  end

  Tools["🗄️ MCP Tools\nfilesystem · GitHub · databases · APIs"]

  AI -->|"every tool call"| BG
  BG -->|"✅ allowed"| Tools
  Report -->|"🔁 Loop A: bypasses to corpus"| Corpus
  Cal -->|"🔁 Loop B: blocks to rules"| BG
  Cal -->|"🔁 Loop C: labels to LLM"| SA
  Report -->|"🔁 Loop D: CI metrics weekly"| Cal

  style CI fill:#EFF6FF,stroke:#3B82F6,stroke-width:2px,color:#1E3A5F
  style Runtime fill:#F0FDF4,stroke:#22C55E,stroke-width:2px,color:#14532D
  style Scout fill:#DBEAFE,stroke:#3B82F6,color:#1E40AF
  style Corpus fill:#DBEAFE,stroke:#3B82F6,color:#1E40AF
  style Evasion fill:#DBEAFE,stroke:#3B82F6,color:#1E40AF
  style Parity fill:#DBEAFE,stroke:#3B82F6,color:#1E40AF
  style ProxyA fill:#DBEAFE,stroke:#3B82F6,color:#1E40AF
  style Report fill:#DBEAFE,stroke:#3B82F6,color:#1E40AF
  style BG fill:#BBF7D0,stroke:#16A34A,color:#14532D
  style IL fill:#BBF7D0,stroke:#16A34A,color:#14532D
  style SA fill:#BBF7D0,stroke:#16A34A,color:#14532D
  style PS fill:#BBF7D0,stroke:#16A34A,color:#14532D
  style Cal fill:#BBF7D0,stroke:#16A34A,color:#14532D
  style AI fill:#FEF3C7,stroke:#F59E0B,stroke-width:2px,color:#78350F
  style Tools fill:#FEF3C7,stroke:#F59E0B,stroke-width:2px,color:#78350F

Canonical gates: 228/228 corpus, 0 bypasses, 100% parity

CI Swarm

Runs on every PR and nightly. Six agents work in sequence, each one hardening what the previous found.

AgentWhat it does
ScoutSAST scan, dependency audit, config review
CorpusEvaluates all 228 attack fixtures against current policy
EvasionRuns 120+ bypass probes and generates novel ones using an LLM
ParityVerifies Node and Python implementations produce identical decisions
ProxyLive stdio MCP session tests against a running proxy instance
ReportWrites security-swarm/latest.json with full results and metrics

Runtime Swarm

Runs inside the production proxy on every tool call.

ComponentWhat it does
BlockGuardEnforces the active policy synchronously on every call. Fail-closed.
InstantLearnerTracks per-block statistics and surfaces rule suggestions in real time
SemanticAuditorOptional async LLM review for calls that clear pattern checks but look suspicious
PatternSynthesizerBatches suggestions from InstantLearner and SemanticAuditor into candidate rules
CalibratorLabels candidates, tunes thresholds, and promotes approved rules back into BlockGuard

Feedback loops

LoopSignalEffect
ACI bypass foundAdded to corpus, CI now guards against it permanently
BRuntime block patternSynthesized into a new rule, promoted to BlockGuard
CCalibrator labelUsed to fine-tune SemanticAuditor thresholds
DCI metrics (weekly)Updates runtime config — keeps CI and production in sync

The proxy supports five transports: stdio, HTTP, SSE, streamable HTTP, and WebSocket.

For enterprise deployments with Redis, Postgres, and Kubernetes see docs/ENTERPRISE_DEPLOYMENT.md.


Threat Lab

Threat Lab watches live traffic and uses a local LLM to propose new attack test cases when it detects suspicious patterns. Nothing is applied automatically. You review and approve every suggestion in the dashboard before it becomes a rule.

Approved discoveries feed back into the CI attack corpus for ongoing regression testing.

ollama serve
ollama pull qwen3:8b

export OLLAMA_BASE_URL=http://127.0.0.1:11434
export MASTYF_AI_LLM_PROVIDER=ollama
export MASTYF_AI_LLM_MODEL=qwen3:8b

pnpm dashboard:proxy
image

MCP package trust scores

Before installing any MCP server from npm, check its trust score at https://www.mastyf.ai/certified. Scores cover CVE exposure, typo-squat risk, maintainer signals, and known attack patterns. Free, no account required.


Common commands

CommandWhat it does
node dist/cli.js startStart proxy and dashboard on port 4000
node dist/cli.js onboardWrap your MCP config to route through the proxy
node dist/cli.js doctorHealth check for DB, policy, and environment
node dist/cli.js scan --allScan MCP configs for CVEs and injection risks
pnpm testRun the full test suite
pnpm security-swarm:fastQuick security regression, 5 to 15 minutes
pnpm security-swarm:analyzeFull adversarial analysis

Troubleshooting

ProblemFix
Dashboard shows no dataProxy and dashboard must share the same MASTYF_AI_DB_PATH. Default is ~/.mastyf-ai/history.db
dist/cli.js not foundRun pnpm build
AI still hitting tools directlyRun node dist/cli.js onboard --apply
Ollama warnings at startupRun ollama serve or remove MASTYF_AI_LLM_PROVIDER from your environment
npm install failsnpm publish is not live yet. Use git clone and pnpm install

Learn more

Related MCP Servers

13bm/GhidraMCP

🐍 ☕ 🏠 - MCP server for integrating Ghidra with AI assistants. This plugin enables binary analysis, providing tools for function inspection, decompilation, memory exploration, and import/export analysis via the Model Context Protocol.

🔒 Security1 views
123Ergo/unphurl-mcp

📇 ☁️ - URL intelligence for AI agents. 13 tools for security signals and data quality: redirect behaviour, brand impersonation detection, domain age, SSL validation, parked detection, URL structural analysis, DNS enrichment.

🔒 Security0 views
82ch/MCP-Dandan

🐍 📇 🏠 🍎 🪟 🐧 - Real-time security framework for MCP servers that detects and blocks malicious AI agent behavior by analyzing tool call patterns and intent across multiple threat detection engines.

🔒 Security0 views
9hannahnine-jpg/arc-gate-mcp

🐍 - Runtime governance for MCP tool calls. Blocks prompt injection and capability abuse before tool results reach your agent.

🔒 Security0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it →
★ Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.