chance-electro-pricing
Provides electrical pricing, cable sizing, and profitability analysis tools for construction estimating, integrating with Claude to answer pricing queries based on a US-market-calibrated price list and NEC standards.
README
Chance Electro — AI Project Advisor
Google × Kaggle Vibe Coding Capstone — Track: Agents for Business
A photo of a hand-drawn plan from a job site becomes a complete estimate package — commercial proposal, invoice, shop order, and a GO / NO-GO profitability verdict — in about 15 minutes instead of 2–3 days of manual work.
Before: 2–3 days of on-site manual take-off and pricing. After: ~15 minutes — one napkin photo → proposal + invoice + shop order + GO/NO-GO.
Chance Electro is a fictional US electrical contractor, but the workflow is real — it models how a small contracting business actually estimates: a US-market-calibrated price list, a crew cost model, and a margin target the owner manages to. Cost and revenue are on the line on every job: misprice one cable gauge and the margin is gone.
Architecture
Three specialized agents talk over the open A2A protocol (HTTP). Agents 2 and 3 run in parallel. Every priced number comes from an MCP server, so proposal and margin can never drift apart. A security layer wraps every LLM call and every A2A boundary.
<details> <summary>Text version of the diagram</summary>
napkin photo / ┌───────────────────────────────┐
PDF / text / ───────▶ │ Web UI · Orchestrator │ A2A client
voice / XLSX·DOCX └───────────────┬───────────────┘
│ A2A (HTTP)
┌───────────────▼───────────────┐
│ Agent 1 · Project Analyst │ Claude vision
│ (Agent Skill: cable sizing) │ + gap-filling quiz
└───────────────┬───────────────┘
structured project
┌───────────────┴───────────────┐
▼ (A2A · in parallel) ▼
┌────────────────────────┐ ┌────────────────────────┐
│ Agent 2 · Document │ │ Agent 3 · Profitability │
│ Factory │ │ Advisor │
└───────────┬─────────────┘ └────────────┬───────────┘
│ MCP tool call │ MCP tool call
└────────────────┬─────────────────┘
┌────────────▼─────────────┐
│ MCP Pricing Server │ price_estimate ·
│ (price list + economics + │ compute_margin ·
│ NEC cable standards) │ recommend_cable ·
└────────────────────────────┘
Guardrails wrap every LLM call and A2A border:
input validation + magic-bytes · prompt-injection (multilingual, Unicode-normalised) ·
output schema + prompt-leak screen · budget / kill-switch · audit trail
</details>
The six course concepts (this project uses five)
| Concept | Where | How |
|---|---|---|
| Multi-agent system | code | 3 independent A2A HTTP servers with agent cards; orchestrator/web are A2A clients; agents 2 & 3 run in parallel (agents/, serve.py, orchestrator.py) |
| MCP Server | code | mcp_server.py exposes the pricing/economics engine as MCP tools; all three agents are MCP clients at runtime (mcp_client.py) — no agent imports the engine directly; mcp_demo.py proves a standalone client↔server round trip |
| Agent Skills | code | skills/registry.py discovers skills on disk, selects by trigger, loads the body progressively, and invokes the skill's executable check (skills/electrical-estimating/), which drives a self-correction round in the analyst |
| Security features | code | guardrails.py — input + magic-byte validation, multilingual prompt-injection screen, output schema + prompt-leak screen, budget + kill-switch, and an audit trail; refusals return a clean HTTP 400 |
| Deployability | video + code | Live on a VPS: 3 agents + MCP server + web, behind systemd + Caddy (HTTPS); shown in the video, reproducible from deploy/ |
| Antigravity | — | not used (deliberate) |
On the multi-agent stack: the agents interoperate over the open A2A (Agent2Agent) protocol — Google's cross-framework agent-interoperability standard, the same protocol ADK agents use to talk to agents built on other stacks. Each agent publishes a standard agent card at
/.well-known/agent-card.json, and the orchestrator and web UI are plain A2A clients — so an ADK agent could discover and call these agents unchanged.
Economics (deterministic — no LLM)
Revenue comes from the price list; crew cost comes from one of two selectable models, so
the GO/NO-GO verdict is exact and reproducible and the sandbox sliders recompute instantly
(catalog.py::compute_economics):
- shares — by project value: R split into crew / foreman / overhead / subcontractor shares.
- hourly — by fully-burdened hourly rates × hours/day × days on site, plus a reverse calc ("max days on site that still keep the margin at target").
- GO/NO-GO = gross margin ≥ a configurable target (default 60%).
Cable pricing is gauge-accurate: the analyst classifies each circuit's load and picks the code-correct gauge (an oven feed gets 10 AWG (3×4mm²), not the default 12 AWG (3×2.5mm²)), which changes both the material spec and the labor price — an NEC-aligned estimating heuristic, not a stamped design.
Run it
Python 3.11.
python3.11 -m venv .venv
.venv/bin/pip install -r requirements.txt # or: uv venv && uv pip install -r requirements.txt
# Web UI (recommended) — open http://localhost:8080
./web.sh
# Dry run, no Claude calls, deterministic (for graders — costs nothing):
CAPSTONE_MOCK=1 ./web.sh
# CLI end-to-end:
./run_all.sh --napkin napkin.jpg
CAPSTONE_MOCK=1 ./run_all.sh --text "kitchen, electric oven, 6 sockets" --mode hourly --days 2
# MCP client↔server proof (no LLM needed):
python mcp_demo.py
Deploying to a server (systemd + Caddy/HTTPS) — see deploy/DEPLOY.md.
The web UI vendors its CSS/icon libraries under web/vendor/, so it stays fully
functional offline (the Google-hosted display font degrades to system fonts if unreachable).
CAPSTONE_MOCK=1 runs the whole A2A pipeline with deterministic mocks — a grader can
reproduce the demo without an API key or any spend. For live runs, copy .env.example to
.env and set ANTHROPIC_API_KEY (never committed — .env is git-ignored).
The launchers start the MCP pricing server first, then the three agents (they are its clients), then the web UI, freeing their ports first so a stale process can't answer.
Observability: GET /ops aggregates each agent's LLM budget (calls, tokens, ~cost) and
guardrail audit trail; the UI shows a "Run stats" line under the margin sandbox after a build.
Plug the pricing server into your own Claude (MCP)
The same MCP server the agents use plugs into Claude Desktop, Claude Code or Cursor over
stdio — so you can price electrical work by just asking Claude. Add to
claude_desktop_config.json (Settings → Developer → Edit Config):
{
"mcpServers": {
"chance-electro-pricing": {
"command": "/absolute/path/to/chance-electro-capstone/.venv/bin/python",
"args": ["/absolute/path/to/chance-electro-capstone/mcp_server.py"]
}
}
}
Then ask: "Which cable gauge does an electric oven feed need, and what does the run cost
per foot?" — Claude calls list_load_categories → recommend_cable and answers from the
price list instead of guessing. No API key is needed on the server side (the tools are
deterministic); mcp_demo.py scripts the same round trip if you'd rather see it in a terminal.
Code map
agents/ base.py · analyst.py · document_factory.py · profitability.py (A2A executors)
mcp_server.py pricing/economics engine exposed as MCP tools
mcp_client.py in-app MCP client — how the agents call the tools
catalog.py price list + sandbox + deterministic economics (behind the MCP server)
guardrails.py security layer (input / injection / output / budget / audit)
skills/ registry.py (skill runtime) + electrical-estimating/ (SKILL.md + scripts/)
schemas.py JSON contracts + deterministic mocks
web/ app.py (A2A client) + index.html (6-step estimator wizard, US documents)
features/ Gherkin BDD spec (behavior, written before the code)
data/ price_list.json · sandbox.json · electrical_standards.json
(demos.json is created at runtime when you save a project in the UI)
run_all.sh · web.sh launchers (MCP server + agents + orchestrator / web)
deploy/ systemd unit · Caddyfile example · DEPLOY.md
docs/ architecture.svg (rendered architecture diagram)
web/vendor/ vendored Tailwind + lucide (UI runs offline)
Known limitations
- Vision non-determinism — Claude vision can vary the scope it reads from one napkin; the estimate is a starting point a human confirms (HITL before anything is sent to a client).
- Wire-gauge notation — lengths and pricing are in US units (linear feet, USD) and wire gauges are AWG-first with the metric cross-section alongside — "12 AWG (3×2.5mm²)". The AWG mapping is ampacity-based, since the underlying price list is metric-derived.
- Estimating heuristic, not a stamped design — cable sizing is NEC-aligned for estimating, not a substitute for a licensed load calculation on large feeders.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。