connect
Open a serial port or network console and start a background reader so you can send commands to and read responses from devices over serial, Telnet, SSH, TCP, or RFC2217.
Instructions
Open a serial port, or a console over the network, and start its background reader.
Defaults are 9600 baud, 8 data bits, no parity, 1 stop bit, no flow control
("9600 8N1"), CR line ending, which is what most console/craft ports expect.
Give preset (see list_presets) to load a device family's usual settings, and
override any field explicitly, e.g. "38400 with XON/XOFF" -> baud=38400,
xonxoff=True. Several ports can be open at once; each gets a name and later
tools default to the most recently used one. Nothing is specific to telecom
gear: any device on a serial port works, including IoT gateways, alarm and
control panels, UPS and PDU menus and lab instruments; choose terminal by
what the device prints.
Network consoles work the same way once open (every read, expect, capture
and screen tool). transport="telnet" or "ssh" talks to the device itself
(a Juniper or Cisco management address, a Linux box: the same CLI as its
console port, minus boot loader and ROMMON) or to a console server port in
front of a serial console; "rfc2217" when the server also lets us set baud,
DTR/RTS and BREAK; "tcp" for raw TCP (ser2net). Or pass a URL as port:
"ssh://admin@mx1", "telnet://192.0.2.1", "telnet://cs1:2003",
"tcp://10.0.0.5:4001", "rfc2217://ser2net:3001".
Passwords are NEVER passed or typed here: SSH uses the user's agent, keys and
~/.ssh/config (host aliases work; the host key must already be in
known_hosts); a password login uses credential, the name of a password
the user stored themselves (serial-console-mcp credential set NAME, or
the SERIAL_CONSOLE_PASSWORD_ environment variable). For a one-off
user name/password login, pass ask=True: the user types the password into
a dialog on their own screen.
Args:
port: System port name, e.g. "COM4" (Windows), "/dev/cu.usbserial-10"
(macOS), or "/dev/ttyUSB0" (Linux). Get exact names from
list_serial_ports. Or a network URL (see above).
preset: Device preset name such as "cisco-console", "juniper-craft",
"kenwood-cat", "icom-civ", "yaesu-rotator", "arduino", "nmea-gps".
name: Nickname for this connection ("rig", "rotator"). Defaults to the
port's short name. Use it in other tools' connection argument.
baud: Baud rate. Common values: 1200, 2400, 4800, 9600, 19200, 38400,
57600, 115200. Unknown? Use detect_baud first.
bytesize: Data bits: 5, 6, 7, or 8. Almost always 8.
parity: "N" none, "E" even, "O" odd. Almost always "N".
stopbits: 1, 1.5, or 2. Almost always 1.
rtscts: Hardware (RTS/CTS) flow control. Off unless the manual says so
and the cable carries those lines.
xonxoff: Software (XON/XOFF) flow control. Off by default. Never for
binary protocols (it swallows 0x11 / 0x13 bytes).
line_ending: Default line ending for send_text/query_text on this
connection: "CR" (most rigs, consoles), "LF" (Unix, Arduino), "CRLF",
or "NONE" (Kenwood-style CAT ending in ';').
prompt: Default prompt for read_until_prompt/query_text on this
connection, e.g. "# ", "> ", ";" (CAT replies). Say what the device
shows, with its trailing space.
prompt_regex: Treat prompt as a regular expression.
terminal: How to interpret what the device sends. "dumb" (default):
raw bytes, right for CAT, CI-V, rotators and most CLIs. "ansi":
strip color/escape sequences and apply CR/backspace overwrites so
shells and colored prompts read cleanly (the console presets use
it); prompts are also matched on the last line as displayed, so a
line redrawn with spaces and backspaces (Junos after ? or
Ctrl-U) still ends in its prompt. "vt100"/"xterm": additionally keep a real screen for
full-screen menus, BIOS/BMC consoles, vi/top; read it with the
screen tool, navigate with send_keys.
cols: Screen width for vt100/xterm (default 80).
rows: Screen height for vt100/xterm (default 24).
transport: "serial" (default), "telnet", "ssh", "tcp" or "rfc2217".
Baud, parity and flow control apply to serial and rfc2217 only;
over telnet, tcp and ssh there is no baud rate to set (through a
console server, its port settings decide).
host: Host name, address or ~/.ssh/config alias for a network transport.
"host:port" is accepted.
tcp_port: TCP port. telnet defaults to 23 and ssh to ~/.ssh/config or
22. A console server maps each serial line to its own port (often
2000-4000+); tcp and rfc2217 always need it.
username: Login name for ssh (else ~/.ssh/config User, else the local
user) or for a telnet login. Not a secret.
credential: NAME of a stored password, never the password itself. For
ssh it is offered for password/keyboard-interactive login; for
telnet/tcp/serial it answers the "login:" and "Password:" prompts
that appear right after connecting (the device's own over telnet,
or a console server's). For a login that comes later, use expect
with send_credential.
ask: Ask the user, in a dialog on this computer and never in the chat,
for what is missing: the password (and user name) when the device
asks for one, and whether to trust an SSH host key seen for the
first time (its fingerprint is shown; a changed key is always
refused). Use it when the user wants to type a password for an
ad-hoc connection. With credential, a stored password is used
first and the dialog only if none is stored.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "connect"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ask | No | ||
| baud | No | ||
| cols | No | ||
| host | No | ||
| name | No | ||
| port | No | ||
| rows | No | ||
| parity | No | ||
| preset | No | ||
| prompt | No | ||
| rtscts | No | ||
| xonxoff | No | ||
| bytesize | No | ||
| stopbits | No | ||
| tcp_port | No | ||
| terminal | No | ||
| username | No | ||
| transport | No | serial | |
| credential | No | ||
| line_ending | No | ||
| prompt_regex | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |