# MCPGuard Security Auditor (`zluowa/mcpguard-security-auditor`) Actor

- **URL**: https://apify.com/zluowa/mcpguard-security-auditor.md
- **Developed by:** [Shengyang Xie](https://apify.com/zluowa) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $40.00 / 1,000 repo bundle audits

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## MCPGuard — AI Agent & MCP Security Auditor

Zero-dependency deterministic security & cost gate for **MCP configurations**, **AI Agent rules / `SKILL.md` files**, **unified repository bundles**, and **autonomous agent budget/loop logs**.

Built on pure **Node.js 24 Alpine** (no headless browser, no LLM calls, no third-party network dependencies) for sub-second cold starts, deterministic findings, **Limited permissions** (`mcp.apify.com` auto-discovery ready), and **GitHub Code Scanning SARIF 2.1.0** export.

### What It Audits & Pay-Per-Event Pricing

| Action | PPE Event | Price (USD) | Capabilities |
|---|---|---:|---|
| *(Platform Start)* | `apify-actor-start` | `$0.001` | Auto-billed by Apify (covers first 5 seconds of platform compute; never manually charged by actor code). |
| `audit-repo-bundle` *(Primary)* | `repo-bundle-audit` | `$0.04` | Audits up to 100 MCP configs + Agent Rules / `SKILL.md` files in one run into a unified **0–100 Security Score**, **Grade A–F**, findings table, optional **SARIF 2.1.0**, and **GitHub PR Markdown** summary. |
| `audit-mcp` | `mcp-config-audit` | `$0.02` | Detects hardcoded vendor keys (`sk-ant-*`, OpenAI, GitHub PAT, AWS, Stripe, Slack, DB URLs), insecure HTTP/query secrets, unpinned `npx`/`uvx` packages, overbroad FS roots (`~/.ssh`, `/etc`, `/`), and privileged/unpinned Docker flags. Supports JSON & JSONC, optional secret redaction (`includeSanitized`), and SARIF 2.1.0. |
| `audit-rules` | `agent-rules-audit` | `$0.02` | Scans `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, and `SKILL.md` for Unicode Tag steganography (`U+E0000–U+E007F`), Bidi Trojan Source overrides, invisible zero-width backdoors (zero false positives on legitimate compound Emoji ZWJ), embedded secrets, piped shell/PowerShell exfiltration payloads, and Context Tax / token bloat. |
| `circuit-break` | `circuit-breaker-eval` | `$0.01` | Evaluates JSON/JSONL agent run logs against hard USD/token caps (`exitCode=2`) and zero-output ping-pong wake storms (`exitCode=3`). |

*Recommended minimum spending cap (`minimalMaxTotalChargeUsd`): `$0.05`.*

### Honest Pay-Per-Event Billing Guarantee

- **Zero false charges**: Malformed JSON/JSONC, missing required fields, unsupported actions, or oversized payloads (`> 1 MiB` / `> 100` bundle files) fail strictly **before** any custom billing event is triggered.
- **Budget ceiling respected**: Enforces `ACTOR_MAX_TOTAL_CHARGE_USD` / `APIFY_MAX_TOTAL_CHARGE_USD` (including the `$0.001` platform start event) before calling the Apify charge endpoint.
- **Idempotent billing**: Sends a deterministic `idempotency-key` per run/event/input hash to prevent duplicate charges on retries.
- **Ultra-low platform compute overhead**: Bounded to `128–256 MB` RAM on `node:24-alpine`, completing typical audits in `< 0.5s` inside the free 5-second start compute window.

### Example Input (`audit-mcp`)

```json
{
  "action": "audit-mcp",
  "sourceName": ".cursor/mcp.json",
  "mcpConfig": "{\"mcpServers\":{\"demo\":{\"command\":\"npx\",\"args\":[\"-y\",\"@modelcontextprotocol/server-filesystem\",\"/\"]}}}",
  "includeSarif": true,
  "includeSanitized": true
}
```

### Example Input (`audit-rules`)

```json
{
  "action": "audit-rules",
  "fileName": "AGENTS.md",
  "rulesContent": "# Engineering Rules\nAlways run npm test before pushing.\n",
  "maxTokens": 4000,
  "includeSarif": true
}
```

### Using via `apify-mcp-server` (Claude / Cursor / VS Code)

Because this Actor runs with **Limited permissions** and richly documented input schemas, AI agents connected to Apify's official MCP server (`https://mcp.apify.com`) automatically discover and invoke `mcpguard-security-auditor` with `action: "audit-repo-bundle"`, `"audit-mcp"`, `"audit-rules"`, or `"circuit-break"`. Results are written cleanly to both the default Dataset (`overview` view) and Key-Value Store (`OUTPUT`).

# Changelog

This Actor's version history is a separate document: https://apify.com/zluowa/mcpguard-security-auditor/changelog.md

# Actor input Schema

## `action` (type: `string`):

Choose which deterministic engine to run: audit-mcp ($0.02), audit-rules ($0.02), audit-repo-bundle ($0.04), or circuit-break ($0.01). Platform start event is $0.001 (includes 5s free compute).

## `mcpConfig` (type: `string`):

Required for action=audit-mcp. Paste raw mcp.json, claude_desktop_config.json, .cursor/mcp.json, or JSONC string (API callers may also pass a JSON object).

## `sourceName` (type: `string`):

Optional filename label used in audit-mcp findings and SARIF locations.

## `rulesContent` (type: `string`):

Required for action=audit-rules. Raw UTF-8 text of AGENTS.md, CLAUDE.md, GEMINI.md, .cursorrules, or SKILL.md.

## `fileName` (type: `string`):

Optional filename label for action=audit-rules.

## `mcpConfigs` (type: `array`):

Used by action=audit-repo-bundle. Array of { path, content } items (JSON/JSONC string or object). Combined file limit: 100 files / 1 MiB.

## `rulesFiles` (type: `array`):

Used by action=audit-repo-bundle. Array of { path, content } UTF-8 rules/SKILL.md files. Combined file limit: 100 files / 1 MiB.

## `targetName` (type: `string`):

Optional repository or PR name label for action=audit-repo-bundle.

## `rawLog` (type: `string`):

Used by action=circuit-break (alternative to records array). JSONL or JSON array of agent turn events.

## `records` (type: `array`):

Used by action=circuit-break (alternative to rawLog). Array of agent turn records with tokens, costUsd, agent, ts/at, eventType.

## `maxTokens` (type: `integer`):

Optional. For audit-rules / audit-repo-bundle: Context Bloat warning threshold (defaults to 4000 when omitted). For circuit-break: optional hard token cap (unlimited when omitted so normal runs are never false-tripped).

## `maxUsd` (type: `number`):

Hard USD spend cap for action=circuit-break (default 5.0).

## `maxPingPong` (type: `integer`):

Maximum allowed consecutive zero-revenue/zero-artifact wake events inside pingPongWindowSec before tripping exitCode=3.

## `pingPongWindowSec` (type: `integer`):

Sliding window duration in seconds for ping-pong storm detection (default 300).

## `includeSarif` (type: `boolean`):

Attach a GitHub Code Scanning compatible SARIF 2.1.0 report for audit-mcp, audit-rules, or audit-repo-bundle.

## `includeMarkdown` (type: `boolean`):

Attach a ready-to-post GitHub PR Markdown report (action=audit-repo-bundle).

## `includeSanitized` (type: `boolean`):

Attach secret-redacted MCP config (audit-mcp) or invisibles-stripped rules text (audit-rules).

## Actor input object example

```json
{
  "action": "audit-mcp",
  "mcpConfig": "{\n  \"mcpServers\": {\n    \"demo\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-memory@1.0.0\"]\n    }\n  }\n}",
  "sourceName": "mcp.json",
  "fileName": "AGENTS.md",
  "targetName": "repo-bundle",
  "maxUsd": 5,
  "maxPingPong": 4,
  "pingPongWindowSec": 300,
  "includeSarif": false,
  "includeMarkdown": false,
  "includeSanitized": false
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `fullReport` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "action": "audit-mcp",
    "mcpConfig": `{
  "mcpServers": {
    "demo": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory@1.0.0"]
    }
  }
}`
};

// Run the Actor and wait for it to finish
const run = await client.actor("zluowa/mcpguard-security-auditor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "action": "audit-mcp",
    "mcpConfig": """{
  \"mcpServers\": {
    \"demo\": {
      \"command\": \"npx\",
      \"args\": [\"-y\", \"@modelcontextprotocol/server-memory@1.0.0\"]
    }
  }
}""",
}

# Run the Actor and wait for it to finish
run = client.actor("zluowa/mcpguard-security-auditor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "action": "audit-mcp",
  "mcpConfig": "{\\n  \\"mcpServers\\": {\\n    \\"demo\\": {\\n      \\"command\\": \\"npx\\",\\n      \\"args\\": [\\"-y\\", \\"@modelcontextprotocol/server-memory@1.0.0\\"]\\n    }\\n  }\\n}"
}' |
apify call zluowa/mcpguard-security-auditor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zluowa/mcpguard-security-auditor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/SCubXEESZ0AgujDQB/builds/rE0ZVM6ebGRqh334j/openapi.json
