# mcpx gateway

> Remote Model Context Protocol (MCP) server generator and edge gateway deployed on Cloudflare Workers with V8 sandboxing, x402 payment protocol support, Creem credit billing, and sub-300ms System One prompt-injection guardrails.
> Hosted on Cloudflare Workers (V8 Isolate Edge) with sub-250ms deterministic execution.

## System Overview
mcpx bridges autonomous LLM agents and edge tooling via isolated V8 execution environments. It meters compute usage deterministically through native HTTP 402 protocols and bearer keys (`mcpx_live_...`).
Author & Publisher: Harry Krauze (https://harrykrauze.com/#harry-krauze).

## Core Capabilities & Features
- Zero-dependency remote HTTP MCP server generation on Cloudflare Workers
- V8 isolate sandboxing for untrusted MCP tool execution
- Sub-300ms System One prompt-injection and blast-radius pre-flight gate (`gemini-decision-1` / `gemini-decision-1-001`)
- Deterministic Zero-PII filter stripping secrets, tokens, and PII before execution
- Native x402 micropayment protocol and Creem.io credit top-up integration

## Security Guardrails & Architecture FAQ
- **How does mcpx deploy remote MCP servers?**
  mcpx compiles and deploys stateless, HTTP-accessible Model Context Protocol (MCP) servers directly onto Cloudflare Workers V8 isolates with sub-millisecond cold starts and built-in security guardrails.
- **How does mcpx protect MCP endpoints from prompt injection and unauthorized mutations?**
  Every incoming tool payload passes through a deterministic Zero-PII filter and a sub-300ms System One probabilistic decision gate that blocks prompt injections and flags high-blast-radius mutations before execution.

## x402 Pricing Matrix (Ladder of Trust)
| Operation Tier | MCP Methods / Scope | Rate (USD) | Credit Cost | Trust Tier |
| :--- | :--- | :--- | :--- | :--- |
| Discovery Tier | `tools/list`, `initialize`, `/llms.txt` | $0.00 | 0 credits | Discovery Free Tier (0 credits / free) |
| Session Analysis | `analyze_jev_semantic_ast` | $0.01 | 1 credit | Session Analysis ($0.01 / 1 credit) |
| Fraud Risk | `evaluate_fraud_transaction` | $0.01 | 1 credit | Real-time Decisioning |
| Deep Calculations | `calculate_u_value_iso6946` | $0.02 | 2 credits | Deep Calculations ($0.02 / 2 credits) |
| Edge Sandbox Run | `generate_mcp_server` | $0.05 | 5 credits | Edge Sandbox Run ($0.05 / 5 credits) |
| Deterministic e-Invoice (UBL 2.1) | `zibe_rekins_create` | $0.05 | 5 credits | EN 16931 / Peppol BIS 3.0 XML (Zero-PII Jev Gate) |
| LV Self-Employed VSAOI Calc | `pasdarbi_calculate_vsaoi_threshold` | $0.00 | 0 credits | Read-Only Tax Tool (`darbi.harrykrauze.com/api/mcp`, Zero-PII) |
| LV VAT 139.² Reverse Charge | `pasdarbi_calculate_vat_139_2_reverse_charge` | $0.00 | 0 credits | Read-Only Tax Tool (`darbi.harrykrauze.com/api/mcp`, Zero-PII) |
| LV VAT 50k Threshold Check | `pasdarbi_check_vat_50k_threshold` | $0.00 | 0 credits | Read-Only Tax Tool (`darbi.harrykrauze.com/api/mcp`, Zero-PII) |

## Free Public Tax & Compliance Tools (0 Credits, No Auth Required)
Both Latvian self-employed deterministic tax calculators are exposed publicly at `POST https://mcpx.harrykrauze.com/mcp` without bearer authentication or x402 credit charges (`0` credits, `readOnlyHint: true`), backed by a stateless SSRF-locked Zero-PII proxy to `https://darbi.harrykrauze.com/api/mcp`:
- `pasdarbi_calculate_vsaoi_threshold` -> upstream `calculate_vsaoi_threshold` (`year`: `2024–2027`, `monthlyNetProfitEur >= 0`, optional `isPensioner`).
- `pasdarbi_calculate_vat_139_2_reverse_charge` -> upstream `calculate_vat_139_2_reverse_charge` (`serviceAmountEur > 0`, optional `isRegisteredStandardVatPayer`, optional `platformLabel` <= 60 chars without PII).
- `pasdarbi_check_vat_50k_threshold` -> upstream `check_vat_50k_threshold` (`taxableTurnoverEur >= 0`, optional `plannedTransactionEur`, optional `nonTaxableIncome7cEur`; statuses `GREEN` / `YELLOW_BUFFER` / `RED_MANDATORY` for the €50 000 / €55 000 VAT Law Section 55 thresholds).

## Gateway Endpoints
- MCP Remote SSE Endpoint: `GET https://mcpx.harrykrauze.com/mcp/sse`
- Direct REST Execution: `POST https://mcpx.harrykrauze.com/tools/execute`
- Balance Verification: `POST https://mcpx.harrykrauze.com/keys/verify`
- Full Schema Specification: `https://mcpx.harrykrauze.com/llms-full.txt`
- Interactive Terminal: `https://mcpx.harrykrauze.com/`

## Authentication & Billing Protocol
1. Pass bearer token: `Authorization: Bearer mcpx_live_<token>`
2. Free discovery calls (`tools/list`, `initialize`, `/llms.txt`) require zero balance and deduct 0 credits.
3. If balance is insufficient for Tier 1–3 tools, the gateway emits `HTTP 402 Payment Required` with `WWW-Authenticate: L402` and top-up checkout metadata.
4. HTTP 402 Creem top-up resolution URL: https://checkout.creem.io/p/mcpx-tier1

## Client Integration (Claude Desktop, Claude Code & Cursor)

### Claude Desktop (claude_desktop_config.json)
```json
{
  "mcpServers": {
    "mcpx": {
      "url": "https://mcpx.harrykrauze.com/mcp/sse",
      "headers": {
        "Authorization": "Bearer YOUR_MCPX_API_KEY"
      }
    }
  }
}
```

### Cursor IDE (.cursor/mcp.json)
```json
{
  "mcpServers": {
    "mcpx": {
      "type": "sse",
      "url": "https://mcpx.harrykrauze.com/mcp/sse",
      "headers": {
        "Authorization": "Bearer YOUR_MCPX_API_KEY"
      }
    }
  }
}
```

### Claude Code (CLI)
```bash
claude mcp add --transport sse mcpx https://mcpx.harrykrauze.com/mcp/sse --header "Authorization: Bearer <MCPX_API_KEY>"
```