Edge AI x402 MCP
README.md
# Edge AI x402 MCP
[](https://nohumans.directory/l/148419f7-7f0)
Ultra-low-cost pay-per-call AI inference, embeddings, FLUX image generation, and public URL-to-Markdown web extraction on Cloudflare Workers, settled on **Solana Mainnet** via **x402 v2** (USDC & USDT via PayAI and Dexter facilitators) or prepaid credit key packs.
- **Production Base URL:** `https://edge-ai-x402.nguyenthanhnam-pye.workers.dev`
- **Remote MCP Endpoint (Streamable HTTP):** `https://edge-ai-x402.nguyenthanhnam-pye.workers.dev/mcp`
- **OpenAPI 3.1 Spec:** `https://edge-ai-x402.nguyenthanhnam-pye.workers.dev/openapi.json`
- **x402 Manifest:** `https://edge-ai-x402.nguyenthanhnam-pye.workers.dev/.well-known/x402.json`
- **MCP Server Card:** `https://edge-ai-x402.nguyenthanhnam-pye.workers.dev/.well-known/mcp/server-card.json`
- **Dexter / x402gle Skills:** `https://x402gle.com/servers/edge-ai-x402.nguyenthanhnam-pye.workers.dev/skills.json`
- **Settlement Network:** Solana Mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`)
- **Accepted Assets:** USDC (`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`), USDT (`Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB`)
- **Facilitators:** PayAI (`https://facilitator.payai.network`) & Dexter (`https://x402.dexter.cash`)
## Pricing & Endpoints
| Route | MCP Tool | Models / Behavior | Price (USD) |
| :--- | :--- | :--- | ---: |
| `GET /v1/models` | `list_ai_models` | List available chat, embedding & image models | Free |
| `GET /v1/web/extract/sample` | — | Static web extraction response example | Free |
| `POST /v1/chat/completions` | `ai_chat_completion` | `llama-3.3-70b`, `gpt-oss-20b`, `gemma-4-26b`, `qwen-coder-32b` | **$0.001** |
| `POST /v1/embeddings` | `ai_embeddings` | `bge-m3`, `bge-small`, `bge-large` | **$0.001** |
| `POST /v1/web/extract` (`GET` also supported) | `web_extract_markdown` | SSRF-guarded public URL HTML -> clean Markdown + headings/links | **$0.002** |
| `POST /v1/images/generate` | `ai_generate_image` | `flux-1-schnell` (1-4 steps, JPEG base64) | **$0.005** |
| `POST /v1/keys/redeem` | — | Redeem prepaid credit packs (`starter_1` $1 / 1,200 cr, `builder_5` $5 / 6,500 cr, `pro_15` $15 / 25,000 cr) | On-chain |
## Quick Start
### 1. Discover x402 v2 payment terms (HTTP 402)
```bash
curl -i -X POST https://edge-ai-x402.nguyenthanhnam-pye.workers.dev/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"llama-3.3-70b","messages":[{"role":"user","content":"Hello"}]}'
```
Decode the base64 `PAYMENT-REQUIRED` response header, sign the Solana Mainnet USDC or USDT transaction with an x402 v2 client, and retry with `PAYMENT-SIGNATURE`.
### 2. Connect via Remote MCP (Streamable HTTP)
```json
{
"mcpServers": {
"edge-ai-x402": {
"url": "https://edge-ai-x402.nguyenthanhnam-pye.workers.dev/mcp"
}
}
}
```
## Security & Accounting
- **Strict x402 v2 Exact Settlement:** Verifies facilitator proof and settles before running inference; atomic SQLite-backed Durable Object (`EdgeLedger`) prevents concurrent replay and enforces the daily neuron budget.
- **SSRF-Protected Web Extraction:** Accepts public HTTP/HTTPS domains only; rejects IP literals, credentials, non-standard ports, loopback/private/internal/metadata hosts, and re-validates every redirect hop.
## Local Development & Tests
```bash
node --test test/*.test.js
```
Copy `wrangler.example.toml` to `wrangler.toml`, provision your own KV namespaces and Solana wallet variables, and deploy with `npx wrangler deploy`.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues