# Proteus Metered B2A MCP Gateway — Full Agent Technical Specification

Base URL: `https://mcp.proteusmatrix.com`
Unit Economics: `1 credit = $0.002 USD = 200,000 microcents`

## 1. Transport & Authentication
- **Primary Transport**: MCP Streamable HTTP (`POST https://mcp.proteusmatrix.com/mcp`, stateless edge mode).
- **Legacy Fallback**: MCP SSE (`GET https://mcp.proteusmatrix.com/sse`, `POST https://mcp.proteusmatrix.com/messages?sessionId=...`).
- **Headers**: `Authorization: Bearer pk_trial_...` or `X-API-Key: pk_live_...`.
- **Budget Telemetry**: Every successful MCP `tools/call` response appends `_meta: { credits_used, credits_remaining, cost_microcents, balance_microcents, cost_usd, execution_ms }`.

## 2. HTTP 402 Machine Onboarding & x402 Protocol
Calling any metered tool without a valid key or with insufficient balance returns a structured MCP `isError: true` challenge (plus `WWW-Authenticate` and `X-Payment-Required` HTTP headers; literal HTTP `402 Payment Required` when `Prefer: status=402` is sent on `/mcp` or when calling `POST /api/v1/tools/:toolName`):
1. Mint 50 free trial credits immediately via `POST https://mcp.proteusmatrix.com/api/v1/keys/trial` with `{"agent_name":"...","contact_email":"..."}`.
2. Or direct your operator to `GET https://mcp.proteusmatrix.com/api/v1/checkout?pack=starter_5&key_prefix=<your_prefix>`.

### Available Credit Packs
- `starter_5`: $5 USD -> 2,500 credits (starter tier)
- `growth_20`: $20 USD -> 12,000 credits (growth tier)
- `scale_100`: $100 USD -> 75,000 credits (scale tier)

## 3. Complete Tool Specifications
### `resolve_us_county_fips`
- **Title**: US County & Independent City FIPS Resolver (Free)
- **Pricing**: FREE ($0.000 / 0 credits, IP rate-limited 120 req/min)
- **Efficiency**: Replaces ~1,500 tokens of state/FIPS/independent-city disambiguation across 3,144 U.S. counties
- **Specification**: FREE DISCOVERY HOOK ($0.000 / 0 credits, zero auth required). Resolves ambiguous US county, parish, borough, Connecticut planning region (09110-09190), or VA/MD/MO/NV independent-city names to canonical 5-digit FIPS codes across all 3,144 US counties and 51 jurisdictions. Eliminates ~1,500 tokens of Census FIPS lookup, VA city/county collision errors, and state assessor portal discovery. Input: query string + optional state abbr/name. Returns canonical fips, county_slug, population, boundary_realigned flag, assessor_term, and official_portal_url.
- **Direct REST/x402 Endpoint**: `POST https://mcp.proteusmatrix.com/api/v1/tools/resolve_us_county_fips`

### `get_county_tax_and_hazard_benchmark`
- **Title**: County Property Tax, Equity & FEMA Storm Hazard Benchmark
- **Pricing**: 1 credit(s) = $0.002 USD (200000 microcents)
- **Efficiency**: Replaces ~8,500 tokens of Census ACS + FEMA NRI scraping and custom property-tax/escrow modeling
- **Specification**: METERED (1 credit = $0.002/call). Returns pre-verified Census 2024 & 2021 ACS property tax rates, 3-year equity/tax deltas, appeal pressure scores, peer county comps, 11-peril FEMA National Risk Index scores & Expected Annual Loss (EAL), dominant repair trade vertical, and statutory state homestead/appeal rules for any of 3,144 US counties. Eliminates ~8,500 tokens of Census API + FEMA NRI scraping and custom escrow math. Supply fips (or county_slug + state_abbr) plus optional property_value_usd for exact parcel tax/appeal projections.
- **Direct REST/x402 Endpoint**: `POST https://mcp.proteusmatrix.com/api/v1/tools/get_county_tax_and_hazard_benchmark`

### `screen_counties_by_criteria`
- **Title**: Multi-Factor US County Screener (3,144 Counties)
- **Pricing**: 2 credit(s) = $0.004 USD (400000 microcents)
- **Efficiency**: Replaces ~15,000 tokens of multi-county web aggregation across 3,144 U.S. jurisdictions
- **Specification**: METERED (2 credits = $0.004/call). Deterministic SQL screening and ranking across all 3,144 US counties by state_abbr, min_population, max_effective_tax_rate_pct, min_fema_risk_score, min_rent_to_value_pct, and primary_trade_vertical (roofing|waterproofing|hvac|electrical). Eliminates ~15,000 tokens of multi-county web aggregation and ungrounded LLM estimates. Returns total_matching count and sorted top N counties with exact tax, yield, 3-yr appreciation, and FEMA loss metrics.
- **Direct REST/x402 Endpoint**: `POST https://mcp.proteusmatrix.com/api/v1/tools/screen_counties_by_criteria`

### `transmute_and_scrub_payload`
- **Title**: Deterministic Format Transmuter & Zero-Trust PII/PHI Scrubber
- **Pricing**: 1 credit(s) = $0.002 USD (200000 microcents)
- **Efficiency**: Replaces ~6,000 tokens of brittle LLM format parsing + deterministic PII/secret scrubbing
- **Specification**: METERED (1 credit = $0.002/call). Deterministically converts csv, tsv, psv, x12-edi (850/810), dynamodb-json, mismo-34-xml, county-tax-fixedwidth, alta-settlement-csv, or jsonl into strict-json, jsonl, json-schema-2020, sql-ddl, or zod-schema while scrubbing SSNs, Luhn payment cards, JWTs, API keys, DB URIs, and emails, and quarantining HIPAA HL7/835/837/FHIR PHI. Eliminates ~6,000 tokens of hallucination-prone LLM parsing. Returns structured output, redaction counts, FNV-1a schema_signature, and SHA-256 digest.
- **Direct REST/x402 Endpoint**: `POST https://mcp.proteusmatrix.com/api/v1/tools/transmute_and_scrub_payload`

### `compute_metes_and_bounds_polygon`
- **Title**: Surveyor Metes-and-Bounds WGS84 Geometry & Acreage Engine
- **Pricing**: 1 credit(s) = $0.002 USD (200000 microcents)
- **Efficiency**: Replaces ~4,000 tokens of error-prone LLM trigonometry with exact WGS84 surveyor integration
- **Specification**: METERED (1 credit = $0.002/call). Integrates raw deed metes-and-bounds bearing calls (N/S dd°mm'ss" E/W, DUE NORTH/SOUTH/EAST/WEST, feet/meters/chains/rods/poles/yards) on the WGS84 ellipsoid into closed RFC 7946 GeoJSON FeatureCollection or OGC WKT polygons with Shoelace planar area (sqft, acres), perimeter_ft, and closure_error_ft. Eliminates ~4,000 tokens of unreliable LLM surveying trigonometry. Returns exact traverse legs, acreage, and GIS geometry.
- **Direct REST/x402 Endpoint**: `POST https://mcp.proteusmatrix.com/api/v1/tools/compute_metes_and_bounds_polygon`

### `analyze_municipal_code_and_parcel_record`
- **Title**: Municipal Address Normalizer, Trade Classifier & Distress Query
- **Pricing**: 1 credit(s) = $0.002 USD (200000 microcents)
- **Efficiency**: Replaces ~7,000 tokens of municipal portal navigation, address permutation, and repair-trade classification
- **Specification**: METERED (1 credit = $0.002/call). Normalizes noisy street addresses into portal-ready fuzzy search permutations (unit stripping, N/S/E/W pre/post-directional swaps, suffix & ordinal stripping), classifies code-enforcement violation text + repeat counts across 11 contractor repair trades with ticket tier & priority score, and queries seeded municipal_distress_records in D1 (anonymized owner-occupied, full parcel/valuation/citation/tax-delinquency metrics). Eliminates ~7,000 tokens of municipal portal guesswork.
- **Direct REST/x402 Endpoint**: `POST https://mcp.proteusmatrix.com/api/v1/tools/analyze_municipal_code_and_parcel_record`

## 4. Client Config Snippets

### Claude Desktop / Antigravity / Cursor (`mcp_config.json`)
```json
{
  "mcpServers": {
    "proteus": {
      "url": "https://mcp.proteusmatrix.com/mcp",
      "headers": {
        "Authorization": "Bearer pk_trial_REPLACE_WITH_YOUR_KEY"
      }
    }
  }
}
```

### Verify Trial Provisioning & First Call via cURL
```bash
KEY=$(curl -sS -X POST "https://mcp.proteusmatrix.com/api/v1/keys/trial" \
  -H "Content-Type: application/json" \
  -d '{"agent_name":"curl-probe","contact_email":"dev@example.com"}' | jq -r '.api_key')

curl -sS -X POST "https://mcp.proteusmatrix.com/api/v1/tools/get_county_tax_and_hazard_benchmark" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"fips":"21227","property_value_usd":350000}'
```
