NodePass MCP Reference

July 7, 2026 ยท View on GitHub

Overview

NodePass Master Mode exposes a Model Context Protocol (MCP) compatible management endpoint over HTTP JSON-RPC 2.0. MCP clients can use this endpoint to discover tools and manage NodePass instances through the same master process that provides the REST API.

The MCP implementation is intended for automation and AI-assisted operations. It can list and inspect instances, create new client or server instances, change instance configuration, control lifecycle state, export or import instance configuration, run TCP connectivity checks, and read or update master metadata.

Endpoint

MCP is available only in Master Mode.

nodepass "master://0.0.0.0:9090?log=info"

The MCP path is derived from the master API prefix:

Master URL pathREST base pathMCP endpoint
empty or //api/v1/api/v2
/admin/admin/v1/admin/v2

For the default master URL above, the MCP endpoint is:

http://127.0.0.1:9090/api/v2

If TLS is enabled for the master, use https:// with the same path.

Authentication

The MCP endpoint is protected by the same API key middleware as the protected REST endpoints. Include the API key in every request:

X-API-Key: <api-key>

The key is generated on first master startup, printed to stdout, and persisted in the master state file. Missing or invalid API keys return HTTP 401 before JSON-RPC handling.

Transport And Request Format

NodePass accepts HTTP POST requests with a JSON-RPC 2.0 body:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}

Headers:

Content-Type: application/json
X-API-Key: <api-key>

Only POST is accepted. Other methods return HTTP 405.

Successful JSON-RPC responses use HTTP 200 and contain result:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {}
}

JSON-RPC errors also use HTTP 200 and contain error:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32602,
    "message": "Invalid params",
    "data": "id is required"
  }
}

HTTP authentication and method errors are returned before JSON-RPC processing.

Supported JSON-RPC Methods

MethodDescription
initializeReturns the advertised MCP protocol version, server information, and capabilities.
tools/listReturns all available MCP tools with JSON schemas.
tools/callExecutes a tool. Tool arguments are provided in params.arguments.

initialize

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {}
}

Response fields:

FieldDescription
protocolVersionMCP protocol version advertised by NodePass. In this codebase the value is 2025-11-25.
capabilities.toolsTool capability declaration.
serverInfo.nameServer name, currently Master.
serverInfo.versionNodePass binary version.

tools/list

Request:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list",
  "params": {}
}

The response contains a tools array. Each item has:

FieldDescription
nameTool name used in tools/call.
descriptionHuman-readable tool description.
inputSchemaJSON schema for accepted arguments.

tools/call

Request:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "list_instances",
    "arguments": {}
  }
}

Most tool responses include a content array with text for MCP clients, plus structured fields such as instance, instances, config, result, or info.

Tool Summary

ToolPurpose
list_instancesList all managed instances except the internal API key record.
get_instanceGet one instance by ID.
create_instanceCreate and start a client or server instance from structured arguments.
update_instanceUpdate metadata such as alias, restart policy, peer, and tags.
control_instanceStart, stop, restart, or reset traffic counters.
set_instance_basicUpdate instance type, tunnel endpoint, target endpoint, targets, or log level.
set_instance_securityUpdate password, TLS mode, certificate paths, or SNI.
set_instance_connectionUpdate mode and connection pool settings.
set_instance_networkUpdate DNS, source IP, read timeout, bandwidth limit, or slot limit.
set_instance_protocolUpdate TCP/UDP switches and PROXY protocol behavior.
set_instance_trafficUpdate protocol blocking and load balancing.
set_instance_advancedUpdate arbitrary URL query parameters.
get_instance_configReturn a parsed, structured version of an instance config URL.
delete_instanceStop and remove an instance.
export_instancesExport instances to nodepass.json.
import_instancesImport instances from nodepass.json.
tcping_targetTest TCP connectivity to host:port.
get_master_infoReturn master and system information.
update_master_infoUpdate the master alias.

Common Arguments

Most instance configuration arguments are strings because they map directly to NodePass URL components or query parameters.

ArgumentDescription
idInstance ID. Generated as an 8-character hexadecimal string.
aliasHuman-readable instance alias.
typeInstance type: server or client.
tunnel_addressTunnel bind address for a server, or remote server address for a client.
tunnel_portTunnel port.
target_addressTarget host address.
target_portTarget port.
targetsMultiple targets in URL path form, for example host1:80,host2:80. Takes precedence over target_address and target_port.
passwordURL userinfo password used in the instance URL.
logLog level: none, debug, info, warn, error, or event.
tlsTLS mode: 0 none, 1 self-signed, 2 custom certificate.
crtCertificate file path when tls=2.
keyPrivate key file path when tls=2.
sniSNI hostname, mainly for client dual-end mode.
dnsDNS cache TTL, for example 5m or 1h.
lbsLoad balancing strategy. Current MCP schema exposes 0, 1, and 2.
modeRuntime mode: 0 auto, 1 reverse or single-end, 2 forward or dual-end.
minMinimum pool size. Usually used by client dual-end mode.
maxMaximum pool size. Usually used by server or dual-end mode.
poolConnection pool backend: 0 TCP, 1 QUIC, 2 WebSocket, 3 HTTP/2. Internally this maps to the URL query parameter type.
dialSource IP for outbound connections. Defaults to auto when not provided in the full generated config.
readRead timeout, for example 30s, 5m, or 1h.
rateBandwidth limit in Mbps. 0 means unlimited.
slotMaximum concurrent connection slots. 0 means unlimited.
proxyPROXY protocol v1: 0 disabled, 1 enabled.
blockProtocol blocking flags: 1 SOCKS, 2 HTTP, 3 TLS. Values may be combined, for example 123.
notcpTCP switch: 0 enabled, 1 disabled.
noudpUDP switch: 0 enabled, 1 disabled.

Instance Tools

list_instances

Arguments: none.

Returns:

FieldDescription
contentText summary such as Found 2 instances.
instancesArray of instance objects.

get_instance

Required arguments:

ArgumentDescription
idInstance ID.

Returns one instance object.

create_instance

Creates an instance from structured fields, stores it in master state, and starts it asynchronously.

Required arguments:

ArgumentDescription
typeserver or client.
tunnel_portTunnel port.
target_portTarget port, unless targets fully supplies the target path.

Optional arguments:

alias, tunnel_address, target_address, targets, password, log, tls, crt, key, sni, dns, lbs, mode, min, max, pool, dial, read, rate, slot, proxy, block, notcp, noudp.

Behavior:

  • Generates an 8-character instance ID.
  • Builds a server:// or client:// URL.
  • Applies provided URL query parameters.
  • Maps the MCP pool argument to the URL query parameter type.
  • Enhances the URL with master defaults such as log level, server TLS settings, and default server pool type when applicable.
  • Stores the instance with restart: true.
  • Starts the instance asynchronously.
  • Sends an SSE create event.

Example:

{
  "jsonrpc": "2.0",
  "id": 10,
  "method": "tools/call",
  "params": {
    "name": "create_instance",
    "arguments": {
      "alias": "web-tunnel",
      "type": "server",
      "tunnel_address": "0.0.0.0",
      "tunnel_port": "10101",
      "target_address": "127.0.0.1",
      "target_port": "3000",
      "log": "info",
      "pool": "0"
    }
  }
}

update_instance

Updates instance metadata. It does not change the tunnel URL.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

ArgumentTypeDescription
aliasstringUpdates the alias when non-empty.
restartbooleanControls auto-start on master state load.
peerobjectOptional peer metadata with sid, type, and alias.
tagsobjectReplaces the instance tag map. Values are converted to strings.

Limits:

  • alias, peer fields, tag keys, and tag values must not exceed 256 characters.
  • The internal API key record ID ******** cannot be updated.

control_instance

Required arguments:

ArgumentDescription
idInstance ID.
actionOne of start, stop, restart, or reset.

Behavior:

  • start starts the instance only if it is currently stopped.
  • stop stops the instance when it is not already stopped.
  • restart stops the instance, waits briefly, and starts it again.
  • reset sets TCP and UDP traffic counters to zero and persists the updated state.

The internal API key record ID ******** cannot be controlled.

set_instance_basic

Updates URL basics and restarts the instance with the new URL.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

type, tunnel_address, tunnel_port, target_address, target_port, targets, log.

At least one update must be provided. type must be client or server.

set_instance_security

Updates security-related URL values and restarts the instance.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

password, tls, crt, key, sni.

Empty password, crt, key, or sni values clear those fields. tls is updated only when non-empty.

set_instance_connection

Updates connection mode and pool settings, then restarts the instance.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

mode, min, max, pool.

pool maps to the URL query parameter type.

set_instance_network

Updates network tuning values, then restarts the instance.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

dns, dial, read, rate, slot.

Empty values delete the corresponding query parameter.

set_instance_protocol

Updates protocol switches, then restarts the instance.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

notcp, noudp, proxy.

Empty values delete the corresponding query parameter.

set_instance_traffic

Updates traffic-control values, then restarts the instance.

Required arguments:

ArgumentDescription
idInstance ID.

Optional arguments:

block, lbs.

Empty values delete the corresponding query parameter.

set_instance_advanced

Updates arbitrary URL fields or query parameters, then restarts the instance.

Required arguments:

ArgumentTypeDescription
idstringInstance ID.
parametersobjectKey-value map. Values are converted to strings.

The update path is shared with the structured setters, so reserved keys such as type, pool, password, tunnel_address, tunnel_port, target_address, target_port, and targets keep their special behavior. Other keys are written as URL query parameters. Empty string values delete query parameters.

Example:

{
  "jsonrpc": "2.0",
  "id": 11,
  "method": "tools/call",
  "params": {
    "name": "set_instance_advanced",
    "arguments": {
      "id": "a1b2c3d4",
      "parameters": {
        "custom": "value",
        "read": "30s"
      }
    }
  }
}

get_instance_config

Required arguments:

ArgumentDescription
idInstance ID.

Returns a parsed config object generated from the instance's complete config URL:

FieldDescription
typeURL scheme, server or client.
passwordPassword from URL userinfo, when present.
tunnel_addressURL hostname.
tunnel_portURL port.
target_addressTarget host when the path contains a single host:port target.
target_portTarget port when the path contains a single host:port target.
targetsFull target path when multiple comma-separated targets are present.
parametersURL query parameters. Pool backend appears as parameters.type.

delete_instance

Required arguments:

ArgumentDescription
idInstance ID.

Behavior:

  • Marks the instance as deleted.
  • Stops it if it is running.
  • Removes it from the master registry.
  • Saves state asynchronously.
  • Sends an SSE delete event.

The internal API key record ID ******** cannot be deleted.

Import And Export Tools

export_instances

Arguments: none.

Exports all non-internal instances to nodepass.json in the same directory as the master state file. The state file is normally stored under gob/nodepass.gob next to the NodePass binary, so the export file is normally:

<nodepass-binary-dir>/gob/nodepass.json

The export includes:

FieldDescription
aliasInstance alias.
urlEnhanced instance URL.
restartAuto-restart policy.
metaPeer and tag metadata.
tcprx, tcptx, udprx, udptxTraffic counters.

import_instances

Arguments: none.

Imports instances from nodepass.json in the same directory as the master state file.

Behavior:

  • Reads an array of exported instance objects.
  • Skips entries without a valid url.
  • Accepts only client:// and server:// URLs.
  • Generates new instance IDs.
  • Restores alias, restart policy, metadata, and traffic counters when present.
  • Generates the full config URL for each imported instance.
  • Starts imported instances whose restart flag is true.
  • Saves state asynchronously.

Network Diagnostic Tool

tcping_target

Required arguments:

ArgumentDescription
targetTarget address in host:port format.

Returns a result object:

FieldDescription
targetTested address.
connectedWhether a TCP connection was established.
latencyConnection latency in milliseconds.
errorError string when the test fails, otherwise null.

Concurrency is limited internally. When the limit is saturated for more than one second, the result contains error: "too many requests".

Master Tools

get_master_info

Arguments: none.

Returns info with master metadata and system statistics:

FieldDescription
midMaster ID.
aliasMaster alias.
os, arch, nocOperating system, architecture, and CPU count.
cpuCPU utilization on Linux, otherwise -1.
mem_total, mem_usedMemory metrics in bytes.
swap_total, swap_usedSwap metrics in bytes.
netrx, nettxNetwork receive/transmit byte counters.
diskr, diskwDisk read/write byte counters.
sysupSystem uptime in seconds, Linux only.
verNodePass version.
nameMaster hostname.
uptimeMaster process uptime in seconds.
logMaster log level.
tlsMaster TLS mode.
crt, keyMaster certificate and key paths.

Detailed CPU, memory, swap, network, disk, and system uptime metrics are collected from /proc on Linux. On other platforms, unsupported metrics remain at default values.

update_master_info

Required arguments:

ArgumentDescription
aliasNew master alias.

The alias must be non-empty and no longer than 256 characters. The value is persisted through the internal API key record.

Error Codes

CodeMeaningCommon causes
-32700Parse errorRequest body is not valid JSON.
-32600Invalid Requestjsonrpc is not 2.0.
-32601Method not foundUnknown JSON-RPC method.
-32602Invalid paramsMissing required arguments, unknown tool, invalid instance ID, invalid action, invalid type, or validation failure.
-32603Internal errorFile I/O or serialization failure during import/export.

cURL Examples

Set common variables:

MCP_URL="http://127.0.0.1:9090/api/v2"
API_KEY="<api-key>"

Initialize:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'

List tools:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'

List instances:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "list_instances",
      "arguments": {}
    }
  }'

Create a server instance:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "create_instance",
      "arguments": {
        "alias": "web",
        "type": "server",
        "tunnel_address": "0.0.0.0",
        "tunnel_port": "10101",
        "target_address": "127.0.0.1",
        "target_port": "3000",
        "log": "info",
        "pool": "0"
      }
    }
  }'

Restart an instance:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 5,
    "method": "tools/call",
    "params": {
      "name": "control_instance",
      "arguments": {
        "id": "a1b2c3d4",
        "action": "restart"
      }
    }
  }'

Update TLS settings:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 6,
    "method": "tools/call",
    "params": {
      "name": "set_instance_security",
      "arguments": {
        "id": "a1b2c3d4",
        "tls": "2",
        "crt": "/etc/nodepass/server.crt",
        "key": "/etc/nodepass/server.key"
      }
    }
  }'

Get master information:

curl -sS -X POST "$MCP_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 7,
    "method": "tools/call",
    "params": {
      "name": "get_master_info",
      "arguments": {}
    }
  }'

Operational Notes

  • Configuration setters call the same URL update path. If the instance is running, NodePass stops it, waits briefly, writes the new URL, regenerates the complete config URL, and starts it again.
  • create_instance, control_instance, setter tools, delete_instance, and import_instances perform some work asynchronously. A successful response means the request was accepted and state updates were scheduled; use get_instance or list_instances to observe the final runtime status.
  • The special internal ID ******** stores the API key and master ID. It is hidden from list_instances and protected from instance mutation tools.
  • tags in update_instance replace the whole tag map instead of merging with existing tags.
  • MCP returns structured data in addition to text content. Automation clients should consume the structured fields where possible.