Pi SoloHost AI CostGuard
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Pi SoloHost AI CostGuard & x402 Compute Router
Self-hosted AI cost comparator, 80/20 hybrid LLM compute router, local monthly spend redline guard, Streamable HTTP MCP server, Pi SDK Testnet integration, and x402 HTTP 402 compute metering sandbox — packaged natively for Pi Desktop SoloHost.
Live Static Preview (GitHub Pages): https://xgbtxy.github.io/pi-solohost-costguard/
Privacy Policy: https://xgbtxy.github.io/pi-solohost-costguard/privacy.html
PiNet Metadata JSON: https://xgbtxy.github.io/pi-solohost-costguard/pinet-metadata.json
Container Image (GHCR):
ghcr.io/xgbtxy/pi-solohost-costguard:1.0.0(linux/amd64,linux/arm64)Pi SoloHost Package Files:
solohost/docker-compose.yml&solohost/config_options.yml(verifiedok: trueagainst Pi's official SoloHost staging validator)
Why This Matters for 420K+ Pi Desktop Node Operators & AI Builders
AI developers and node operators routinely overpay 4x–10x on LLM API bills by sending routine classification, summarization, and extraction requests to flagship frontier models. AI CostGuard runs locally inside Pi Desktop SoloHost (127.0.0.1:18080, zero external dependencies, zero tracking, zero secret leakage) to solve four concrete problems in one container:
12 Official LLM API Cost Comparator: Real-time per-request, monthly, and annual USD comparison across 12 official public API models (OpenAI, Anthropic, Google, DeepSeek, Mistral), factoring in prompt-cache discounts.
80/20 Hybrid Compute Router: Calculates exact monthly/annual USD savings for Hybrid 80/20, Ultra-Frugal 90/10, and Frontier-First 30/70 policies, generating a concrete task-tier routing specification.
Local Spend Redline Guard (
/data/state.json): Enforces operator-configured monthly USD spend ceilings (OK/WARNING/BREACH) and computes automatic hybrid downshift fallbacks whenever projected burn exceeds budget.Native MCP + Pi SDK + x402 Stack:
Streamable HTTP MCP Server (
POST /mcp): Exposesestimate_llm_cost,optimize_hybrid_route, andcheck_budget_redlineto any MCP-compatible AI agent.Pi SDK 3-Phase Testnet Payments: Integrates
Pi.init,Pi.authenticate,Pi.createPaymentwith server-sidePOST /api/pi/approveandPOST /api/pi/complete(relays tohttps://api.minepi.com/v2/paymentswhenPI_API_KEYis configured, or runs safely in zero-key Testnet simulation mode when blank).x402 Programmatic Compute Metering (
POST /api/x402/route-audit): Returns a standards-compliant HTTP402 Payment Requiredchallenge with base64PAYMENT-REQUIREDheader (Base Sepoliaeip155:84532/ Base Mainneteip155:8453, publicpayToonly, zero private keys) and an instant free preview at?sample=true.
Related MCP server: agent-budget
Architecture
flowchart LR
Op["Pi Desktop / Pi Browser Operator"] -->|"127.0.0.1:18080 (SoloHost)"| Web["CostGuard Server (Node 20 ESM, zero deps)"]
Agent["Local AI Agent / IDE"] -->|"POST /mcp (JSON-RPC 2.0)"| Web
X402["Programmatic x402 Client"] -->|"POST /api/x402/route-audit (402 / 200)"| Web
Web -->|"Persist policy & audits"| Vol[("Named Volume /data/state.json")]
Web -.->|"Optional when PI_API_KEY set"| PiAPI["https://api.minepi.com/v2/payments"]1-Click Pi SoloHost Deployment
Open Pi Desktop SoloHost (or SoloHost Publisher).
Paste
solohost/docker-compose.ymlandsolohost/config_options.yml.Configure your local loopback port (
18080), monthly USD budget redline (25), default routing profile (hybrid_80_20), and optionalPI_API_KEY(leave blank to start immediately in zero-key Testnet simulation mode).Click Install & Launch — Pi Desktop pulls
ghcr.io/xgbtxy/pi-solohost-costguard:1.0.0, starts the container on127.0.0.1:18080, verifies/health, and embeds the UI directly in the App tab.
Reproducible Live SoloHost Validation
Verify the package directly against Pi's official authoritative staging validator:
npm run validate:solohost
# Or also preview the exact generated .env file:
node scripts/validate-solohost.mjs --preview-envLocal Standalone Quickstart (Zero npm install Needed)
Requires Node.js 20+.
git clone https://github.com/xgbtxy/pi-solohost-costguard.git
cd pi-solohost-costguard
cp .env.example .env
npm start
# Open http://127.0.0.1:8080Run the full automated test suite:
npm testMCP Client Configuration
Connect any Streamable HTTP MCP client (Claude Desktop bridge, Cursor, Windsurf, custom agents) to your running SoloHost instance:
{
"mcpServers": {
"pi-solohost-costguard": {
"transport": "streamable-http",
"url": "http://127.0.0.1:18080/mcp"
}
}
}Quick curl smoke test:
curl -s -X POST http://127.0.0.1:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'x402 HTTP 402 Metering Demo
# 1. Inspect the standards-compliant HTTP 402 challenge & PAYMENT-REQUIRED header:
curl -i -X POST http://127.0.0.1:8080/api/x402/route-audit \
-H "Content-Type: application/json" \
-d '{"requestsPerMonth":10000,"monthlyBudgetUsd":25}'
# 2. Fetch a free live 12-model routing audit preview (HTTP 200):
curl -s -X POST "http://127.0.0.1:8080/api/x402/route-audit?sample=true" \
-H "Content-Type: application/json" \
-d '{"requestsPerMonth":10000,"monthlyBudgetUsd":25}'Security & Privacy Guarantees
Zero runtime npm dependencies — dramatically reduces supply-chain attack surface.
Non-root container (
USER node) onnode:20-alpinewith loopback-only host binding (127.0.0.1:${PORT:-18080}:8080), no privileged flags, no host bind mounts, and bare named volume persistence (costguard_data:/data).Zero private keys — x402 endpoints use only public recipient address metadata (
X402_PAY_TO).Strict secret isolation — optional
PI_API_KEYstays server-side (preserve_if_blank: trueinconfig_options.yml) and is never serialized to browser HTML,/health, or/api/config.PI_OPERATOR_HANDLE(detect: pi_username) is strictly for optional local attribution/display and is never used for authentication, ownership, or access control.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Ledger of record for AI spend: verifiable receipts, waste auditor & model arbitrage MCP.
Agent Cost Allocator MCP — multi-tenant LLM cost attribution for chargeback billing. Companion to
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceBudget & cost control for AI agents: hard per-agent spend caps, rate limits, idempotency, and human-in-the-loop approval — enforced before each LLM call, not after the invoice. One hosted MCP endpoint (no proxy or self-hosting), settled via x402 (USDC on Base).MIT
- AlicenseNot gradedqualityCmaintenanceBudget management and cost tracking MCP server for autonomous agents, enabling budget creation, cost recording, spending projections, and alert rules.MIT
- AlicenseNot gradedqualityCmaintenanceLocal-first cost tracking and model routing for MCP agents with offline token counting, budget alerts, and spend reports.63 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to monitor running loops, estimate token consumption and monetary cost, prune verbose thinking chains near limits, and route sub-tasks between fast/cheap models and deep reasoning engines. It provides budget-aware model routing and telemetry through MCP.7MIT