← Back to NwTwin

MCP tools

Ten tools cover the whole surface, so an assistant can read a network, change it, break it on purpose, score it and explain the result without you touching the UI.

The endpoint

The app serves a Model Context Protocol endpoint at http://localhost:8946/mcp over Streamable HTTP, or on stdin/stdout for a client that launches the app itself. Any MCP client reaches it: Claude Desktop, Claude Code, or your own agent. Setup instructions for each come with the app.

The tools are local. They read and write the network files on your machine, and the only call that leaves it is analyze, which goes to the AI provider you configured. No key, no outbound traffic, and the other nine still work.

Creating

ToolTakesWhat it does
create_network name (optional) Makes a new network and returns its id. It arrives empty and in Draft, with no nodes, no links and no scores, the same thing the New button in the app produces. Fill it with edit_network or modify_network, then score it. Without this an assistant could only work on networks that already existed.

Reading

ToolTakesWhat you get
list_networks nothing Every network with its id, name, state (Draft, Waiting, Processing, Ready, Error) and current scores. The usual first call, because every other tool wants an id.
get_network id The full topology: nodeDataArray, linkDataArray and the netai results block. This is the structure to read before editing, since the edit tools speak the same shape.
get_results id The score breakdown: overall base and simulated numbers, per-scenario results, and a score for every node and every link. Run the simulation first, or you get the previous run's numbers.

Changing

ToolTakesWhat it does
edit_network id, nodes, links Replaces the node array, the link array, or both, wholesale. Nodes carry id, label and type (c for core or tandem, a for access, omitted for a site); links carry id, from and to. Use it when an agent has built a whole topology.
modify_network id, ops The surgical counterpart: a list of operations (add_node, update_node, delete_node, add_link, update_link, delete_link) applied in order and saved once. Deleting a node deletes its links. A bad operation aborts the whole batch, so a half-applied edit never reaches disk.
set_failures id, down_nodes, down_links Marks nodes and links as down, which is the scenario the sim scores get measured against. It clears previous failures first, so each call states the whole outage rather than adding to it; two empty arrays reset the network to healthy.
scenario_weights weights (optional) With no argument, returns the current weights. With one, changes how much each scenario counts toward the index. All ones is the plain average; zero drops a scenario from the mean. Weights are recorded on the run, so a stored score says how it was computed.
Changing a weight rescores nothing on its own. Scores are stored with the network, so anything already marked Ready keeps its old numbers until it is run again.

Running

ToolTakesWhat it does
run_simulation id Runs the survivability algorithm and waits for it, up to 120 seconds, then returns the base and simulated scores. The work happens on a worker thread, so the browser UI stays responsive while an agent drives it. Call set_failures first if the run is meant to model an outage.
analyze id, question Hands the topology and its scores to the AI provider you configured, with your question attached. The only tool that needs a key, and the only one that sends anything off the machine.

The order they go in

A full pass is five calls, and an agent generally works them in this order:

create_network         # only for a network that does not exist yet
list_networks          # otherwise, find the id
get_network            # read the topology before touching it
set_failures           # state the outage to model
run_simulation         # score it, and wait
get_results            # per-node and per-link breakdown

What those scores mean, and what the scenarios actually remove, is on Under the index.