@mcp-guardian/server 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +373 -136
- package/dist/auth/auth-types.d.ts +40 -0
- package/dist/auth/auth-types.d.ts.map +1 -0
- package/dist/auth/auth-types.js +5 -0
- package/dist/auth/auth-types.js.map +1 -0
- package/dist/auth/oauth.d.ts +25 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +96 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/session-cache.d.ts +47 -0
- package/dist/auth/session-cache.d.ts.map +1 -0
- package/dist/auth/session-cache.js +91 -0
- package/dist/auth/session-cache.js.map +1 -0
- package/dist/cli.js +48 -3
- package/dist/cli.js.map +1 -1
- package/dist/database/database-interface.d.ts +17 -0
- package/dist/database/database-interface.d.ts.map +1 -0
- package/dist/database/database-interface.js +2 -0
- package/dist/database/database-interface.js.map +1 -0
- package/dist/database/history-db.d.ts.map +1 -1
- package/dist/database/history-db.js.map +1 -1
- package/dist/database/postgres-db.d.ts +18 -0
- package/dist/database/postgres-db.d.ts.map +1 -0
- package/dist/database/postgres-db.js +118 -0
- package/dist/database/postgres-db.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/policy/policy-engine.d.ts +19 -0
- package/dist/policy/policy-engine.d.ts.map +1 -0
- package/dist/policy/policy-engine.js +108 -0
- package/dist/policy/policy-engine.js.map +1 -0
- package/dist/policy/policy-types.d.ts +51 -0
- package/dist/policy/policy-types.d.ts.map +1 -0
- package/dist/policy/policy-types.js +5 -0
- package/dist/policy/policy-types.js.map +1 -0
- package/dist/policy/policy-watcher.d.ts +24 -0
- package/dist/policy/policy-watcher.d.ts.map +1 -0
- package/dist/policy/policy-watcher.js +68 -0
- package/dist/policy/policy-watcher.js.map +1 -0
- package/dist/proxy/proxy-manager.d.ts +5 -1
- package/dist/proxy/proxy-manager.d.ts.map +1 -1
- package/dist/proxy/proxy-manager.js +12 -3
- package/dist/proxy/proxy-manager.js.map +1 -1
- package/dist/proxy/proxy-server.d.ts +25 -5
- package/dist/proxy/proxy-server.d.ts.map +1 -1
- package/dist/proxy/proxy-server.js +239 -12
- package/dist/proxy/proxy-server.js.map +1 -1
- package/dist/utils/circuit-breaker.d.ts +29 -0
- package/dist/utils/circuit-breaker.d.ts.map +1 -0
- package/dist/utils/circuit-breaker.js +81 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/dist/utils/structured-logger.d.ts +47 -0
- package/dist/utils/structured-logger.d.ts.map +1 -0
- package/dist/utils/structured-logger.js +48 -0
- package/dist/utils/structured-logger.js.map +1 -0
- package/package.json +18 -8
package/README.md
CHANGED
|
@@ -1,52 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🛡️ MCP Guardian
|
|
2
2
|
|
|
3
3
|
**Security, cost, and health audit for MCP infrastructure.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@mcp-guardian/server)
|
|
7
6
|
[](https://www.typescriptlang.org/)
|
|
8
7
|
[](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
9
8
|
[](LICENSE)
|
|
10
9
|
[](https://github.com/rudraneel93/mcp-guardian/actions/workflows/ci.yml)
|
|
11
10
|
|
|
11
|
+
MCP Guardian scans your [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) servers for security vulnerabilities, tracks real token costs via a proxy interceptor, and monitors health metrics. It works as both an **MCP server** (so AI assistants like Cline/Claude can invoke its tools) and a **standalone CLI**.
|
|
12
|
+
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
## Table of Contents
|
|
15
16
|
|
|
17
|
+
- [Why MCP Guardian?](#why-mcp-guardian)
|
|
16
18
|
- [Features](#features)
|
|
17
19
|
- [Installation](#installation)
|
|
18
20
|
- [Quick Start](#quick-start)
|
|
19
21
|
- [Proxy Workflow (Real Cost Tracking)](#proxy-workflow-real-cost-tracking)
|
|
22
|
+
- [One-Off Scan](#one-off-scan)
|
|
20
23
|
- [CLI Reference](#cli-reference)
|
|
21
|
-
- [mcp-guardian proxy](#mcp-guardian-proxy)
|
|
22
|
-
- [
|
|
23
|
-
- [mcp-guardian
|
|
24
|
-
- [mcp-guardian
|
|
25
|
-
- [mcp-guardian
|
|
26
|
-
- [
|
|
24
|
+
- [`mcp-guardian proxy`](#mcp-guardian-proxy)
|
|
25
|
+
- [Policy Engine (v0.4+)](#policy-engine-v04)
|
|
26
|
+
- [`mcp-guardian scan`](#mcp-guardian-scan)
|
|
27
|
+
- [`mcp-guardian audit`](#mcp-guardian-audit)
|
|
28
|
+
- [`mcp-guardian health`](#mcp-guardian-health)
|
|
29
|
+
- [`mcp-guardian report`](#mcp-guardian-report)
|
|
30
|
+
- [MCP Server (AI Assistant Integration)](#mcp-server-ai-assistant-integration)
|
|
31
|
+
- [Available Tools](#available-tools)
|
|
32
|
+
- [Available Resources & Prompts](#available-resources--prompts)
|
|
27
33
|
- [CI/CD Integration](#cicd-integration)
|
|
34
|
+
- [Production Deployment (K8s + Helm)](#production-deployment-k8s--helm)
|
|
35
|
+
- [Docker](#docker)
|
|
28
36
|
- [Architecture](#architecture)
|
|
37
|
+
- [Data Flow (Proxy → DB → Audit)](#data-flow-proxy--db--audit)
|
|
29
38
|
- [Config Discovery](#config-discovery)
|
|
30
|
-
- [Security Scoring](#security-scoring-model)
|
|
39
|
+
- [Security Scoring Model](#security-scoring-model)
|
|
31
40
|
- [Pricing Models](#pricing-models)
|
|
32
41
|
- [Environment Variables](#environment-variables)
|
|
33
42
|
- [Development](#development)
|
|
43
|
+
- [SECURITY.md](#securitymd)
|
|
44
|
+
- [FAQ](#faq)
|
|
34
45
|
- [Roadmap](#roadmap)
|
|
35
46
|
- [License](#license)
|
|
36
47
|
|
|
37
48
|
---
|
|
38
49
|
|
|
50
|
+
## Why MCP Guardian?
|
|
51
|
+
|
|
52
|
+
As MCP adoption grows, so does the attack surface. MCP servers run arbitrary commands, access filesystems, make network calls, and handle sensitive data — often with zero visibility into their security posture or operational cost.
|
|
53
|
+
|
|
54
|
+
MCP Guardian provides:
|
|
55
|
+
|
|
56
|
+
- **Active policy enforcement (v0.4+)** — YAML-configurable policy engine that blocks, flags, or passes every `tools/call` in real time based on tool allowlists/denylists, regex patterns, rate limits, and token budgets
|
|
57
|
+
- **Security auditing** — CVE scanning (OSV.dev + NVD), hardcoded secret detection, typo-squatting detection, command injection detection, and TLS validation
|
|
58
|
+
- **Real cost tracking** — Proxy interceptor that captures actual `tools/call` traffic and counts tokens via `tiktoken` (o200k_base encoding) — no estimates, no mocks
|
|
59
|
+
- **Health monitoring** — Live JSON-RPC 2.0 handshake probes with latency, success rate, tool count, and context pressure analysis
|
|
60
|
+
- **Agent-native** — Runs as an MCP server so your AI assistant can self-audit its own infrastructure
|
|
61
|
+
- **Enterprise SIEM logging (v0.4+)** — Structured JSON logs via pino with request-ID tracing, policy decision audit trails, and block events at WARN level
|
|
62
|
+
- **Session-based replay protection (v0.6.0)** — Short-lived 5-min session tokens prevent JWT replay attacks. Nonce tracking detects token reuse
|
|
63
|
+
- **Hot-reload policies (v0.6.0)** — File watcher atomically swaps policy engine on YAML changes — no restart needed
|
|
64
|
+
- **Circuit breaker (v0.5.2)** — 3-state circuit breaker protects upstream MCP servers from cascading failures
|
|
65
|
+
- **OAuth 2.1 / OIDC (v0.5.0)** — JWT validation with OIDC Discovery, bearer token extraction, agent identity mapping
|
|
66
|
+
- **RBAC (v0.5.1)** — Scope-based and client-ID-based access control in policy engine
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
39
70
|
## Features
|
|
40
71
|
|
|
41
72
|
### 🔒 Security Scan (`scan_security`)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
73
|
+
|
|
74
|
+
| Check | Description |
|
|
75
|
+
|---|---|
|
|
76
|
+
| **CVE Checking** | Queries [OSV.dev](https://osv.dev) (purl-based) and [NIST NVD](https://nvd.nist.gov) for known vulnerabilities. Rate-limited (5 req/min without API key, 20 req/min with key) |
|
|
77
|
+
| **Auth Probing** | Detects missing authentication via env vars (`API_KEY`, `AUTH_TOKEN`, etc.) and URL credentials |
|
|
78
|
+
| **Transport Security** | Flags unencrypted transports (HTTP, WS) and validates TLS certificates (expiry, issuer, validity) |
|
|
79
|
+
| **Typo-Squat Detection** | Levenshtein distance matching against 24 known official MCP packages |
|
|
80
|
+
| **Secret Scanning** | 6 regex patterns for hardcoded API keys, tokens, private keys, passwords, GitHub tokens, OpenAI keys |
|
|
81
|
+
| **Command Validation** | Flags dangerous patterns (path traversal, shell chaining, `rm -rf`, `curl`/`wget` in commands, and more) |
|
|
82
|
+
| **🔴 Active Policy Engine (v0.4+)** | YAML-configurable rules: tool allowlist/denylist, regex pattern blocking, rate limiting, token budgets. Operates in `audit` (passive), `warn` (flag only), or `block` (active enforcement) modes |
|
|
83
|
+
| **Scoring** | Weighted 0–100 security score with actionable recommendations |
|
|
84
|
+
|
|
85
|
+
### 💰 Cost Audit (`audit_costs`)
|
|
86
|
+
|
|
50
87
|
- **Proxy Interceptor** — `mcp-guardian proxy` sits between your AI client and MCP servers, capturing every `tools/call` request/response
|
|
51
88
|
- **Real Token Counting** — Uses `tiktoken` (o200k_base encoding) on actual JSON-RPC traffic — no hardcoded estimates
|
|
52
89
|
- **Multi-Model Pricing** — 97 models across 17 providers (OpenAI, Anthropic, Google, DeepSeek, xAI, Meta, Mistral, and more)
|
|
@@ -54,28 +91,41 @@ MCP Guardian scans your Model Context Protocol (MCP) servers for security vulner
|
|
|
54
91
|
- **Custom Pricing** — Override via `PRICING_OVERRIDES` env var: `{"my-model": {"input": 2.0, "output": 6.0}}`
|
|
55
92
|
|
|
56
93
|
### ❤️ Health Monitor (`check_health`)
|
|
94
|
+
|
|
57
95
|
- **Live Probes** — Full JSON-RPC 2.0 handshake (initialize → initialized → `tools/list`) with request/response correlation
|
|
58
96
|
- **SSE Probing** — Multi-path discovery (`/`, `/sse`, `/message`) with auth header injection and timeout handling
|
|
59
97
|
- **Latency Tracking** — End-to-end latency per server with historical success rates from SQLite
|
|
60
98
|
- **Overload Detection** — Warns when >15 tools exposed; context pressure estimation
|
|
61
99
|
|
|
62
100
|
### 📊 Full Report (`full_report`)
|
|
101
|
+
|
|
63
102
|
- **Three Output Formats** — Colored text, Markdown tables, structured JSON (with `resource` MIME type for agent consumption)
|
|
64
103
|
- **Overall Score** — Composite security + health score (0–100)
|
|
65
|
-
- **Database Storage** — All scans, costs, health checks, and proxy-captured call records persisted in SQLite
|
|
104
|
+
- **Database Storage** — All scans, costs, health checks, and proxy-captured call records persisted in SQLite (4 tables, batched writes)
|
|
66
105
|
|
|
67
106
|
### 🔧 Production Features
|
|
107
|
+
|
|
68
108
|
- **Dependency Injection** — IoC container (`src/container.ts`) for testability and runtime swaps
|
|
69
109
|
- **Rate Limiting** — Token-bucket rate limiter on OSV.dev and NVD API calls
|
|
70
110
|
- **Graceful Shutdown** — SIGINT/SIGTERM handlers flush DB and close connections
|
|
71
111
|
- **Batched DB Writes** — 1s debounced flush reduces I/O by 10x
|
|
72
112
|
- **Alert Thresholds** — 6 CLI flags with exit codes 1/2 for CI/CD integration
|
|
73
|
-
- **GitHub Actions CI** — Node 18/20/22 matrix,
|
|
113
|
+
- **GitHub Actions CI** — Node 18/20/22 matrix, 74 tests across 11 suites
|
|
74
114
|
|
|
75
115
|
---
|
|
76
116
|
|
|
77
117
|
## Installation
|
|
78
118
|
|
|
119
|
+
### From npm (recommended)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm install -g @mcp-guardian/server
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
After global install, the `mcp-guardian` command is available in your PATH.
|
|
126
|
+
|
|
127
|
+
### From source
|
|
128
|
+
|
|
79
129
|
```bash
|
|
80
130
|
git clone https://github.com/rudraneel93/mcp-guardian.git
|
|
81
131
|
cd mcp-guardian
|
|
@@ -83,7 +133,7 @@ npm install
|
|
|
83
133
|
npm run build
|
|
84
134
|
```
|
|
85
135
|
|
|
86
|
-
**Requirements:** Node.js ≥18, npm ≥9
|
|
136
|
+
**Requirements:** Node.js ≥ 18, npm ≥ 9
|
|
87
137
|
|
|
88
138
|
---
|
|
89
139
|
|
|
@@ -108,6 +158,7 @@ mcp-guardian report --config ./cline_mcp_settings.json
|
|
|
108
158
|
```
|
|
109
159
|
|
|
110
160
|
**Example output (real data from proxy against 3 MCP servers):**
|
|
161
|
+
|
|
111
162
|
```
|
|
112
163
|
💰 Cost Audit
|
|
113
164
|
github: 194 tokens, $0.0018 (gpt-4o)
|
|
@@ -128,57 +179,22 @@ puppeteer - Score: D (10) — 3 CVEs (1 critical), needs auth
|
|
|
128
179
|
Overall Score: 60/100
|
|
129
180
|
```
|
|
130
181
|
|
|
131
|
-
> **Important:** The cost audit will show `$0.0000` until the proxy has been running and captured real `tools/call` traffic. This is not a bug — the `call_records` table starts empty.
|
|
132
|
-
|
|
133
|
-
---
|
|
182
|
+
> **Important:** The cost audit will show `$0.0000` until the proxy has been running and captured real `tools/call` traffic. This is not a bug — the `call_records` table starts empty.
|
|
134
183
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
To verify the full pipeline works end-to-end with real data (no mocks):
|
|
184
|
+
### One-Off Scan
|
|
138
185
|
|
|
139
186
|
```bash
|
|
140
|
-
#
|
|
141
|
-
mcp-guardian
|
|
142
|
-
|
|
143
|
-
# Terminal 2: Run your AI workflows (or pipe test calls)
|
|
144
|
-
|
|
145
|
-
# Terminal 1: Ctrl+C when done, then:
|
|
146
|
-
mcp-guardian audit --config ./cline_mcp_settings.json
|
|
147
|
-
mcp-guardian report --config ./cline_mcp_settings.json
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
**Verified results** (proxy wrapping 3 real MCP servers — github, filesystem, puppeteer):
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
💰 Cost Audit (real data from live proxy run)
|
|
154
|
-
github: 194 tokens, $0.0018 (gpt-4o)
|
|
155
|
-
search_repositories: 66 tokens, 1 call, $0.0006
|
|
156
|
-
list_directory: 63 tokens, 1 call, $0.0006
|
|
157
|
-
read_file: 65 tokens, 1 call, $0.0006
|
|
158
|
-
|
|
159
|
-
filesystem: 245 tokens, $0.0026 (gpt-4o)
|
|
160
|
-
search_repositories: 81 tokens, 1 call, $0.0008
|
|
161
|
-
list_directory: 80 tokens, 1 call, $0.0009
|
|
162
|
-
read_file: 84 tokens, 1 call, $0.0009
|
|
163
|
-
|
|
164
|
-
puppeteer: 216 tokens, $0.0021 (gpt-4o)
|
|
165
|
-
search_repositories: 74 tokens, 1 call, $0.0007
|
|
166
|
-
list_directory: 70 tokens, 1 call, $0.0007
|
|
167
|
-
read_file: 72 tokens, 1 call, $0.0007
|
|
168
|
-
|
|
169
|
-
Total across 3 servers: 655 tokens, $0.0065
|
|
187
|
+
# Quick security scan on auto-discovered configs
|
|
188
|
+
mcp-guardian scan
|
|
170
189
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
filesystem: C (50) — 20 CVEs (1 high), needs auth
|
|
174
|
-
puppeteer: D (10) — 3 CVEs (1 critical), needs auth
|
|
190
|
+
# Scan with thresholds for CI
|
|
191
|
+
mcp-guardian scan --config ./cline_mcp_settings.json --fail-on-critical --fail-on-secrets --threshold-score 70
|
|
175
192
|
|
|
176
|
-
|
|
177
|
-
github
|
|
178
|
-
filesystem: 1253ms, 14 tools ✅ healthy
|
|
179
|
-
puppeteer: 1275ms, 7 tools ✅ healthy
|
|
193
|
+
# Check health
|
|
194
|
+
mcp-guardian health --server github-server --fail-on-overload --threshold-latency 2000
|
|
180
195
|
|
|
181
|
-
|
|
196
|
+
# Generate a Markdown report for documentation
|
|
197
|
+
mcp-guardian report --format markdown --output audit-report.md
|
|
182
198
|
```
|
|
183
199
|
|
|
184
200
|
---
|
|
@@ -187,21 +203,68 @@ Overall Score: 60/100
|
|
|
187
203
|
|
|
188
204
|
### `mcp-guardian proxy`
|
|
189
205
|
|
|
190
|
-
Start the MCP proxy interceptor
|
|
206
|
+
Start the MCP proxy interceptor with optional active policy enforcement.
|
|
191
207
|
|
|
192
208
|
```bash
|
|
209
|
+
# Audit-only (passive)
|
|
193
210
|
mcp-guardian proxy --config ./cline_mcp_settings.json
|
|
194
|
-
```
|
|
195
211
|
|
|
196
|
-
|
|
212
|
+
# Active blocking with default policy
|
|
213
|
+
mcp-guardian proxy --config ./cline_mcp_settings.json --policy ./default-policy.yaml
|
|
214
|
+
|
|
215
|
+
# Active blocking with custom policy + mode override
|
|
216
|
+
mcp-guardian proxy --config ./cline_mcp_settings.json --policy ./my-policy.yaml --blocking-mode block
|
|
217
|
+
```
|
|
197
218
|
|
|
198
219
|
| Option | Description |
|
|
199
|
-
|
|
220
|
+
|---|---|
|
|
200
221
|
| `-c, --config <path>` | Path to MCP config file |
|
|
222
|
+
| `--policy <path>` | Path to policy YAML file (enables active blocking) |
|
|
223
|
+
| `--blocking-mode <mode>` | Override policy mode: `audit` (passive), `warn` (flag), `block` (enforce) |
|
|
224
|
+
|
|
225
|
+
### Policy Engine (v0.4+)
|
|
226
|
+
|
|
227
|
+
The policy engine evaluates every intercepted `tools/call` before it reaches the MCP server. Define rules in YAML:
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
# my-policy.yaml
|
|
231
|
+
version: "1.0"
|
|
232
|
+
policy:
|
|
233
|
+
mode: block
|
|
234
|
+
rules:
|
|
235
|
+
- name: "deny-shell-tools"
|
|
236
|
+
action: block
|
|
237
|
+
tools: { deny: ["execute_command", "bash", "sh", "eval", "exec"] }
|
|
238
|
+
- name: "block-injection"
|
|
239
|
+
action: block
|
|
240
|
+
patterns:
|
|
241
|
+
- "rm\\s+-rf"
|
|
242
|
+
- "curl\\s|wget\\s"
|
|
243
|
+
- ";\\s*\\w"
|
|
244
|
+
- "&&|\\|\\|"
|
|
245
|
+
- name: "rate-limit"
|
|
246
|
+
action: flag
|
|
247
|
+
maxCallsPerMinute: 60
|
|
248
|
+
- name: "token-budget"
|
|
249
|
+
action: flag
|
|
250
|
+
maxTokens: 50000
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Blocked calls** return a JSON-RPC 2.0 error to the client:
|
|
254
|
+
```json
|
|
255
|
+
{"jsonrpc":"2.0","id":"abc-123","error":{"code":-32001,"message":"Blocked by MCP Guardian policy: Tool 'execute_command' is explicitly denied"}}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Policy modes:**
|
|
259
|
+
| Mode | Behavior |
|
|
260
|
+
|---|---|
|
|
261
|
+
| `audit` | Pass all calls; log decisions only (passive) |
|
|
262
|
+
| `warn` | Downgrade `block` actions to `flag`; log warnings |
|
|
263
|
+
| `block` | Full active enforcement — blocked calls never reach the MCP server |
|
|
201
264
|
|
|
202
265
|
### `mcp-guardian scan`
|
|
203
266
|
|
|
204
|
-
Run security scan on MCP servers.
|
|
267
|
+
Run security scan on MCP servers.
|
|
205
268
|
|
|
206
269
|
```bash
|
|
207
270
|
mcp-guardian scan
|
|
@@ -210,8 +273,8 @@ mcp-guardian scan --all --threshold-score 70
|
|
|
210
273
|
```
|
|
211
274
|
|
|
212
275
|
| Option | Description |
|
|
213
|
-
|
|
214
|
-
| `-c, --config <path>` | Path to MCP config file |
|
|
276
|
+
|---|---|
|
|
277
|
+
| `-c, --config <path>` | Path to an MCP config file |
|
|
215
278
|
| `-a, --all` | Aggregate all discoverable configs |
|
|
216
279
|
| `--threshold-score <n>` | Exit code 2 if any server score drops below `n` |
|
|
217
280
|
| `--fail-on-critical` | Exit code 1 if any critical CVE found |
|
|
@@ -228,8 +291,8 @@ mcp-guardian audit --threshold-cost 0.50
|
|
|
228
291
|
```
|
|
229
292
|
|
|
230
293
|
| Option | Description |
|
|
231
|
-
|
|
232
|
-
| `-c, --config <path>` | Path to MCP config file |
|
|
294
|
+
|---|---|
|
|
295
|
+
| `-c, --config <path>` | Path to an MCP config file |
|
|
233
296
|
| `-a, --all` | Aggregate all discoverable configs |
|
|
234
297
|
| `-s, --server <name>` | Filter to a specific server |
|
|
235
298
|
| `--threshold-cost <n>` | Exit code 2 if total cost exceeds `n` USD |
|
|
@@ -245,8 +308,8 @@ mcp-guardian health --threshold-latency 2000 --fail-on-overload
|
|
|
245
308
|
```
|
|
246
309
|
|
|
247
310
|
| Option | Description |
|
|
248
|
-
|
|
249
|
-
| `-c, --config <path>` | Path to MCP config file |
|
|
311
|
+
|---|---|
|
|
312
|
+
| `-c, --config <path>` | Path to an MCP config file |
|
|
250
313
|
| `-a, --all` | Aggregate all discoverable configs |
|
|
251
314
|
| `-s, --server <name>` | Filter to a specific server |
|
|
252
315
|
| `--threshold-latency <ms>` | Exit code 2 if any server exceeds latency threshold |
|
|
@@ -264,18 +327,32 @@ mcp-guardian report --all --threshold-score 60
|
|
|
264
327
|
```
|
|
265
328
|
|
|
266
329
|
| Option | Description |
|
|
267
|
-
|
|
268
|
-
| `-c, --config <path>` | Path to MCP config file |
|
|
330
|
+
|---|---|
|
|
331
|
+
| `-c, --config <path>` | Path to an MCP config file |
|
|
269
332
|
| `-a, --all` | Aggregate all discoverable configs |
|
|
270
|
-
| `-f, --format <fmt>` | Output format: `text
|
|
333
|
+
| `-f, --format <fmt>` | Output format: `text` (default), `markdown`, or `json` |
|
|
334
|
+
| `--output <path>` | Save report to a file instead of stdout |
|
|
271
335
|
| `--threshold-score <n>` | Exit code 2 if overall score drops below `n` |
|
|
272
336
|
|
|
273
337
|
---
|
|
274
338
|
|
|
275
|
-
## MCP Server (
|
|
339
|
+
## MCP Server (AI Assistant Integration)
|
|
276
340
|
|
|
277
341
|
Add to your `cline_mcp_settings.json` or `claude_desktop_config.json`:
|
|
278
342
|
|
|
343
|
+
```json
|
|
344
|
+
{
|
|
345
|
+
"mcpServers": {
|
|
346
|
+
"mcp-guardian": {
|
|
347
|
+
"command": "npx",
|
|
348
|
+
"args": ["-y", "@mcp-guardian/server"]
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Or with a local install:
|
|
355
|
+
|
|
279
356
|
```json
|
|
280
357
|
{
|
|
281
358
|
"mcpServers": {
|
|
@@ -287,30 +364,103 @@ Add to your `cline_mcp_settings.json` or `claude_desktop_config.json`:
|
|
|
287
364
|
}
|
|
288
365
|
```
|
|
289
366
|
|
|
290
|
-
|
|
367
|
+
### Available Tools
|
|
291
368
|
|
|
292
369
|
| Tool | Parameters | Description |
|
|
293
|
-
|
|
294
|
-
| `scan_security` | `configPath?` | Scan MCP configs for CVEs, auth gaps, typo-squatting,
|
|
370
|
+
|---|---|---|
|
|
371
|
+
| `scan_security` | `configPath?` | Scan MCP configs for CVEs, auth gaps, typo-squatting, hardcoded secrets, and dangerous commands |
|
|
295
372
|
| `audit_costs` | `serverName?` | Estimate token usage and costs per server with multi-model pricing |
|
|
296
373
|
| `check_health` | `serverName?` | Check latency, success rate, tool count, and context pressure |
|
|
297
|
-
| `full_report` | `configPath?`, `format?` (json\|markdown\|text) | Generate complete audit report |
|
|
374
|
+
| `full_report` | `configPath?`, `format?` (json\|markdown\|text) | Generate complete audit report in any format |
|
|
298
375
|
|
|
299
|
-
JSON format reports also include a structured `resource` content type
|
|
376
|
+
JSON format reports also include a structured `resource` content type (MIME: `application/json`) so AI assistants can consume reports programmatically.
|
|
377
|
+
|
|
378
|
+
### Available Resources & Prompts
|
|
379
|
+
|
|
380
|
+
- **Resource:** `mcp-guardian://latest-scan` — exposes the most recent security scan as structured JSON
|
|
381
|
+
- **Prompt:** `audit-config` — generates structured audit instructions for an MCP config path, which the assistant can use to guide its investigation
|
|
300
382
|
|
|
301
383
|
---
|
|
302
384
|
|
|
303
385
|
## CI/CD Integration
|
|
304
386
|
|
|
305
|
-
Run in
|
|
387
|
+
Run MCP Guardian in CI to catch issues before deployment:
|
|
306
388
|
|
|
307
389
|
```yaml
|
|
308
390
|
- name: MCP Guardian Security Scan
|
|
309
|
-
run: npx mcp-guardian scan --config ./cline_mcp_settings.json --fail-on-critical --fail-on-secrets
|
|
391
|
+
run: npx @mcp-guardian/server scan --config ./cline_mcp_settings.json --fail-on-critical --fail-on-secrets
|
|
310
392
|
env:
|
|
311
393
|
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
|
|
394
|
+
|
|
395
|
+
- name: MCP Guardian Cost Audit
|
|
396
|
+
run: npx @mcp-guardian/server audit --all --threshold-cost 0.50
|
|
397
|
+
|
|
398
|
+
- name: MCP Guardian Health Check
|
|
399
|
+
run: npx @mcp-guardian/server health --all --threshold-latency 3000 --fail-on-overload
|
|
312
400
|
```
|
|
313
401
|
|
|
402
|
+
### Exit Codes
|
|
403
|
+
|
|
404
|
+
| Code | Meaning |
|
|
405
|
+
|---|---|
|
|
406
|
+
| 0 | All checks passed within thresholds |
|
|
407
|
+
| 1 | Critical security issue found (critical CVE, secret, overload) |
|
|
408
|
+
| 2 | Threshold exceeded (score, cost, or latency below/above limit) |
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## Production Deployment (K8s + Helm)
|
|
413
|
+
|
|
414
|
+
See the full guide at **[deploy/PRODUCTION.md](deploy/PRODUCTION.md)**.
|
|
415
|
+
|
|
416
|
+
### Quick Helm Install
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# Install from local chart
|
|
420
|
+
helm install mcp-guardian ./deploy/helm/mcp-guardian \
|
|
421
|
+
--set config.policy.mode=block \
|
|
422
|
+
--set config.mcpConfigPath=/etc/mcp-guardian/cline_mcp_settings.json
|
|
423
|
+
|
|
424
|
+
# Or from the repo (future)
|
|
425
|
+
helm repo add mcp-guardian https://rudraneel93.github.io/mcp-guardian
|
|
426
|
+
helm install mcp-guardian mcp-guardian/mcp-guardian
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Key Features
|
|
430
|
+
- **Helm chart** with ConfigMap-backed policies, PVC persistence, and safe defaults
|
|
431
|
+
- **Fail-closed** by default (block traffic if proxy crashes) — configurable to fail-open
|
|
432
|
+
- **Sidecar injection pattern** documented for stdio MCP servers
|
|
433
|
+
- **Scaling guide** with CPU/memory recommendations per traffic level
|
|
434
|
+
- **Pod Disruption Budget** for HA, anti-affinity for multi-AZ
|
|
435
|
+
- **SIEM integration** via pino structured JSON logs (Splunk, Datadog, Elasticsearch)
|
|
436
|
+
|
|
437
|
+
### Performance Overhead
|
|
438
|
+
|
|
439
|
+
| Scenario | p50 | p99 | Overhead |
|
|
440
|
+
|----------|-----|-----|----------|
|
|
441
|
+
| Direct MCP (no proxy) | 5ms | 7ms | — |
|
|
442
|
+
| Proxy (no policy) | 27ms | 77ms | +25.78ms |
|
|
443
|
+
| Proxy (blocking policy) | 27ms | 74ms | +25.93ms |
|
|
444
|
+
|
|
445
|
+
Policy engine adds **~0.15ms** — negligible. The ~26ms is Node.js child process stdio overhead.
|
|
446
|
+
|
|
447
|
+
## Docker
|
|
448
|
+
|
|
449
|
+
A Docker image is available for running the proxy in containerized environments.
|
|
450
|
+
|
|
451
|
+
```bash
|
|
452
|
+
# Build
|
|
453
|
+
docker build -t mcp-guardian .
|
|
454
|
+
|
|
455
|
+
# Run proxy
|
|
456
|
+
docker run -i \
|
|
457
|
+
-v $(pwd)/cline_mcp_settings.json:/app/cline_mcp_settings.json \
|
|
458
|
+
-v mcp-guardian-db:/root/.mcp-guardian \
|
|
459
|
+
mcp-guardian --config /app/cline_mcp_settings.json
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
The `Dockerfile` uses `node:20-alpine` and runs `mcp-guardian proxy` as the default entrypoint.
|
|
463
|
+
|
|
314
464
|
---
|
|
315
465
|
|
|
316
466
|
## Architecture
|
|
@@ -319,9 +469,9 @@ Run in GitHub Actions to catch security issues before deployment:
|
|
|
319
469
|
mcp-guardian/
|
|
320
470
|
├── src/
|
|
321
471
|
│ ├── index.ts # MCP server entry (stdio transport)
|
|
322
|
-
│ ├── cli.ts # CLI wrapper (5 commands: scan, audit, health, report
|
|
323
|
-
│ ├── container.ts # Dependency injection container
|
|
324
|
-
│ ├── types.ts #
|
|
472
|
+
│ ├── cli.ts # CLI wrapper (5 commands: proxy, scan, audit, health, report)
|
|
473
|
+
│ ├── container.ts # Dependency injection container (IoC)
|
|
474
|
+
│ ├── types.ts # Shared TypeScript interfaces (8 types)
|
|
325
475
|
│ ├── config-parser.ts # Multi-format config parsing with multi-file aggregation
|
|
326
476
|
│ │
|
|
327
477
|
│ ├── proxy/ # MCP Proxy Interceptor (real cost engine)
|
|
@@ -334,18 +484,19 @@ mcp-guardian/
|
|
|
334
484
|
│ │ └── health-monitor.ts # Live JSON-RPC probing + DB integration
|
|
335
485
|
│ │
|
|
336
486
|
│ ├── scanners/ # Individual security checks
|
|
337
|
-
│ │ ├── cve-checker.ts # OSV.dev → NVD fallback chain
|
|
338
|
-
│ │ ├── auth-prober.ts # Auth/transport detection (env + URL)
|
|
487
|
+
│ │ ├── cve-checker.ts # OSV.dev → NVD fallback chain (rate-limited)
|
|
488
|
+
│ │ ├── auth-prober.ts # Auth/transport detection (env + URL patterns)
|
|
339
489
|
│ │ ├── typo-squat-detector.ts # Levenshtein distance (O(n) memory)
|
|
340
|
-
│ │
|
|
490
|
+
│ │ ├── secret-scanner.ts # 6 regex patterns for secrets
|
|
491
|
+
│ │ └── command-validator.ts # 10 suspicious pattern checks for command injection
|
|
341
492
|
│ │
|
|
342
493
|
│ ├── clients/ # External API clients
|
|
343
|
-
│ │ ├── osv-client.ts # api.osv.dev (purl-based, rate-limited)
|
|
344
|
-
│ │ ├── nvd-client.ts # NIST NVD (API key, rate-limited)
|
|
345
|
-
│ │ └── pricing-client.ts # 97 models, custom override support
|
|
494
|
+
│ │ ├── osv-client.ts # api.osv.dev (purl-based, token-bucket rate-limited)
|
|
495
|
+
│ │ ├── nvd-client.ts # NIST NVD (API key support, rate-limited)
|
|
496
|
+
│ │ └── pricing-client.ts # 97 models, 17 providers, custom override support
|
|
346
497
|
│ │
|
|
347
498
|
│ ├── database/
|
|
348
|
-
│ │ └── history-db.ts # SQLite via sql.js (4 tables, batched writes)
|
|
499
|
+
│ │ └── history-db.ts # SQLite via sql.js (4 tables, batched writes, 1s debounce)
|
|
349
500
|
│ │
|
|
350
501
|
│ ├── reporter/
|
|
351
502
|
│ │ └── report-generator.ts # Text, Markdown, JSON formatting
|
|
@@ -354,12 +505,26 @@ mcp-guardian/
|
|
|
354
505
|
│ ├── token-counter.ts # tiktoken (o200k_base) wrapper
|
|
355
506
|
│ ├── mcp-client.ts # Full JSON-RPC 2.0 state machine + SSE probing
|
|
356
507
|
│ ├── rate-limiter.ts # Token-bucket rate limiter
|
|
357
|
-
│ ├── tls-checker.ts # TLS certificate validation
|
|
508
|
+
│ ├── tls-checker.ts # TLS certificate validation (expiry, issuer, chain)
|
|
358
509
|
│ ├── scoring.ts # Shared scoring utility
|
|
359
|
-
│ └── logger.ts # Colored console logger
|
|
510
|
+
│ └── logger.ts # Colored console logger with log levels
|
|
511
|
+
│
|
|
512
|
+
tests/ # 74 tests across 11 suites (Vitest)
|
|
513
|
+
├── config-parser.test.ts
|
|
514
|
+
├── secret-scanner.test.ts
|
|
515
|
+
├── auth-prober.test.ts
|
|
516
|
+
├── typo-squat-detector.test.ts
|
|
517
|
+
├── scoring.test.ts
|
|
518
|
+
├── pricing-client.test.ts
|
|
519
|
+
├── services/
|
|
520
|
+
│ ├── cost-auditor.test.ts
|
|
521
|
+
│ └── security-scanner.test.ts
|
|
522
|
+
└── integration/
|
|
523
|
+
├── proxy-audit.test.ts
|
|
524
|
+
└── full-pipeline.test.ts
|
|
360
525
|
```
|
|
361
526
|
|
|
362
|
-
### Data Flow
|
|
527
|
+
### Data Flow (Proxy → DB → Audit)
|
|
363
528
|
|
|
364
529
|
```
|
|
365
530
|
AI Client (Cline/Claude)
|
|
@@ -370,10 +535,10 @@ AI Client (Cline/Claude)
|
|
|
370
535
|
│ MCP Proxy Server │ ← mcp-guardian proxy
|
|
371
536
|
│ (proxy-server.ts) │
|
|
372
537
|
└───────┬───────────┘
|
|
373
|
-
│ counts tokens (tiktoken)
|
|
538
|
+
│ counts tokens (tiktoken o200k_base)
|
|
374
539
|
▼
|
|
375
540
|
┌───────────────────┐
|
|
376
|
-
│ call_records table │ ← SQLite
|
|
541
|
+
│ call_records table │ ← SQLite (sql.js)
|
|
377
542
|
│ (history-db.ts) │
|
|
378
543
|
└───────┬───────────┘
|
|
379
544
|
│ async getCallRecordsForServer()
|
|
@@ -382,7 +547,7 @@ AI Client (Cline/Claude)
|
|
|
382
547
|
│ Cost Auditor │ ← mcp-guardian audit / report
|
|
383
548
|
│ (cost-auditor.ts) │
|
|
384
549
|
└───────────────────┘
|
|
385
|
-
│ per-tool breakdown + multi-model pricing
|
|
550
|
+
│ per-tool breakdown + multi-model pricing (97 models)
|
|
386
551
|
▼
|
|
387
552
|
Cost Report ($0.0023, gpt-4o)
|
|
388
553
|
```
|
|
@@ -394,17 +559,17 @@ AI Client (Cline/Claude)
|
|
|
394
559
|
MCP Guardian auto-discovers config files from these standard locations:
|
|
395
560
|
|
|
396
561
|
| Client | Config Path |
|
|
397
|
-
|
|
562
|
+
|---|---|
|
|
398
563
|
| **Cline (VS Code)** | `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` |
|
|
399
|
-
| **Cline (VS Code Insiders)** | `~/Library/Application Support/Code - Insiders/User/globalStorage
|
|
400
|
-
| **Cline (Linux)** | `~/.config/Code/User/globalStorage
|
|
401
|
-
| **Cline (Windows)** | `%APPDATA%/Code/User/globalStorage
|
|
564
|
+
| **Cline (VS Code Insiders)** | `~/Library/Application Support/Code - Insiders/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` |
|
|
565
|
+
| **Cline (Linux)** | `~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` |
|
|
566
|
+
| **Cline (Windows)** | `%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` |
|
|
402
567
|
| **Claude Desktop (macOS)** | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
403
568
|
| **Claude Desktop (Linux)** | `~/.config/Claude/claude_desktop_config.json` |
|
|
404
569
|
| **Cursor** | `~/.cursor/mcp.json` |
|
|
405
570
|
| **Windsurf** | `~/.codeium/windsurf/mcp_config.json` |
|
|
406
571
|
|
|
407
|
-
Use `--config` / `
|
|
572
|
+
Use `--config` / `-c` for a custom path, or `--all` / `-a` to aggregate all discoverable configs with deduplication (first file wins for duplicate server names).
|
|
408
573
|
|
|
409
574
|
---
|
|
410
575
|
|
|
@@ -413,7 +578,7 @@ Use `--config` / `configPath` for a custom path, or `--all` to aggregate all dis
|
|
|
413
578
|
Each server receives a score from 0–100 with these deductions:
|
|
414
579
|
|
|
415
580
|
| Finding | Deduction |
|
|
416
|
-
|
|
581
|
+
|---|---|
|
|
417
582
|
| Critical CVEs detected | −40 |
|
|
418
583
|
| High-severity CVEs | −20 |
|
|
419
584
|
| Medium-severity CVEs | −10 |
|
|
@@ -421,6 +586,8 @@ Each server receives a score from 0–100 with these deductions:
|
|
|
421
586
|
| Unencrypted transport | −10 |
|
|
422
587
|
| Typo-squat detected | −30 |
|
|
423
588
|
| Hardcoded secrets found | −15 |
|
|
589
|
+
| High-severity command warning | −25 |
|
|
590
|
+
| Medium-severity command warning | −10 |
|
|
424
591
|
|
|
425
592
|
**Letter grades:** A (80–100), B (60–79), C (40–59), D (0–39)
|
|
426
593
|
|
|
@@ -430,29 +597,30 @@ Each server receives a score from 0–100 with these deductions:
|
|
|
430
597
|
|
|
431
598
|
97 models across 17 providers. Cached rates per 1M tokens (as of mid-2025):
|
|
432
599
|
|
|
433
|
-
| Provider | Models | Example Rates |
|
|
434
|
-
|
|
435
|
-
| OpenAI (14) | gpt-4o, gpt-4.5-preview, o1, o3, o4-mini, gpt-3.5-turbo | $5/$15
|
|
436
|
-
| Anthropic (8) | claude-3-5-sonnet, claude-opus, claude-haiku | $3/$15
|
|
437
|
-
| Google (12) | gemini-2.5-pro, gemini-2.0-flash, gemma | $1.25/$10
|
|
438
|
-
| DeepSeek (4) | deepseek-chat, deepseek-reasoner, deepseek-v3 | $0.14/$0.28
|
|
439
|
-
| xAI/Grok (5) | grok-3, grok-3-mini | $3/$15
|
|
440
|
-
| Meta/Llama (8) | llama-4-maverick, llama-3.3-70b | $0.2/$0.6
|
|
441
|
-
| Mistral (9) | mistral-large, mixtral-8x22b, codestral | $2/$6
|
|
442
|
-
| + 10 more
|
|
600
|
+
| Provider | Models | Example Rates (input/output per 1M) |
|
|
601
|
+
|---|---|---|
|
|
602
|
+
| OpenAI (14) | gpt-4o, gpt-4.5-preview, o1, o3, o4-mini, gpt-3.5-turbo | $5/$15 |
|
|
603
|
+
| Anthropic (8) | claude-3-5-sonnet, claude-opus, claude-haiku | $3/$15 |
|
|
604
|
+
| Google (12) | gemini-2.5-pro, gemini-2.0-flash, gemma | $1.25/$10 |
|
|
605
|
+
| DeepSeek (4) | deepseek-chat, deepseek-reasoner, deepseek-v3 | $0.14/$0.28 |
|
|
606
|
+
| xAI/Grok (5) | grok-3, grok-3-mini | $3/$15 |
|
|
607
|
+
| Meta/Llama (8) | llama-4-maverick, llama-3.3-70b | $0.2/$0.6 |
|
|
608
|
+
| Mistral (9) | mistral-large, mixtral-8x22b, codestral | $2/$6 |
|
|
609
|
+
| + 10 more | Cohere, AI21, Reka, Amazon, Alibaba, Zhipu, 01.AI, Writer, Perplexity, HuggingFace | varies |
|
|
443
610
|
|
|
444
|
-
Unknown models receive a conservative default estimate of $10/$30 per million tokens. Override via `PRICING_OVERRIDES` env var.
|
|
611
|
+
Unknown models receive a conservative default estimate of $10/$30 per million tokens. Override any model via the `PRICING_OVERRIDES` env var.
|
|
445
612
|
|
|
446
613
|
---
|
|
447
614
|
|
|
448
615
|
## Environment Variables
|
|
449
616
|
|
|
450
|
-
| Variable | Purpose |
|
|
451
|
-
|
|
452
|
-
| `NVD_API_KEY` | NIST NVD API key for CVE lookups (20 req/min vs 5 without) |
|
|
453
|
-
| `MCP_GUARDIAN_DB_PATH` | Override SQLite database path
|
|
454
|
-
| `LOG_LEVEL` | Logging level: `DEBUG`, `INFO`, `WARN`, `ERROR`
|
|
455
|
-
| `PRICING_OVERRIDES` | Custom pricing JSON: `{"my-model": {"input": 2.0, "output": 6.0}}` |
|
|
617
|
+
| Variable | Purpose | Default |
|
|
618
|
+
|---|---|---|
|
|
619
|
+
| `NVD_API_KEY` | NIST NVD API key for CVE lookups (20 req/min vs 5 without) | (none) |
|
|
620
|
+
| `MCP_GUARDIAN_DB_PATH` | Override SQLite database path | `~/.mcp-guardian/history.db` |
|
|
621
|
+
| `LOG_LEVEL` | Logging level: `DEBUG`, `INFO`, `WARN`, `ERROR` | `INFO` |
|
|
622
|
+
| `PRICING_OVERRIDES` | Custom pricing JSON: `{"my-model": {"input": 2.0, "output": 6.0}}` | (none) |
|
|
623
|
+
| `OPENAI_API_KEY` | Optionally used by tiktoken for token counting | (none) |
|
|
456
624
|
|
|
457
625
|
---
|
|
458
626
|
|
|
@@ -465,18 +633,69 @@ cd mcp-guardian
|
|
|
465
633
|
npm install
|
|
466
634
|
|
|
467
635
|
# Development
|
|
468
|
-
npm run dev
|
|
469
|
-
npm run build
|
|
470
|
-
npm run lint
|
|
471
|
-
npm test
|
|
472
|
-
npm run test:watch
|
|
636
|
+
npm run dev # Watch mode with tsx
|
|
637
|
+
npm run build # Compile TypeScript
|
|
638
|
+
npm run lint # Type check (tsc --noEmit)
|
|
639
|
+
npm test # 74 tests across 11 suites (Vitest)
|
|
640
|
+
npm run test:watch # Watch mode
|
|
473
641
|
|
|
474
642
|
# Contributing
|
|
475
|
-
See CONTRIBUTING.md for guidelines on adding scanners, pricing models, and tests.
|
|
643
|
+
# See CONTRIBUTING.md for guidelines on adding scanners, pricing models, and tests.
|
|
476
644
|
```
|
|
477
645
|
|
|
478
646
|
---
|
|
479
647
|
|
|
648
|
+
## FAQ
|
|
649
|
+
|
|
650
|
+
### Why does `mcp-guardian audit` show $0.0000?
|
|
651
|
+
|
|
652
|
+
The cost audit reads real data from the proxy's database. You must run `mcp-guardian proxy` first to capture `tools/call` traffic, then run `audit`. Without proxy data, the `call_records` table is empty and the audit returns zero.
|
|
653
|
+
|
|
654
|
+
### Do I need an NVD API key?
|
|
655
|
+
|
|
656
|
+
No, but you'll be rate-limited to 5 requests per minute without one. Get a free key at [NIST NVD](https://nvd.nist.gov/developers/request-an-api-key) for 20 req/min.
|
|
657
|
+
|
|
658
|
+
### How do I run the proxy alongside my AI assistant?
|
|
659
|
+
|
|
660
|
+
Start `mcp-guardian proxy --config <path>` in one terminal, then run your AI assistant normally in another. The proxy sits between the assistant and MCP servers, transparently capturing all `tools/call` traffic.
|
|
661
|
+
|
|
662
|
+
### What does the proxy intercept?
|
|
663
|
+
|
|
664
|
+
The proxy only tracks `tools/call` JSON-RPC messages — it counts input tokens (the request) and output tokens (the response). It forwards all other messages without tracking.
|
|
665
|
+
|
|
666
|
+
### Can I use MCP Guardian with SSE/HTTP transports?
|
|
667
|
+
|
|
668
|
+
The security scan and health monitor support SSE/HTTP transports. The proxy currently supports **stdio** transports only (it spawns child processes). Cost auditing via proxy works only for stdio-based MCP servers.
|
|
669
|
+
|
|
670
|
+
### How do I override pricing for my custom model?
|
|
671
|
+
|
|
672
|
+
Set the `PRICING_OVERRIDES` environment variable with JSON:
|
|
673
|
+
|
|
674
|
+
```bash
|
|
675
|
+
export PRICING_OVERRIDES='{"my-custom-model": {"input": 2.0, "output": 6.0}}'
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
Rates are in USD per 1 million tokens.
|
|
679
|
+
|
|
680
|
+
### Where is the database stored?
|
|
681
|
+
|
|
682
|
+
By default, SQLite data is stored at `~/.mcp-guardian/history.db`. Override with the `MCP_GUARDIAN_DB_PATH` environment variable. The database has 4 tables: `security_scans`, `cost_records`, `health_checks`, and `call_records`.
|
|
683
|
+
|
|
684
|
+
### What's the difference between `--config` and `--all`?
|
|
685
|
+
|
|
686
|
+
- `--config <path>` loads a single config file
|
|
687
|
+
- `--all` auto-discovers and aggregates all config files from known locations (Cline, Claude Desktop, Cursor, Windsurf), deduplicating servers by name
|
|
688
|
+
|
|
689
|
+
### Can I run MCP Guardian in CI/CD?
|
|
690
|
+
|
|
691
|
+
Yes. Use the alert threshold flags (`--fail-on-critical`, `--fail-on-secrets`, `--threshold-score`, etc.) which return non-zero exit codes that CI systems understand. See the [CI/CD Integration](#cicd-integration) section for examples.
|
|
692
|
+
|
|
693
|
+
### How accurate is the token counting?
|
|
694
|
+
|
|
695
|
+
Token counting uses `tiktoken` with the `o200k_base` encoding (used by GPT-4o and many modern models). For non-OpenAI models, this provides a close approximation since most modern tokenizers are similar in granularity.
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
480
699
|
## Roadmap
|
|
481
700
|
|
|
482
701
|
- [x] Core security, cost, and health scanning
|
|
@@ -492,9 +711,27 @@ See CONTRIBUTING.md for guidelines on adding scanners, pricing models, and tests
|
|
|
492
711
|
- [x] Dependency injection container (IoC pattern)
|
|
493
712
|
- [x] Token-bucket rate limiter (OSV + NVD)
|
|
494
713
|
- [x] TLS certificate validation
|
|
495
|
-
- [x]
|
|
714
|
+
- [x] Command injection validation (10 suspicious patterns)
|
|
715
|
+
- [x] Active policy engine — YAML-based pass/block/flag with allowlists, regex, rate limiting, token budgets
|
|
716
|
+
- [x] Structured JSON logging (pino) for SIEM ingestion
|
|
717
|
+
- [x] STRIDE threat model (SECURITY.md)
|
|
718
|
+
- [x] 74 tests (11 suites)
|
|
496
719
|
- [x] GitHub Actions CI (Node 18/20/22 matrix)
|
|
497
|
-
- [
|
|
720
|
+
- [x] Performance benchmarks (p50: 5ms baseline, +25.78ms proxy overhead, +0.15ms policy)
|
|
721
|
+
- [x] Helm chart + production deployment guide (K8s, fail-open/closed, sidecar pattern, scaling)
|
|
722
|
+
- [x] Published to npm as [`@mcp-guardian/server`](https://www.npmjs.com/package/@mcp-guardian/server)
|
|
723
|
+
- [x] OAuth 2.1 / OIDC proxy authentication (v0.5.0)
|
|
724
|
+
- [x] RBAC — scope & client-ID-based access control (v0.5.1)
|
|
725
|
+
- [x] Circuit breaker — 3-state protection for upstream servers (v0.5.2)
|
|
726
|
+
- [x] Per‑client rate limiting (v0.5.2)
|
|
727
|
+
- [x] Consistent SIEM fields — requestId, authnSuccess, authzAllowed (v0.5.2)
|
|
728
|
+
- [x] Session binding — replay protection via 5‑min session tokens (v0.6.0)
|
|
729
|
+
- [x] Hot‑reload policies — chokidar file watcher (v0.6.0)
|
|
730
|
+
- [ ] OPA integration for Rego policies
|
|
731
|
+
- [ ] Web dashboard for historical trends
|
|
732
|
+
- [ ] Slack/Discord alerting
|
|
733
|
+
- [ ] Prometheus metrics endpoint
|
|
734
|
+
- [ ] Multi-user proxy
|
|
498
735
|
|
|
499
736
|
---
|
|
500
737
|
|
|
@@ -502,4 +739,4 @@ See CONTRIBUTING.md for guidelines on adding scanners, pricing models, and tests
|
|
|
502
739
|
|
|
503
740
|
MIT — see [LICENSE](LICENSE) for details.
|
|
504
741
|
|
|
505
|
-
**Built with TypeScript, @modelcontextprotocol/sdk, tiktoken, sql.js, and
|
|
742
|
+
**Built with TypeScript, @modelcontextprotocol/sdk, tiktoken, sql.js, commander, chalk, and zod.**
|