mcp-server-tcp
v1.1.0A versatile TCP client/server proxy MCP server for LLMs
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
tcp_ping_port
测量到目标主机的 TCP 握手时延与端口连通性。 @param host 目标主机域名或 IP @param port 目标 TCP 端口 (1-65535) @param timeout_ms 超时时间(毫秒,默认 3000) @return 包含 connected, host, port, latency_ms, error 的检测结果
| Parameter | Type | Description |
|---|---|---|
host * | string | |
port * | integer | |
timeout_ms | integer |
tcp_port_scan
并发扫描目标主机的指定端口列表并返回开放状态。 @param host 目标主机域名或 IP @param ports 待扫描的端口列表 @param timeout_ms 单个端口探测超时时间(毫秒,默认 1000) @return 包含 host, scanned_count, open_ports, results 列表的扫描结果
| Parameter | Type | Description |
|---|---|---|
host * | string | |
ports * | array | |
timeout_ms | integer |
tcp_send_once
建立短连接、发送单次数据并读取响应,随后立即优雅关闭连接。 @param host 目标主机域名或 IP @param port 目标 TCP 端口 @param data 待发送数据(Text Payload 明文字符串或 Hex Payload 十六进制串) @param encoding 编码格式,支持 'utf-8' 或 'hex'(默认 'utf-8') @param timeout_ms 操作整体超时时间(毫秒,默认 5000) @return 包含 success, sent_bytes, received_bytes, response_data, error 的通信结果
| Parameter | Type | Description |
|---|---|---|
data * | string | |
host * | string | |
port * | integer | |
encoding | string | |
timeout_ms | integer |
tcp_connect
建立持久化 TCP 连接,分配唯一 conn_id 并纳入连接池受管。 @param host 目标主机域名或 IP @param port 目标 TCP 端口 (1-65535) @param timeout_ms 连接超时时间(毫秒,默认 5000) @return ConnectResult 字典,包含 connected, conn_id, host, port, error
| Parameter | Type | Description |
|---|---|---|
host * | string | |
port * | integer | |
timeout_ms | integer |
tcp_disconnect
优雅关闭指定的 TCP 连接并从连接池中注销释放套接字。 @param conn_id 连接全局唯一标识符 @return DisconnectResult 字典,包含 conn_id, disconnected, message
| Parameter | Type | Description |
|---|---|---|
conn_id * | string |
tcp_list_connections
列出当前连接池中所有活跃连接的状态快照,支持按 Mock Server ID 拓扑过滤。 @param server_id 可选的 Mock Server 全局唯一标识符过滤 @return 活跃连接列表,包含 conn_id, host, port, idle_seconds, unread_bytes, server_id, is_server_accepted 等
| Parameter | Type | Description |
|---|---|---|
server_id |
tcp_send_text
向指定长连接发送 UTF-8 文本数据(Text Payload),支持可选行尾 CRLF。 @param conn_id 连接全局唯一标识符 @param text 待发送的文本内容 @param append_crlf 是否在末尾自动追加 \r\n(默认 False) @return SendResult 字典,包含 conn_id, bytes_sent, success, error
| Parameter | Type | Description |
|---|---|---|
conn_id * | string | |
text * | string | |
append_crlf | boolean |
tcp_send_hex
向指定长连接发送十六进制编码的原始二进制字节流(Hex Payload)。 @param conn_id 连接全局唯一标识符 @param hex_string 十六进制字符串(支持形如 '01 02 03' 或 '010203') @return SendResult 字典,包含 conn_id, bytes_sent, success, error
| Parameter | Type | Description |
|---|---|---|
conn_id * | string | |
hex_string * | string |
tcp_recv_text
从指定长连接接收文本数据(Text Payload),具备定界符切包与软超时宽容返回能力。 @param conn_id 连接全局唯一标识符 @param timeout_ms 超时毫秒数(默认 5000) @param delimiter 报文定界符(如 '\r\n' 或 '\n',可选) @return RecvTextResult 字典,包含 text, bytes_read, timed_out, closed, error
| Parameter | Type | Description |
|---|---|---|
conn_id * | string | |
delimiter | ||
timeout_ms | integer |
tcp_recv_hex
从指定长连接接收原始二进制字节并格式化为 Hex Payload,支持限制字节数与软超时。 @param conn_id 连接全局唯一标识符 @param timeout_ms 超时毫秒数(默认 5000) @param max_bytes 最大接收字节数上限(可选) @return RecvHexResult 字典,包含 hex_string, bytes_read, timed_out, closed, error
| Parameter | Type | Description |
|---|---|---|
conn_id * | string | |
max_bytes | ||
timeout_ms | integer |
tcp_start_server
启动本地 Mock TCP 服务端监听器,被动接受外部客户端连入并统一分配 conn_id。 @param host 绑定监听的本地地址(默认 127.0.0.1) @param port 绑定监听的本地端口(默认 0,系统随机分配可用端口) @return StartServerResult 字典,包含 server_id, host, port, started, error
| Parameter | Type | Description |
|---|---|---|
host | string | |
port | integer |
tcp_stop_server
安全停止指定的 Mock TCP 服务端监听器,并级联断开所有该服务端接受的客户端连接。 @param server_id Mock Server 全局唯一标识符 @return StopServerResult 字典,包含 server_id, stopped, closed_connections_count, message
| Parameter | Type | Description |
|---|---|---|
server_id * | string |
tcp_broadcast
向指定 Mock Server 下的所有连入活跃客户端同时多路广播数据。 @param server_id Mock Server 全局唯一标识符 @param text 待广播的文本数据(Text Payload) @param hex_string 待广播的十六进制二进制数据(Hex Payload) @param append_crlf 广播文本时是否自动追加 \r\n(默认 False) @return BroadcastResult 字典,包含 server_id, recipients_count, success_count, failed_count
| Parameter | Type | Description |
|---|---|---|
server_id * | string | |
append_crlf | boolean | |
hex_string | ||
text |
tcp_dump_traffic
回溯指定连接的最近 Traffic Ring Buffer 内存审计记录(最多 100 条)。 @param conn_id 连接全局唯一标识符 @param limit 最大返回记录数(默认 100) @return TrafficDumpResult 字典,包含 conn_id, total_records, records
| Parameter | Type | Description |
|---|---|---|
conn_id * | string | |
limit | integer |