Introducing a new way to review your PRs.

Read the announcement

jamaljsr / polar

One-click Bitcoin Lightning networks for local app development & testing

View on GitHub

19 documents · Updated Oct 19, 2026

docs / mcp-network-operations

MCP network operations

MCP network operations give an AI client a controlled way to inspect and change Polar's local Lightning Network simulations. The command set covers network and node life cycles, archive transfer, node links, and startup settings. Results flow back through the MCP tool registry and expose current network state in a form that an AI client can use.

Scope and system role

This page covers the network and node commands. It is a companion to Application state and MCP tools and MCP Taproot Asset operations.

The network command layer sits between an MCP client and Polar's network state. A client first discovers the available tool names and input rules. It then sends a command that the local bridge passes to the matching network action.

The following flow shows how a command changes a network and returns a result.

flowchart LR
    Client[MCP client] --> Bridge[Local MCP bridge]
    Bridge --> IPC[Application message layer]
    IPC --> Registry[Tool registry]
    Registry --> State[Network state]
    State --> Runtime[Docker network and node runtime]
    State --> Result[Network or operation result]
    Result --> Client

Tool discovery and registry

The registry is the single catalog for network tool names, descriptions, input schemas, and actions. The definitions in src/…/toolRegistry.ts are exposed for discovery, while execution resolves the requested name through that same catalog. This keeps the name that an AI client sees tied to the action that Polar runs.

Command discovery

The GET /api/mcp/tools endpoint returns the available MCP definitions. Network commands use the networkId value to select a network, while node commands use a node name within that network. list_networks is the main entry point when a client needs IDs and current state before it performs a change.

The registry includes these network commands:

AreaCommands
Network recordslist_networks, create_network, rename_network, delete_network
Archive transferimport_network_from_zip, export_network_to_zip
Network controlstart_network, stop_network
Node membershipadd_node, remove_node, rename_node
Node controlstart_node, restart_node, stop_node
Node settingsset_lightning_backend, set_tap_backend, update_node_command
Node informationlist_node_versions, get_default_node_command

References: src/…/toolRegistry.ts• L80-164 src/…/ipc.ts• L18-47 electron/mcpBridge.ts• L147-183

Command results

Successful commands return either the changed network, a changed node, or a small operation summary. A missing network, missing node, invalid input, or rejected state change returns an error instead of a partial success. Status values in returned data are converted to names such as Started, Stopped, or Error, so an AI client does not need to interpret numeric status values.

References: src/…/ipc.ts• L24-47 src/…/helpers.ts• L5-54 src/…/types.ts• L4-11

Network records and archives

Network record commands create and maintain the saved definition of a Polar simulation. Archive commands move that definition and its related data between Polar instances or storage locations.

Network inventory and creation

list_networks returns all networks with their configuration and status. create_network accepts a name, an optional description, and optional node requests. Each request names an implementation and can set a version and a positive count.

When a node request omits a version, Polar uses the latest supported version. If the request omits the node list, creation uses a basic network with two LND nodes and one Bitcoin Core node. The creation plan checks the required backend relationships and the version rules before it creates the network.

Supported creation types are:

TypeRole in a network
bitcoindBitcoin chain and wallet backend
LNDLightning node
c-lightningLightning node
eclairLightning node
litdLightning Terminal node with Lightning support
tapdTaproot Assets node

References: src/…/listNetworks.ts• L6-33 src/…/createNetwork.ts• L11-29 src/…/createNetwork.ts• L54-82 src/…/createNetwork.ts• L263-369

Network archive transfer

export_network_to_zip writes a stopped or failed network to a .polar.zip file. It needs a network ID and an absolute output path. import_network_from_zip reads a previously exported archive from an existing path and adds it as a new network.

The two commands form a round trip: export preserves a network for later use, and import restores it with a new local ID. A running network cannot be exported because its state can change during the archive operation.

References: src/…/exportNetwork.ts• L10-41 src/…/exportNetwork.ts• L52-77 src/…/importNetwork.ts• L9-36 src/…/importNetwork.ts• L40-65 src/…/network.ts• L997-1061

Network identity and deletion

rename_network changes a network's name and can replace its description. The name is the human-readable identity used by clients, but commands still select the record by networkId. delete_network permanently removes the network and its node data.

References: src/…/renameNetwork.ts• L10-47 src/…/renameNetwork.ts• L50-85 src/…/deleteNetwork.ts• L8-30 src/…/deleteNetwork.ts• L33-56

Network and node control

Control commands change whether a complete network or one node is active. They use the stored status as a guard and return the status after the requested action.

Network life cycle

start_network starts all Bitcoin and Lightning-related nodes in a network. stop_network shuts the network down in a controlled way. The network action also checks runtime needs such as available node images and ports, then waits for services to become ready before it reports startup as complete.

The network-level commands are:

CommandRequired selectionMain result
start_networknetworkIdUpdated network with started state
stop_networknetworkIdUpdated network with stopped state
delete_networknetworkIdConfirmation and removed network summary

References: src/…/startNetwork.ts• L8-31 src/…/startNetwork.ts• L33-59 src/…/stopNetwork.ts• L8-31 src/…/stopNetwork.ts• L33-59 src/…/network.ts• L735-803

Node life cycle

start_node, stop_node, and restart_node control one node selected by networkId and nodeName. Start accepts a stopped or failed node. Stop accepts only a started node. Restart accepts a started or failed node and performs a stop followed by a start.

These commands can select Bitcoin, Lightning, or Taproot Assets nodes by name. Their result reports the selected name, network ID, and the node's resulting status rather than returning a full network record.

References: src/…/startNode.ts• L9-43 src/…/startNode.ts• L53-87 src/…/stopNode.ts• L9-43 src/…/stopNode.ts• L53-87 src/…/restartNode.ts• L9-45 src/…/restartNode.ts• L47-104

Node membership and identity

Node membership commands change which services belong to a network. They also keep the saved network view, runtime definition, and visual network view aligned.

Node addition

add_node adds one supported implementation to an existing network. The version is optional and defaults to the latest supported version. If the network is active, the new node is started after it is added.

The command rejects unknown implementations, unknown versions, and unknown network IDs. The node type also affects its place in the network: Bitcoin nodes provide chain backends, Lightning nodes use Bitcoin backends, and Taproot Assets nodes use LND backends.

References: src/…/addNode.ts• L11-53 src/…/addNode.ts• L55-123 src/…/types.ts• L23-28 src/…/types.ts• L68-89

Node removal

remove_node permanently removes a named node and its data. If the network is active, Polar stops the node as part of the removal. The operation also applies the node-type rules that protect required relationships and active simulations.

A Bitcoin node cannot be removed when it is the only Bitcoin node. An LND node cannot be removed while a Taproot Assets node depends on it. A Lightning node cannot be removed while a network simulation uses it.

References: src/…/removeNode.ts• L9-43 src/…/removeNode.ts• L45-116 src/…/network.ts• L475-631

Node naming

rename_node changes the name of a Bitcoin, Lightning, or Taproot Assets node. The new name may contain letters, numbers, hyphens, and underscores, and it must not belong to another node in the same network.

Renaming is a coordinated change because other node links and saved runtime data use the node name. If the node was active, Polar stops the network during the change and starts it again afterward.

References: src/…/renameNode.ts• L9-49 src/…/renameNode.ts• L51-125 src/…/network.ts• L1122-1170

Node relationships and startup settings

Relationship and startup commands tune an existing node without changing the set of networks. They expose the links that make a multi-node simulation work and the command used when a node starts.

Backend relationships

set_lightning_backend changes the Bitcoin node used by a Lightning node. If that Lightning node is active, Polar restarts it so the new link takes effect.

set_tap_backend changes the LND node used by a Taproot Assets node. The target versions must be compatible. Polar also rejects a backend change after the Taproot Assets node has been started because changing the link could make its asset data unsafe.

References: src/…/setLightningBackend.ts• L8-49 src/…/setLightningBackend.ts• L51-82 src/…/setTapBackend.ts• L11-51 src/…/setTapBackend.ts• L53-117

Node command settings

get_default_node_command returns the standard startup command for an implementation and version. The command can include placeholders that Polar fills with the node's actual network context.

update_node_command replaces a node's startup command with a custom value. Passing an empty command resets the node to its default command. This setting changes future startup behavior; it does not itself start or restart the node.

References: src/…/getDefaultNodeCommand.ts• L11-49 src/…/getDefaultNodeCommand.ts• L52-77 src/…/updateNodeCommand.ts• L8-50 src/…/updateNodeCommand.ts• L52-97

Version and compatibility information

list_node_versions reports supported versions, the latest version for each implementation, and compatibility requirements. A client should use this command before it requests a pinned version or builds a mixed-version network.

The version data supports two decisions. Bitcoin backends must satisfy the requirements of their Lightning consumers, and an LND node must satisfy the minimum version required by a Taproot Assets node. create_network checks these relationships before it changes application state.

References: src/…/listNodeVersions.ts• L8-39 src/…/listNodeVersions.ts• L41-92 src/…/createNetwork.ts• L307-370

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep each network tool's definition, MCP model action, and TOOL_REGISTRY entry aligned. A definition without a registry executor can be discovered but cannot run.
  • Keep node implementation names and version data aligned with the node creation rules. The same names drive creation, addition, default commands, and compatibility checks.
  • Preserve network and node name links when changing rename, backend, or removal behavior. Backend fields and chart links use those names as references.
  • Preserve the export and import contract for .polar.zip files. The archive pair must continue to agree on path handling and restored network identity.
  • Preserve status guards and result serialization when changing start, stop, or restart behavior. MCP consumers depend on clear post-action status names.

Important failure modes

TriggerConsequenceGuard
A Lightning node is requested without a Bitcoin backendNetwork creation is rejectedInclude at least one compatible bitcoind node
More tapd nodes are requested than LND nodesNetwork creation is rejectedProvide one suitable LND backend for each Taproot Assets node
A pinned node version is not in the supported image listCreation or addition is rejectedCall list_node_versions before pinning versions
A start request names a missing image or an unavailable portThe network or node enters an error state and the command failsMake required images available and resolve port conflicts
A node command uses the wrong current statusThe operation is rejectedStart only stopped or failed nodes; stop only started nodes
A removal would leave no Bitcoin backend or would break an active dependencyNode removal is rejectedKeep a second Bitcoin backend and remove dependent links or simulations first
A Taproot Assets backend changes after the node has startedThe operation is rejected to protect asset dataSet the LND backend before first startup
An export targets a running network or an import path does not existNo archive is written or no network is importedStop the network and provide an existing .polar.zip path

Key files

FileWhy to read it
src/…/toolRegistry.tsShows the complete catalog and the link between public tool names and actions.
src/…/ipc.tsShows how discovery and execution cross from MCP into the application state layer.
src/…/createNetwork.tsExplains the high-level creation contract and backend/version checks.
src/…/listNodeVersions.tsDefines the version and compatibility information available to clients.
src/…/startNetwork.ts and src/…/stopNetwork.tsDefine whole-network control and its returned state.
src/…/startNode.ts, restartNode.ts, and stopNode.tsDefine node-level control and status rules.
src/…/addNode.ts and removeNode.tsDefine node membership changes and safety checks.
src/…/setLightningBackend.ts and setTapBackend.tsDefine the two backend relationships that connect node types.
src/…/network.tsShows how MCP requests affect saved network state and the running node environment.