tcpsh-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@tcpsh-mcpOpen port 4444 and wait for a connection"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
tcpsh-mcp — MCP Server for TCP Connection Management
MCP server for tcpsh — the interactive TCP connection manager.
MCP server exposing 13 tools for interactive TCP connection management: open listeners, interact with sessions, forward ports, proxy traffic, and run local commands — all from any MCP-compatible AI host (Claude Desktop, VS Code Copilot, etc.).
Installation
This server is installed on demand from GitHub — no npm registry required.
Add to your MCP host configuration:
{
"mcpServers": {
"tcpsh": {
"command": "npx",
"args": ["-y", "github:nchgroup/tcpsh-mcp"]
}
}
}npx -y github:nchgroup/tcpsh-mcp clones the repository, runs npm install, and executes the bin entry — no manual setup required.
Requirements
Node.js ≥ 18.0.0
Internet access on first run (GitHub clone + npm install)
Related MCP server: Terminal MCP Server
Tools
# | Tool | Description |
1 |
| Open a TCP listener |
2 |
| Close a listener and its sessions |
3 |
| List open ports and session counts |
4 |
| List active sessions with traffic counters |
5 |
| Send data to a TCP session |
6 |
| Read buffered data from a TCP session |
7 |
| Terminate a session (FIN or RST) |
8 |
| Detailed info about a session |
9 |
| Start a transparent TCP forward |
10 |
| Start a TCP proxy with traffic logging |
11 |
| List active forwards and proxies |
12 |
| Stop a forward or proxy |
13 |
| Run a shell command on the local machine |
Tool Reference
open_port
port (number, required) TCP port to listen on
host (string, optional) Bind address or interface name — default: 0.0.0.0host accepts an IP address, a network interface name, or can be omitted:
open_port(4444) # bind 0.0.0.0:4444
open_port(4444, "127.0.0.1") # loopback only
open_port(4444, "tun0") # resolves tun0 → its IPv4 address
open_port(443, "eth0") # resolves eth0 → its IPv4 addressIn standalone mode (no TCPSH_SERVER) the interface is resolved locally via os.networkInterfaces().
In remote mode the interface name is sent as-is to the tcpsh server, which resolves it there.
close_port
port (number, required) Port to close (closes all its sessions too)send_to_session
port (number, required) Port the session belongs to
idx (number, optional) Session index, 1-based — default: 1
data (string, required) Raw data to send (no newline added automatically)read_from_session
port (number, required) Port the session belongs to
idx (number, optional) Session index — default: 1Drains the internal RX buffer. Call again to receive subsequent data.
kill_session
port (number, required) Port the session belongs to
idx (number, optional) Session index — default: 1
force (boolean, optional) true = RST (immediate), false = FIN (graceful) — default: falseadd_forward
local_port (number, required) Local port to listen on
remote_host (string, required) Destination host
remote_port (number, required) Destination portadd_proxy
local_port (number, required) Local port to listen on
remote_host (string, required) Destination host
remote_port (number, required) Destination port
log_file (string, optional) Path to write hex traffic logexec_local
command (string, required) Shell command executed via sh -cExample Prompts
Open a reverse shell catcher:
"Open port 4444 and wait for a connection"
Read shell output:
"Read the output from the session on port 4444"
Send a command to a session:
"Send the command 'id\n' to port 4444"
Set up port forwarding:
"Forward local port 8080 to 10.0.0.1:80"
Intercept HTTP traffic:
"Start a proxy on port 8080 pointing to 10.0.0.1:80, log to /tmp/http.log"
Run a local network scan:
"Run nmap -sV localhost and return the output"
Remote Mode
tcpsh-mcp can delegate all TCP management to a remote tcpsh server instead of running a local in-process manager. This is useful when:
the AIhost is sandboxed and cannot open TCP ports directly
you want state to persist even if the MCP process restarts
multiple AI sessions should share the same network state
Prerequisites
Start a tcpsh server on the target machine:
tcpsh -server 0.0.0.0:9000The token printed at startup encrypts all traffic with ChaCha20-Poly1305.
Enable remote mode
Pass two environment variables when starting the MCP server. Example MCP host configuration:
{
"mcpServers": {
"tcpsh-remote": {
"command": "npx",
"args": ["-y", "github:nchgroup/tcpsh-mcp"],
"env": {
"TCPSH_SERVER": "127.0.0.1:9000",
"TCPSH_TOKEN": "aBcDeFgHiJkLmNoPqRsTuVwXyZ012345"
}
}
}
}Or on the command line:
TCPSH_SERVER=127.0.0.1:9000 TCPSH_TOKEN=<TOKEN> node src/index.jsWhat works remotely
Tool | Remote support |
| ✅ Delegated to tcpsh server |
| ⚠️ Always runs locally (on the MCP server host) |
When neither TCPSH_SERVER nor TCPSH_TOKEN is set, tcpsh-mcp falls back to its
built-in in-process TCP manager (default behaviour).
Architecture
tcpsh-mcp/
├── package.json bin entry + @modelcontextprotocol/sdk dep
└── src/
├── index.js McpServer + StdioServerTransport + tool registration
│ (selects TcpManager or RemoteTcpManager at startup)
├── tcp-manager.js Local TCP state: listeners, sessions, RX buffers, forwards, proxies
├── remote-manager.js Remote mode: encrypted ChaCha20-Poly1305 frames over TCP
└── tools.js 13 tool definitions (inputSchema + handlers)Transport: stdio — compatible with all MCP hosts
State: in-process (default) or on the remote tcpsh server (remote mode)
RX buffer: received data is buffered per session and drained on
read_from_sessionSDK:
@modelcontextprotocol/sdkv1.x (stable)
Manual Testing
Send raw JSON-RPC to the server's stdin:
# Start the server
node src/index.js
# In another terminal / via pipe:
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}\n{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}\n' \
| node src/index.jsRelated Projects
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
MCP server with quote and live cryptocurrency price tools, local and cloud-deployed transports.
MCP server for network documentation, generated by doc2mcp.
The official MCP Server for the Mux API
Related MCP Servers
- AlicenseAqualityAmaintenanceMCP server for SSH and local terminal access. Supports interactive commands, long-running processes, and TUI apps like tmux/zellij63MIT
- AlicenseNot gradedqualityCmaintenanceA production-ready MCP server for secure, session-based command execution, file manipulation, and system inspection via local terminal sessions.2 npmISC
- AlicenseNot gradedqualityCmaintenanceAn MCP server that lets you execute commands, manage files, run persistent shell sessions, transfer large files, and control background processes on remote machines via a lightweight HTTP agent, useful when SSH/WinRM/SMB are unavailable.MIT
- AlicenseBqualityAmaintenanceMCP server enabling local network interaction, shell command execution, system resource monitoring, and SSH-based remote device management.18MIT