GridIntake MCP Server
README.md
# GridIntake
**An agent for the registration desk of a German grid operator: it processes wallbox, heat-pump and battery registrations end to end, and hands an engineer only the cases that need judgement.**
Delivered the way a forward-deployed engineer would hand it to a client: an **MCP server** that exposes the client's systems as tools, three **Agent Skills** (`SKILL.md` packages), a **LangGraph** agent with human-in-the-loop approval, a **rule pack** the client's team owns, an **eval pipeline** that gates CI, and a **process one-pager** for non-technical stakeholders.
[](https://github.com/JoshilFernandes/grid-intake-agent/actions/workflows/ci.yml)




## The problem
Every new wallbox, heat pump or home battery has to be registered with the local grid operator. All charging points must be notified, and total charging power above 12 kVA needs the operator's consent, answered within two months (NAV §19). Since 2024, devices above 4.2 kW must also be controllable by the operator, who in return may not refuse or delay them because of possible local congestion (§14a EnWG). Registrations arrive through portals and, very often, as free-text e-mails from electricians, and desks check them by hand.
## What the agent does
| Step | What happens | LLM? |
|---|---|---|
| **Extract** | Portal JSON is used as-is. Installer e-mails (German) are turned into the same schema, by an LLM with structured output or by an offline parser | yes (optional) |
| **Check rules** | The operator's rule pack: mandatory fields, meter-number format, installer register, documents, NAV §19 consent threshold, §14a controllability | no |
| **Grid screen** | Looks up the address's substation and its load after the new device (with simultaneity factors) | no |
| **Decide** | Auto-confirm / request missing info / engineer review / not a registration. A small, tested policy function | no |
| **Reply** | German letter from the `customer-reply-de` skill templates | no |
| **Engineer review** | LangGraph `interrupt()`; the case waits (checkpointed) until an engineer approves or declines from the CLI or any MCP client | human |
| **Report** | Plain-language desk report: outcomes, deadlines, effort estimate with stated assumptions | no |
The LLM only turns unstructured text into data. Routing and every customer-facing commitment come from deterministic rules the client can read and change.
## Run it (no API key needed)
```bash
git clone https://github.com/JoshilFernandes/grid-intake-agent.git
cd grid-intake-agent
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
python -m gridintake demo # process the 14 sample registrations
python -m gridintake show GR-2611-005 # one case with its German reply draft
python -m gridintake decide GR-2611-003 --approve --engineer "A. Meier"
python evals/run_evals.py # eval gate
```
Sample output of the demo:
```
[OK ] GR-2611-001 portal auto_confirm Complete notification, registered installer, grid headroom available
[ENG] GR-2611-003 portal engineer_review Charging power 22.0 kVA exceeds 12.0 kVA: DSO consent required, answer due within 60 days
[ASK] GR-2611-005 email:rules request_info heat_pump 9.0 kW: controllability (§14a EnWG) not stated
[ENG] GR-2611-006 portal engineer_review Substation ONS-205 would carry 361.6 kVA, above its planning limit of 360 kVA (90% of 400 kVA) ...
[---] GR-2611-008 email:rules reject No wallbox, heat pump or storage found in the request
```
Full stakeholder report: [`docs/sample-desk-report.md`](docs/sample-desk-report.md).
### Use a real LLM for e-mail extraction
```bash
pip install -e ".[groq]" # or [anthropic] / [openai] / [ollama]
export GRIDINTAKE_LLM=groq:llama-3.3-70b-versatile GROQ_API_KEY=...
python evals/run_evals.py # same golden set, now measuring the LLM
```
## Use it from Claude (MCP + Skills)
```json
{
"mcpServers": {
"gridintake": { "command": "python", "args": ["-m", "gridintake.mcp_server"], "cwd": "/path/to/grid-intake-agent" }
}
}
```
Copy the folders in [`skills/`](skills) into your skills directory, then ask *"Triage the registration inbox"*. The `grid-request-triage` skill tells the agent which tools to call in which order, when to stop for an engineer, and why it must not decline a §14a device for congestion.
| MCP | Name | Purpose |
|---|---|---|
| tool | `list_inbox`, `get_request` | Read the queue |
| tool | `process_request` | Run the whole pipeline for one case |
| tool | `check_rules`, `lookup_grid_capacity` | Single steps, for "why?" questions |
| tool | `list_engineer_queue`, `decide_request` | Human-in-the-loop |
| tool | `desk_report` | Plain-language report |
| resource | `rules://active`, `docs://process` | Context the agent reads instead of guessing |
| prompt | `triage_inbox` | Starts a triage session |
| Skill | What it encodes |
|---|---|
| [`grid-request-triage`](skills/grid-request-triage/SKILL.md) | Tool order, routing rules, §14a guardrail, output format |
| [`customer-reply-de`](skills/customer-reply-de/SKILL.md) | Seven German letter templates and writing rules |
| [`capacity-assessment`](skills/capacity-assessment/SKILL.md) | How to read the grid screen and what to recommend |
## Evals
`evals/run_evals.py` runs on every push (see [`evals/report.md`](evals/report.md)):
| Metric | Result | Gate |
|---|---|---|
| Routing accuracy (14 cases) | 1.00 | ≥ 0.95 |
| Rule-flag recall | 1.00 | ≥ 0.95 |
| E-mail extraction accuracy | 1.00 | ≥ 0.90 |
| Unsafe auto-confirms | 0 | = 0 |
| German replies well-formed | 1.00 | = 1.00 |
| SKILL.md files valid | 1.00 | = 1.00 |
Plus 15 unit tests, including a case that pauses for an engineer, survives a process restart and resumes.
## Rolling it out at a client
- [`docs/process-before-after.md`](docs/process-before-after.md): one page for managers and the works council: today's process, the new one, what stays with people, how a pilot is measured.
- [`docs/deployment-playbook.md`](docs/deployment-playbook.md): week-by-week path from shadowing the desk to production, and which parts are reusable for other back-office processes.
- [`rules/dso_default.yaml`](rules/dso_default.yaml): a new grid operator is a new YAML file, not new code.
## Project layout
```
src/gridintake/
├── graph.py LangGraph state machine + routing policy
├── rules.py rule checks driven by the YAML rule pack
├── extraction.py LLM (init_chat_model + structured output) and offline e-mail parser
├── systems.py adapters: grid GIS, installer register, tickets (stand-ins for the client's systems)
├── replies.py German letters from the skill templates
├── mcp_server.py FastMCP server: tools, resources, prompt
├── report.py stakeholder report
└── service.py facade used by CLI, MCP and evals
skills/ three Agent Skills (SKILL.md + templates + script)
rules/ rule pack per grid operator
evals/ golden set + harness (CI gate)
data/ synthetic requests and client-system data
docs/ architecture, process one-pager, deployment playbook
```
## Scope and honesty notes
- All data is synthetic. The rule pack encodes the federal baseline (NAV §19, §14a EnWG) as summarised by [ADAC](https://www.adac.de/rund-ums-fahrzeug/elektromobilitaet/laden/wallbox-anmelden/) and the [Bundesnetzagentur](https://www.bundesnetzagentur.de/steuerbare-ve.html); each grid operator's own technical connection conditions (TAB) differ and must be checked before go-live.
- The grid screen is a triage aid with simple simultaneity factors, not a load-flow calculation.
- Time savings in the report are planning assumptions, labelled as such.
## Author
**Joshil Fernandes**, AI Automation Engineer, Berlin · [LinkedIn](https://www.linkedin.com/in/joshil-fernandes-56849841b) · [GitHub](https://github.com/JoshilFernandes)
MIT licensed.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues