Water devices and characteristic points

MCP: wywołaj read_docs({ operations: [operation] }) i podaj tylko pola ze zwróconego inputSchema. Przykłady HTTP poniżej zawierają kopertę zapisu, requestId i identyfikatory nadawane przez MCP (projectId przy tworzeniu, documentId przy tworzeniu dokumentu). Nie dodawaj tych pól do wywołania MCP. Typ rewizji bierze się ze schematu operacji.

Use the action schemas with user bearer authentication.

POST action Purpose
/api/v1/actions/water-design/query Devices, services, saved calculations and revisions; see query kinds
/api/v1/actions/water-design/commands Typed create, edit, delete and calculation workflows
/api/v1/actions/characteristic-points/list Retained engineering points
/api/v1/actions/characteristic-points/commands Create, edit, locate or delete points
/api/v1/actions/water-device-points/references Read device and point links
/api/v1/actions/water-device-points/commands Change links or create and link atomically

Water Design is the shared command envelope and revision for devices, services, catchments and calculations.

Read the current domain revision before a command. Keep the write envelope when recovering the same attempt. Command variants describe their required fields.

Query kinds

water-design/query takes {"projectId":"<projectId>","query":{"kind":"<kind>",...}}. query.kind selects one of these queries; each accepts only its listed fields. An unknown kind is refused with an issue at query.kind that names the allowed kinds.

Kind Fields Result
revision — Current water-design revision
tree — Device groups with their items
device deviceId device, or null
evidence_devices deviceIds (1–200) devices
device_mention deviceId device, or null
device_mentions limit (1–50), optional search items
description groupId, descriptionType (operat or technical) One group description with bodyMarkdown and bodyRevision
descriptions descriptionType, optional afterGroupId, optional limit (1–3) descriptions and nextCursor
service serviceId service, or null
services Optional category (water-service or special-water-use), afterId, limit (1–3) services and nextCursor
calculations, unreadable_calculations, calculation, calculation_dependencies, dependency_options See calculation queries

Every water-design result except the calculation queries also returns the current revision.

Points, parcels and devices

Retain 20 outlets and their locations with few calls. Examples show one item; put all points in one import, create all devices in one batch, then assign the parcels under every device in one call. Parcel discovery and acceptance below are for points without devices and for road corridors.

Project and points

GET /api/v1/me has account identity only. The cheapest existing public v1 read for the personal organization ID is GET /api/v1/projects: extract access.organizationId once (for example, pipe the response to jq -r .access.organizationId) and retain it for project creation. No individual project reads are needed, even when the account also has team projects.

Send x-operat-write-contract: <writeContract.value from GET /api/v1/actions> with every write, starting with this one; without it the write fails with write_contract_missing. Headers.

POST projects/create:

{"organizationId":"<personalOrganizationId>","projectId":"<fresh-uuid-1>","name":"Wyloty kanalizacji deszczowej","type":"operat","requestId":"outlets-demo-1"}

Returns {"project":{"id":"<projectId>"}}.

Generate the projectId (a random UUID v4) and the requestId once per project. After a lost or timed-out answer, send the identical body again: the project is created once.

Use project.id below.

POST characteristic-points/commands:

{"projectId":"<projectId>","input":{"command":{"kind":"import","points":[{"id":"point-1","name":"Wylot 1","projection":"EPSG:2180","source":"import","northing":235835.349,"easting":575680.518}]},"write":{"sessionId":"<fresh-uuid-1>","lane":"project-presentation","sequence":1}}}

Returns {"result":{"kind":"imported","pointIds":["point-1"]},"change":{"revision":"<returned-revision>"}}.

Import up to 500 points at once. Keep caller point IDs for device links.

Characteristic Points use northing and easting in the supplied projection. Polish survey X is northing; Y is easting. Map/parcel coordinates use [easting,northing].

Parcels, with optional EGiB evidence

POST location/parcels/discover-point:

{"projectId":"<projectId>","points":[{"easting":575680.518,"northing":235835.349,"projection":"EPSG:2180"}]}

Returns {"results":[{"candidate":{"clickPoint":{"easting":575680.518,"northing":235835.349,"projection":"EPSG:2180"},"displayNo":"278","externalId":"060901_5.0010.278","featureId":null,"geometry":{"format":"geojson","projection":"EPSG:2180","geometry":{"type":"Polygon","coordinates":[[[575670,235825],[575695,235825],[575695,235850],[575670,235850],[575670,235825]]]}},"municipalityName":"Bełżyce","precinctName":"Matczyn","source":"click"}}]}.

Send up to 200 points; results follows input order, including candidate:null for misses. Deduplicate non-null candidates by externalId and bind candidates to those complete objects. Discovery and EGiB batches have a 20,000-total-vertex cap; split larger batches. Single-point {projectId,point} returns {candidate}. Project-free POST /api/v1/parcels/lookup is useful for standalone lookup; its response does not feed acceptance.

POST location/parcels/candidate-egib-details:

const detailsInput = { projectId, candidates: candidates.map(candidate => ({ candidate, subscriptionId: crypto.randomUUID() })) };

Returns {"results":[{"operation":{"id":"<fresh-uuid-3>","status":"pending"},"subscriptionId":"<fresh-uuid-2>"}]}.

Send up to 200 candidate/subscription pairs. results follows input order; bind it to detailsResults. Optional: accept immediately with these IDs, even while pending. To add without EGiB evidence, skip this request and set both EGiB keys to null in acceptance. Retaining EGiB source evidence is separate from creating EGiB request forms.

POST location/parcels/accept:

const acceptanceInput = {
  projectId,
  write: { sessionId: "<fresh-uuid-1>", lane: "project-presentation", sequence: 2 },
  candidates: candidates.map((candidate, index) => ({ parcelId: crypto.randomUUID(), candidate,
    egibOperationId: detailsResults[index].operation.id, egibSubscriptionId: detailsResults[index].subscriptionId })),
};

Returns {"accepted":[{"parcelId":"<fresh-uuid-4>","externalId":"060901_5.0010.278","created":true,"egibEvidence":true}]}.

One acceptance supports 200 distinct cadastral candidates. Deduplicate by candidate.externalId; generate one project parcel UUID per candidate. Reuse that UUID for all devices on the same parcel. egibEvidence:true means the read was attached, not that records were found.

Parcels along the road corridor

Call maps/roads/axis with bufferM:1 and retain its complete response as roadAxis1m. Bind the region response’s complete candidates and accept them using the request above.

POST location/parcels/discover-region:

const roadParcelDiscovery = {projectId,geometry:{format:"geojson",projection:"EPSG:2180",geometry:roadAxis1m.buffer},limit:200};

Devices, parameters and water service

POST water-design/query with {"projectId":"<projectId>","query":{"kind":"revision"}} returns {"kind":"revision","revision":{"revision":"<returned-revision>"}}. Use the actual inner revision as input.expectedRevision below. Use one expected revision for each batch. Its change.revision is the next command’s revision.

POST water-design/commands:

{"projectId":"<projectId>","input":{"command":{"kind":"workflow","operation":{"kind":"batch_devices","operations":[{"kind":"create_device","id":"outlet-1","featureId":"outlet-feature-1","groupId":"outlets","groupLabel":"Wyloty","name":"Wylot 1","deviceType":"outlet","workScope":"Budowa","pointIds":["point-1"],"parcelIds":[],"pointStyle":null,"evidencePolicy":null}]}},"expectedRevision":"<returned-revision>","write":{"sessionId":"<fresh-uuid-1>","lane":"project-presentation","sequence":3}}}

Returns {"result":{"kind":"devices_applied","results":[{"kind":"device_created","deviceId":"outlet-1"}]},"change":{"revision":"<returned-revision>"}}.

Put all 20 operations in operations (maximum 200). They run in order, atomically at one expected revision; any failure rolls back the whole batch. Each operation is create_device, replace_device (same fields except groupLabel) or delete_device (id only). The first device creates its group. Choose the actual scope and device type (outlet for this demo).

workScope: Budowa, Przebudowa, Likwidacja, Istniejący, Remont, Rozbudowa.

deviceType: storage_reservoir, pond, ditch, pier, footbridge, bridge, culvert, outlet, water_intake, outlet_spillway_structure, pond_monk, sluice_gate, pipeline, other.

Parcels under devices

POST water-design/devices/assign-parcels:

{"projectId":"<projectId>","write":{"sessionId":"<fresh-uuid-1>","lane":"project-presentation","sequence":4}}

Returns {"started":true}.

One call assigns parcels to every device: the parcel at each point, every parcel within 1 m of its line drawings and every parcel under its polygon drawings. It adds the parcels the project lacks, links each to its devices and never removes a link. It runs as one job per project; a call while it runs answers {"started":false} and joins it, and a call after it adds only what is missing.

POST water-design/devices/parcel-assignment with {"projectId":"<projectId>"} until status is done:

Returns {"status":"done","devices":20,"parcelsAdded":18,"unassigned":[{"deviceId":"outlet-7","reason":"not-found"}]}.

unassigned lists each device without any parcel: no-location (no points or drawings), too-large (its area needs more than one parcel search; use discovery on shorter parts), not-found or failed (call again later). MCP's water-design/devices/assign-parcels waits for the result itself.

POST water-design/commands:

{"projectId":"<projectId>","input":{"command":{"kind":"workflow","operation":{"kind":"put_description","groupId":"outlets","descriptionType":"operat","expectedBodyRevision":null,"bodyMarkdown":"| Urządzenie | Parametr | Wartość |\n| --- | --- | --- |\n| Wylot 1 | Średnica | 400 mm |\n| Wylot 1 | Materiał | beton |"}},"expectedRevision":"<returned-revision>","write":{"sessionId":"<fresh-uuid-1>","lane":"project-presentation","sequence":5}}}

Returns {"result":{"kind":"description_saved","bodyRevision":"<returned-revision>"},"change":{"revision":"<returned-revision>"}}.

descriptionType: operat, technical.

There is no device parameters field. For an existing description, query {"kind":"description","groupId":"outlets","descriptionType":"operat"} and use its bodyRevision instead of null.

POST water-design/commands:

{"projectId":"<projectId>","input":{"command":{"kind":"workflow","operation":{"kind":"create_water_service","id":"stormwater-service","category":"water-service","serviceType":"stormwater-discharge","parameters":{},"status":null,"notes":null,"targets":[{"kind":"group","groupId":"outlets"}]}},"expectedRevision":"<returned-revision>","write":{"sessionId":"<fresh-uuid-1>","lane":"project-presentation","sequence":6}}}

Returns {"result":{"kind":"water_service_created","serviceId":"stormwater-service"},"change":{"revision":"<returned-revision>"}}.

To inspect accepted parcels POST location/get with {"projectId":"<projectId>","domain":"location_parcels"}.

domain: location_parcels, location_inspections, location_stakeholders, location_documents.

Device evidence

POST evidence/refresh:

{"projectId":"<projectId>","profileId":"hydro.water-device-evidence","targetRefs":[{"domain":"objects","entityType":"water-device","entityId":"outlet-1","projectId":"<projectId>"}]}

Returns {"results":[{"planned":{"runId":"<runId>","createdRun":true},"targetRef":{"entityId":"outlet-1"}}]}.

Put all devices in targetRefs (1–200 distinct targets in this project). One call schedules them all. Omit scope for the full profile. Results follow input order and retain each target identity; provider acquisition runs in the background. A missing target or more than 5,000 probes refuses the whole batch; split targets or narrow scope. Single-target requests with targetRef still return a single result.

POST evidence/report:

{"projectId":"<projectId>","profileId":"hydro.water-device-evidence","targetRefs":[{"domain":"objects","entityType":"water-device","entityId":"outlet-1","projectId":"<projectId>"}]}

Returns {"results":[{"targetRef":{"entityId":"outlet-1"},"report":{"settled":true,"status":"fresh","progress":{"done":11,"failed":0,"total":11,"percent":100},"providerResults":[{"status":"success","canonicalRecords":[{"recordType":"jcwp","nationalCode":"<JCWP code>","name":"<JCWP name>","basinAuthority":"<Zarząd Zlewni>","basinAuthorityAddress":"<authority address>"}]}]}}]}.

Poll until every results[].report.settled is true. Read its providerResults[].canonicalRecords for typed facts, groups[].sections for displayed fields and sourceResults for source status. Never infer a fact from a missing record.