Skip to main content
Glama
router-session-mcp

router-session-mcp

by yichase

router-session-mcp

Use an MCP client to run commands on a router CLI over SSH, Telnet, or a simulator console on a Linux host. Each session keeps its own terminal and configuration view. An agent can disconnect, reconnect, and pick up where it left off.

Quick start

Install Git, Python 3.12 or later, and uv. To start the server from source, run:

git clone https://github.com/yichase/router-session-mcp.git
cd router-session-mcp
uv run --frozen router-session-mcp

Select Streamable HTTP in your MCP client and enter http://127.0.0.1:8765/mcp. Use --port to change the port. The server listens on the loopback interface. Local clients that connect to it share the same device sessions.

Related MCP server: ptywright

Connect to a device

Mode

Arguments for open_session

ssh

Router ip, username, and password. The default port is 22.

telnet

Router ip, username, and password. The default port is 23. Telnet transmits credentials and commands in cleartext.

ssh_connect

SSH login details in server_ssh and a positive integer router_number. Each simulator session gets a separate SSH login.

The CLI driver recognizes prompts such as <Router3> and [Router3]. Direct connections work without a configuration file. For SSH, the server verifies device and host keys against ~/.ssh/known_hosts by default.

For simulator access, copy the example configuration, set attach_command to the console command on your Linux host, and start the server with that file:

cp config.example.toml config.toml
uv run --frozen router-session-mcp --config config.toml

For example, attach_command = "connect" and router_number = 3 run connect 3 on the host.

Session tools

Tool

Purpose

open_session

Log in and return a session_id and the device prompt.

run_command

Run one query or configuration command in the existing terminal and return its output and prompt.

reply

Use the current interaction_id to answer a device question.

list_sessions

Find sessions after reconnecting and inspect their targets, states, and pending questions.

close_session

Close a single device session.

Device sessions stay open when an agent disconnects. Press Ctrl+C to stop the server and release all connections. If a command returns outcome="unknown", check the device state before deciding whether to retry.

Design and tool examples (Chinese) · Contributing

License

This project is distributed under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables SSH interactive session management through MCP, supporting commands, menus, and session lifecycle operations.
      1
      -
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to open persistent interactive terminal sessions with network devices over SSH, Telnet, TCP console, or serial, write raw commands including nested ssh/telnet transitions, and read full output without requiring a particular prompt format. It supports multiple concurrent sessions and keeps credentials/secrets out of MCP arguments or audit logs.
      7
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables clients to execute commands, maintain interactive shell sessions, incrementally read output, and manage or close those sessions through an authenticated MCP endpoint.
      MIT