Critical Raw Minerals & Urban Mining Oracle (x402)
Deterministic Web3 x402 Critical Minerals & Urban Mining Scrap Valuation Oracle for Autonomous AI Agents on Base (USDC)
README
Critical Raw Minerals & Urban Mining Oracle (minerals-oracle-x402)
High-performance deterministic micro-oracle service designed for autonomous trading, supply chain, and RWA (Real World Asset) agents on Base Network. Serves real-time spot pricing, COMEX/LME cross-exchange arbitrage spreads, and urban-mining scrap benchmark yield valuations for critical raw physical commodities.
- 🌐 Live Cloud Run Service: https://minerals-oracle-x402-212942243360.asia-northeast3.run.app
- 🪝 Free Real-Time Alpha Hook: https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/api/v1/oracle/alpha-signals
- 📊 Economics ROI Proof: https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/api/v1/oracle/economics-roi
- 📑 LLM Agent Manifest: https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/llms.txt
- 📚 Swagger API Docs: https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/docs
⚡ Key Features
-
Normalized Critical Commodities Price Feeds:
- Silver (
Ag): LBMA & COMEX spot inUSD/troy_oz,USD/g,USD/kg. - Platinum (
Pt): LPPM & NYMEX spot inUSD/troy_oz,USD/g. - Copper (
Cu): LME Grade A Cathode & COMEX inUSD/mt,USD/lb,USD/kg. - Lithium (
Li): Battery Grade 99.5% $\text{Li}_2\text{CO}_3$ / $\text{LiOH}$ inUSD/mt,USD/kg. - Rare Earths (
NdDy): Permanent magnet grade Neodymium-Dysprosium ($\text{PrNd}/\text{DyFe}$) composite inUSD/kg.
- Silver (
-
Locational Arbitrage & Basis Spreads:
- COMEX vs. LME Copper arbitrage calculation factoring in trans-oceanic freight & import tariffs.
- COMEX vs. LBMA Loco London Silver spread.
- SMM Domestic China vs. Fastmarkets CIF Rotterdam Lithium premium/discount.
- NYMEX vs. LPPM Platinum spread.
-
Urban Mining & Circular Economy Valuation Engine:
EV_BATTERY_BLACK_MASS: Hydrometallurgical recovery of $\text{Li}$, $\text{Ni}$, $\text{Co}$, and $\text{Mn}$ with payable recovery yields and treatment charges (TC/RC).AUTO_CATALYST_CERAMIC: Spent catalytic converter PGM recovery ($\text{Pt}$, $\text{Pd}$, $\text{Rh}$) from ceramic monolith assays.E_WASTE_HIGH_GRADE_PCB: Precious and base metal extraction ($\text{Au}$, $\text{Ag}$, $\text{Cu}$) from shredded PCB feedstock.WIND_EV_PERMANENT_MAGNETS: NdFeB scrap recycling for separated rare earth oxides ($\text{Nd}$, $\text{Dy}$, $\text{Pr}$).
-
Web3 Monetization via x402 on Base:
- Enforces micro-payments (0.005 USDC per query) via HTTP 402 challenge-response on Base (Chain ID
8453). - Native Base USDC token:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913. - Supports EIP-712/EIP-191 cryptographic signatures and facilitator verification.
- Enforces micro-payments (0.005 USDC per query) via HTTP 402 challenge-response on Base (Chain ID
-
Multi-Agent Standards Native:
- Google AP2 (
/.well-known/ap2): Agent Protocol v2 manifest. - Model Context Protocol (MCP): Tool schema definitions (
mcp_tool_spec.json) and/mcp/invokedispatcher. - OpenAPI / Swagger (
/docs): Standard machine-readable and interactive API documentation.
- Google AP2 (
📁 Repository Structure
minerals-oracle-x402/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI application, routing & MCP endpoints
│ ├── feed_engine.py # Deterministic commodity pricing, spread & scrap engine
│ ├── x402_verifier.py # HTTP 402 challenge & EIP-712 payment verifier
│ └── schemas.py # Pydantic data contracts & schemas
├── tests/
│ ├── __init__.py
│ └── test_client.py # Autonomous agent payment test suite
├── .well-known/
│ └── ap2.json # Google Agent Protocol AP2 manifest
├── mcp_tool_spec.json # FastMCP tool definition for LLM agents
├── Dockerfile # Ultra-lightweight multi-stage container
├── requirements.txt # Python dependencies
└── README.md # Documentation & quickstart
🚀 Quick Start
1. Local Setup
# Clone and enter directory
cd minerals-oracle-x402
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run development server
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
Interactive documentation will be available at http://localhost:8000/docs.
2. Running via Docker
# Build lightweight container
docker build -t minerals-oracle-x402 .
# Run container
docker run -p 8000:8000 minerals-oracle-x402
💳 x402 Payment Flow Specification
sequenceDiagram
autonumber
actor Agent as Autonomous AI Agent
participant Oracle as minerals-oracle-x402
participant Base as Base Network (USDC)
Agent->>Oracle: GET /api/v1/oracle/prices
Oracle-->>Agent: HTTP 402 Payment Required<br/>(Nonce, Price: 0.005 USDC, Base Chain ID: 8453)
Note over Agent: Agent signs payment challenge<br/>using private key (EIP-712/EIP-191)
Agent->>Oracle: GET /api/v1/oracle/prices<br/>Header: Authorization: x402 <base64_payload>
Oracle->>Oracle: Verify signature / Facilitator settle
Oracle-->>Agent: HTTP 200 OK<br/>Certified Oracle Feeds & Attestation Hashes
Payment Authorization Header Format
Authorization: x402 eyJub25jZSI6ICIxYTIz...IiwgInNpZ25hdHVyZSI6ICIweDk5...In0=
Where the decoded JSON payload contains:
{
"nonce": "7f8b92c4a90184b2ef019a823b102938",
"signature": "0x...",
"signer": "0xYourAgentWalletAddress"
}
🤖 MCP (Model Context Protocol) Integration
To use with Claude Desktop, Cursor, Gemini or Antigravity agents, load mcp_tool_spec.json.
Available tools:
get_mineral_prices: Retrieve all current spot prices and unit conversions.get_arbitrage_spreads: Fetch COMEX/LME/SMM basis spreads and margins.calculate_urban_mining_value: Calculate batch recovery yields for EV Black Mass, Auto Catalysts, E-Waste, or Permanent Magnets.
Example Python Agent MCP tool call:
import httpx
resp = httpx.post(
"http://localhost:8000/mcp/invoke",
json={
"name": "calculate_urban_mining_value",
"arguments": {
"scrap_category": "EV_BATTERY_BLACK_MASS",
"quantity_metric_tons": 5.0,
"custom_assay_overrides": {"Li": 4.1, "Co": 6.5}
}
},
headers={"X-Dev-Bypass": "true"} # Or with valid x402 signature
)
print(resp.json())
🧪 Running Tests
Execute the automated test suite verifying 402 challenge flow, EIP-712 cryptographic verification, scrap calculations, and AP2 endpoints:
pytest -v tests/test_client.py
📜 License
MIT License. Built for Autonomous Agent Commerce and Critical Mineral Resilience.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。