Skip to main content
Glama
mcp-audit-rgpd

mcp-audit-rgpd

README.md
# API Audit RGPD & EU AI Act

> πŸ‡ͺπŸ‡Ί **Commercial Micro-API** β€” Automated GDPR & EU AI Act compliance auditing for any public website, monetized via the [x402 payment protocol](https://x402.org) (0.25 USDC on Base network).

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
[![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)](https://nodejs.org)
[![x402](https://img.shields.io/badge/payment-x402%20USDC-blue)](https://x402.org)
[![GDPR](https://img.shields.io/badge/GDPR-Compliant%20Audit-brightgreen)](https://gdpr.eu)
[![EU AI Act](https://img.shields.io/badge/EU%20AI%20Act-Art.%2050%20Check-orange)](https://artificialintelligenceact.eu)

---

## ✨ What It Does

This API performs a **100% local, zero-cost** compliance audit of any public website against:

| Regulation | Checks |
|---|---|
| **GDPR (Art. 7, 13, 14, 32)** | HTTPS encryption, third-party trackers, cookie consent (CMP), privacy policy, legal notices |
| **ePrivacy Directive** | Trackers loading without prior consent |
| **EU AI Act (Art. 50)** | Generative AI tools detected without transparency disclosure |
| **French LCEN** | Legal notices (mentions lΓ©gales) presence |

**Returns a JSON report** with a compliance score out of 100, detected risks, and prioritized recommendations.

---

## πŸ’° Pricing & Payment

| Field | Value |
|---|---|
| **Price** | 0.25 USDC per audit |
| **Network** | Base (mainnet) or Base Sepolia (testnet) |
| **Protocol** | [x402](https://x402.org) β€” HTTP-native micropayments |
| **Wallet** | `0xB1b0f5a198D1a8344d32172f29D73fa3FaA74B4c` |

The API follows the **x402 standard**: the client receives a `402 Payment Required` response with payment instructions, pays on-chain, and retries the request with proof.

---

## πŸš€ Quick Start

### Prerequisites

- Node.js 18+
- An x402-compatible wallet with USDC on Base (for paid usage)

### Install & Run

```bash
git clone https://github.com/votre-org/api-audit-rgpd
cd api-audit-rgpd
npm install
cp .env.example .env   # Edit NETWORK and WALLET_ADDRESS if needed
npm start
```

The server starts at `http://localhost:3000`.

### Environment Variables

```env
NETWORK=base-sepolia          # base | base-sepolia
WALLET_ADDRESS=0xB1b0...4c   # Your receiving wallet
PRICE_USDC=0.25               # Price per audit
PORT=3000                     # HTTP port
```

---

## πŸ“‘ API Reference

### `GET /` β€” Free Manifest

Returns a JSON description of the API (pricing, endpoints, MCP server info). No payment required.

```bash
curl http://localhost:3000/
```

**Response:**
```json
{
  "name": "API Audit RGPD & EU AI Act",
  "version": "1.0.0",
  "pricing": { "amount": 0.25, "currency": "USDC", "network": "base-sepolia", "protocol": "x402" },
  "endpoints": [...]
}
```

---

### `GET /api/audit?url=https://...` β€” Paid Audit (0.25 USDC)

Audits a public website for GDPR & EU AI Act compliance.

**Without payment** β†’ `402 Payment Required` with x402 instructions.  
**With x402 payment header** β†’ Full JSON audit report.

```bash
# Without payment (shows 402 + payment info)
curl "http://localhost:3000/api/audit?url=https://www.example.com"

# With x402 payment (using an x402-compatible client)
x402-client "http://localhost:3000/api/audit?url=https://www.example.com"
```

**Parameters:**

| Param | Type | Required | Description |
|---|---|---|---|
| `url` | string | βœ… | Full URL to audit (must start with `https://` or `http://`) |

**Response Fields:**

| Field | Type | Description |
|---|---|---|
| `url_auditee` | string | Final URL after redirects |
| `https_detecte` | boolean | Whether HTTPS is active |
| `trackers_detectes` | string[] | List of third-party trackers found |
| `cmp_detecte` | boolean | Whether a cookie consent platform was found |
| `cmp_identifiees` | string[] | Named CMPs detected (Axeptio, Didomi, etc.) |
| `politique_confidentialite` | boolean | Privacy policy link found |
| `mentions_legales` | boolean | Legal notices found |
| `ia_generative_detectee` | boolean | Generative AI tools detected |
| `ia_outils_detectes` | string[] | Named AI tools detected |
| `score_conformite` | number | Compliance score (0–100) |
| `risques_detectes` | string[] | List of detected risks with regulation references |
| `recommandations_prioritaires` | string[] | Prioritized action items |
| `timestamp` | string | ISO 8601 audit date |
| `duree_ms` | number | Analysis duration in milliseconds |

**Example response (Wikipedia):**
```json
{
  "url_auditee": "https://www.wikipedia.org/",
  "https_detecte": true,
  "trackers_detectes": [],
  "cmp_detecte": false,
  "politique_confidentialite": true,
  "mentions_legales": false,
  "ia_generative_detectee": false,
  "score_conformite": 65,
  "risques_detectes": ["πŸ”΄ Aucune CMP / bandeau de consentement cookies dΓ©tectΓ©"],
  "recommandations_prioritaires": ["ImplΓ©menter une CMP..."],
  "timestamp": "2024-01-15T10:30:00.000Z",
  "duree_ms": 450
}
```

---

## πŸ”Œ MCP Server (Claude Desktop / Cursor / Continue)

This project ships as a **Model Context Protocol (MCP) server**, letting any MCP client (Claude Desktop, Cursor, Continue.dev, etc.) call the audit as a native tool.

### Configure in Claude Desktop

Add to `~/.config/claude-desktop/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "audit-rgpd": {
      "command": "node",
      "args": ["/path/to/api-audit-rgpd/mcp-server.js"],
      "env": {
        "NETWORK": "base-sepolia",
        "WALLET_ADDRESS": "0xB1b0f5a198D1a8344d32172f29D73fa3FaA74B4c"
      }
    }
  }
}
```

### Available MCP Tool

| Tool | Description |
|---|---|
| `audit_eu_compliance` | Audit any URL for GDPR & EU AI Act compliance. Returns full JSON report with score and recommendations. |

---

## πŸ” What Gets Detected

### Third-Party Trackers
Google Analytics (GA4), Google Tag Manager, Meta Pixel, TikTok Pixel, Hotjar, DoubleClick, LinkedIn Insight, Twitter/X Pixel, Criteo, HubSpot, Segment, Mixpanel, Amplitude, Intercom.

### Cookie Consent Platforms (CMPs)
Axeptio, Didomi, Cookiebot, OneTrust, Tarteaucitron, TrustArc, Quantcast CMP, Usercentrics, CookieYes, Iubenda.

### Generative AI Tools (EU AI Act Art. 50)
OpenAI widget, Intercom AI (Fin), Crisp, Drift, Tidio, Zendesk AI, Botsify, ManyChat, Cohere, Anthropic/Claude.

---

## πŸ—οΈ Architecture

```
api-audit-rgpd/
β”œβ”€β”€ index.js          # Express server + x402 middleware
β”œβ”€β”€ mcp-server.js     # MCP stdio server
β”œβ”€β”€ lib/
β”‚   └── auditor.js    # Core audit engine (100% local, 0 € cost)
β”œβ”€β”€ test-client.js    # Test suite (npm test)
β”œβ”€β”€ .env              # Configuration
└── README.md
```

**Zero external API cost**: The audit engine uses only Node.js built-in modules and Cheerio for HTML parsing. No LLM calls, no paid APIs. Server cost = **€0 per request**.

---

## πŸ§ͺ Testing

```bash
npm test
```

Runs 3 test suites:
1. `GET /` β†’ Valid JSON manifest with correct pricing fields
2. `GET /api/audit` β†’ HTTP 402 without payment (x402 response format)
3. Live audit of `https://www.wikipedia.org` β†’ Valid report structure

---

## πŸ“‹ Scoring Methodology

| Criterion | Points |
|---|---|
| βœ… HTTPS enabled | +20 |
| βœ… CMP / cookie banner present | +20 |
| βœ… Privacy policy linked | +20 |
| βœ… Legal notices present | +15 |
| βœ… Zero third-party trackers | +25 |
| ❌ Trackers without consent (per 2 trackers) | -10 (max -30) |
| ❌ Generative AI without transparency notice | -10 |

---

## βš–οΈ Legal Disclaimer

This tool provides **automated indicative analysis only**. It does not constitute legal advice. For full GDPR compliance, consult a qualified DPO (Data Protection Officer) or legal counsel.

---

## πŸ“„ License

[MIT](./LICENSE) Β© 2024 API Audit RGPD