mcp-terminal-share

mcp-terminal-share

Enables two or more Claude Code terminals on the same machine to communicate by registering and sending messages via the local filesystem.

Category
访问服务器

README

mcp-terminal-share

An MCP server that lets two or more Claude Code terminals on the same machine talk to each other. Register each terminal with a short name, then send messages between them.

┌──────────────┐                      ┌──────────────┐
│  terminal A  │ ── send_message ──►  │  terminal B  │
│              │ ◄── send_message ──  │              │
└──────────────┘                      └──────────────┘
        │              file-based              │
        └──────► ~/.claude/terminal-messages ──┘

Why

Pair-running two Claude Code sessions and want one to hand off a long log or a task summary to the other? That's it.

Install

Wire it into Claude Code's MCP config (Claude Code → ~/.claude.json or via the CLI):

claude mcp add terminal-share -- npx -y mcp-terminal-share

Or by hand in your MCP config:

{
  "mcpServers": {
    "terminal-share": {
      "command": "npx",
      "args": ["-y", "mcp-terminal-share"]
    }
  }
}

Requires Node.js 18+.

Tools

Tool Purpose
register Give this terminal a name (e.g. A1, dev). Required before others can address it.
list_terminals Show all live terminals. Stale records are cleaned up automatically.
send_message Send {from, to, summary, content} to another terminal.
get_messages Read messages addressed to you. Deletes them on read by default.
watch_messages Block until a message arrives or timeout (default 300s) expires.

Names must match ^[A-Za-z0-9_-]{1,32}$. Message content is capped at 1 MB, summary at 500 B.

Suggested slash commands

If you already use the bundled t-rg / t-list / t-send / t-get / t-watch skills, they map 1:1 onto the tools above.

Show the registered name in your statusline

After a successful register, the server writes a tiny session record keyed by a hash of the working directory:

~/.claude/terminal-messages/sessions/<sha256(cwd)[:16]>.json

The MCP server, your statusline, and any helper subprocess it spawns all inherit cwd from the same Claude Code session, so they can find each other without any extra plumbing.

claude-hud

Add --extra-cmd "mcp-terminal-share-label" to your statusline command:

{
  "statusLine": {
    "type": "command",
    "command": "claude-hud --extra-cmd \"mcp-terminal-share-label\""
  }
}

The bundled mcp-terminal-share-label bin reads the record for the current cwd and outputs claude-hud's expected {"label": "📟 <name>"} (or {} when nothing is registered). Override the emoji/prefix with MCP_TERMINAL_SHARE_LABEL_PREFIX.

Other statuslines

Roll your own. The minimal Node version:

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
import { createHash } from "node:crypto";

const key = createHash("sha256").update(process.cwd()).digest("hex").slice(0, 16);
try {
  const { name } = JSON.parse(
    readFileSync(
      join(homedir(), ".claude", "terminal-messages", "sessions", `${key}.json`),
      "utf-8",
    ),
  );
  process.stdout.write(`📟 ${name}`);
} catch {
  // not registered
}

The file is removed automatically when the MCP server shuts down.

Known limitation: if you open two Claude Code sessions in the same directory, the later one's register overwrites the earlier one's session record. This only affects the statusline label — message routing between terminals is unaffected.

How it works

  • Each terminal writes its registration to ~/.claude/terminal-messages/terminals/<name>.json.
  • Messages are dropped into ~/.claude/terminal-messages/messages/to_<recipient>_<ts>_<rand>.json.
  • A session record for statusline consumers lives at ~/.claude/terminal-messages/sessions/<sha256(cwd)[:16]>.json.
  • Liveness uses a 5 s heartbeat; records older than 30 s whose owning PID is also dead are reaped on read.
  • Messages older than 24 h are reaped on read, and a per-recipient queue cap of 100 prevents runaway buildup.
  • All file writes go through a temp-file + rename for atomicity.

Override the storage root with MCP_TERMINAL_SHARE_DIR (mostly useful for tests).

Security model

  • Local, single-user, single-host. Anyone with read access to ~/.claude/terminal-messages can read or spoof messages. This is fine on a personal dev machine and explicitly out of scope to defend otherwise.
  • No network surface. Communication is purely through the local filesystem; nothing listens on a port.
  • Input validation. Names are regex-validated to prevent path traversal; content size is capped.

If you need cross-machine sharing or untrusted multi-tenant isolation, this is the wrong tool — reach for a real message bus.

Development

npm install
npm test

Tests use Node's built-in node:test runner with isolated temp dirs (no extra deps).

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选