Skip to main content
Glama
mcp-rugpull-sentinel

mcp-rugpull-sentinel

by Yoggurin
README.md
# MCP Rug-Pull Sentinel (`mcp-rugpull-sentinel`)

**Anti-Tool-Poisoning & Anti-Rug-Pull Security Suite for Model Context Protocol (MCP) Servers.**

Protects AI agents (Claude, Cursor, VS Code, Antigravity, Windsurf) from delayed `tools/list` mutations and hidden prompt-injection attacks using:
1. **GitHub Marketplace Action (`action.yml`)**: Audits `mcp_config.json` / `.mcp.json`, pins deterministic SHA-256 hashes in `mcp-lock.json`, and blocks CI/PR merges on hidden prompt injections or schema drift.
2. **Cloudflare Workers Hourly Watchdog (`0 * * * *`)**: Monitors remote MCP endpoints every hour, stores baselines in Cloudflare D1 (`migrations/0001_init.sql`) or KV (`SENTINEL_KV`), analyzes diffs with **Gemini AI**, and sends immediate Slack/Discord/HTTP webhook alerts.
3. **Interactive MCP Apps UI (`ui://sentinel/diff-inspector.html`)**: Implements `io.modelcontextprotocol/ui` (`text/html;profile=mcp-app`) plus a standalone `/mcp-app.html` inspector and `/mcp` Streamable HTTP endpoint.
4. **Paddle Billing SaaS (`29 €/mes` Pro & `59 €/mes` Team)**: HMAC-SHA256 verified `/api/webhooks/paddle` and Paddle.js v2 checkout integration.

## Quickstart: GitHub Action

```yaml
- uses: Yoggurin/mcp-rugpull-sentinel@v1
  with:
    config-path: .mcp.json
    lockfile-path: mcp-lock.json
    mode: verify
    fail-on-severity: high
    fail-on-drift: 'true'
    gemini-api-key: ${{ secrets.GEMINI_API_KEY }}
```

### Inputs

| Input | Description | Required | Default |
| :--- | :--- | :---: | :--- |
| `config-path` | Path to `mcp_config.json` or `.mcp.json` (auto-discovered if omitted) | `false` | `''` |
| `lockfile-path` | Path to deterministic `mcp-lock.json` | `false` | `mcp-lock.json` |
| `mode` | Execution mode: `verify` (CI/PR gate), `update` (generate `mcp-lock.json`), or `scan` (no lockfile) | `false` | `verify` |
| `fail-on-severity` | Minimum finding severity that fails the workflow: `low`, `medium`, `high`, `critical`, `none` | `false` | `high` |
| `fail-on-drift` | Fail CI/PR when any tool hash differs from `mcp-lock.json` (`true`/`false`) | `false` | `'true'` |
| `gemini-api-key` | Optional Gemini API key for AI forensic diff analysis | `false` | `''` |
| `alert-webhook-url` | Optional Slack, Discord, or HTTP webhook URL for immediate drift alerts | `false` | `''` |

### Outputs

| Output | Description |
| :--- | :--- |
| `passed` | `true` if no policy violations were detected |
| `drift_detected` | `true` if any tool mutated, was added, or was removed compared to `mcp-lock.json` |
| `injection_detected` | `true` if prompt injection or tool poisoning indicators were found |
| `max_severity` | Highest severity observed (`none`, `low`, `medium`, `high`, `critical`) |
| `drifts_count` | Number of drifted tools |
| `findings_count` | Number of prompt injection findings |

Generate or update `mcp-lock.json` locally:

```bash
node dist/action/index.cjs --config .mcp.json --lockfile mcp-lock.json --mode update
```

## Development, Build & Live Verification

```bash
npm install
npm run build
npm run test:live
```

`npm run test:live` boots a real local mutating MCP server (`tests/mock-mutating-mcp-server.ts`) and webhook receiver, verifies GitHub Action `update` / `verify` / CI block on rug-pull mutation, tests the Worker hourly watchdog + D1 SQL adapter + MCP Apps `/mcp` + Paddle HMAC-SHA256 webhook, and optionally checks `DEPLOYED_WORKER_URL`.

## Cloudflare Deployment

```bash
# Default (KV + Cron + Assets)
npx wrangler deploy

# Optional D1 SQL backend (requires D1:Edit token scope)
./scripts/setup-d1.ps1
```