persistent-terminal-mcp: Instructions file for Claude Code

CLAUDE.md

persistent-terminal-mcp CLAUDE.md is an instructions file for Claude Code from masx200/persistent-terminal-mcp. It costs 1,910 tokens per session, scanned A, original, MIT.

Project instructions for a TypeScript MCP server that keeps terminal sessions running between commands. It also describes a browser terminal interface and a REST API, which lets other programs communicate over HTTP.

In plain words
What is it for?
Managing multiple lasting terminal sessions, viewing them live in a browser, accessing them through REST, and developing or testing the server.
Why use it?
It explains how the server connects coding-agent clients to persistent terminals and how developers should build, run, test, and maintain it.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code; built for cline.

This is masx200/persistent-terminal-mcp's own configuration. It tells Claude Code how to work on persistent-terminal-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything persistent-terminal-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to masx200/persistent-terminal-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/masx200/persistent-terminal-mcp/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/masx200/persistent-terminal-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for persistent-terminal-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/masx200/persistent-terminal-mcp/claude-md/github.svg)](https://agentmods.dev/instructions/masx200/persistent-terminal-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/masx200/persistent-terminal-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/masx200/persistent-terminal-mcp/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for persistent-terminal-mcp CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/masx200/persistent-terminal-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/masx200/persistent-terminal-mcp/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,910 This file is loaded in full into every session.
When invoked 1,910 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01910 $0.01910
Opus 5.5 $0.00764 $0.00764
Sonnet 5.5 $0.00382 $0.00382
Haiku 4.5 $0.00191 $0.00191

Measured 2mo ago against content hash 9a4cee6ec337, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

persistent-terminal-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 302 lines

How it starts

The opening of the file, as written. The whole thing — 302 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

项目概述

这是一个基于 TypeScript 的 Model Context Protocol (MCP) 服务器,提供持久化终端会话管理功能。项目实现了完整的 MCP 协议标准,支持多种客户端(Claude Desktop、Claude Code、Cursor、Cline 等)。

核心架构

主要组件

  1. MCP 服务器 (src/mcp-server.ts)

    • 实现 Model Context Protocol 标准
    • 处理 JSON-RPC 通信
    • 提供工具、资源、提示词和日志功能
  2. 终端管理器 (src/terminal-manager.ts)

    • 基于 node-pty 的持久化终端会话管理
    • 支持多终端会话并发
    • 智能输出处理和 Spinner 压缩
    • 自动超时清理机制
  3. Web UI 系统

    • 基于 Express + WebSocket 的实时界面 (src/web-ui-server.ts)
    • 使用 xterm.js 渲染终端界面 (public/terminal.html)
    • 支持交互式操作和实时通信
  4. REST API 服务器 (src/rest-server.ts, src/rest-api.ts)

    • 独立的 HTTP 服务器(端口 3001)
    • 完整的 RESTful API 接口
    • 支持非 MCP 客户端集成

数据流架构

MCP Client ↔ MCP Server ↔ Terminal Manager ↔ Node PTY ↔ Terminal Process
              ↓
        Web UI Server ↔ WebSocket ↔ Browser
              ↓
        REST API Server ↔ HTTP Client

开发命令

构建和运行

# 构建 TypeScript 项目
npm run build

# 开发模式运行 MCP 服务器
npm run dev

# 生产模式运行
npm run start

# 开发模式运行 REST API 服务器
npm run dev:rest

测试

# 运行所有测试
npm test

# 仅运行单元测试
npm run test:unit

# 运行集成测试
npm run test:integration

# 运行特定集成测试
npm run test:integration:stdio
npm run test:integration:cursor
npm run test:integration:terminal

# 运行测试并生成覆盖率报告
npm test -- --coverage

示例和调试

# 基本使用示例
npm run example:basic

# REST API 演示
npm run example:rest

# 交互式演示
npm run example:interactive

# 智能读取演示
npm run example:smart

# Spinner 压缩测试
npm run example:spinner

# Web UI 测试
npm run example:webui

# 测试所有工具
npm run test:tools

环境配置

必需环境变量

# REST API 服务器端口
REST_PORT=3001

# 终端配置
MAX_BUFFER_SIZE=10000     # 最大缓冲区行数
SESSION_TIMEOUT=86400000  # 会话超时时间(24小时)

# 终端尺寸
DEFAULT_COLS=80
DEFAULT_ROWS=24

# 日志级别
LOG_LEVEL=info

开发配置

# 启用 MCP 调试模式
MCP_DEBUG=true

# 启用应用调试模式
DEBUG=true

关键技术细节

MCP 协议实现

  • 使用 @modelcontextprotocol/sdk 实现
  • 支持 stdio 传输模式
  • 保持 stdout 纯净,所有日志输出到 stderr
  • 实现完整的工具、资源、提示词和日志功能

Read the full file on GitHub · 302 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 302 lines · 1,910 tokens per session scan A 9a4cee6ec337

Subscribe to this mod's changes

persistent-terminal-mcp CLAUDE.md is an instructions file published in the GitHub repository masx200/persistent-terminal-mcp (4 stars, last pushed 6mo ago), licensed MIT. It adds 1,910 tokens to every session, about $0.0076 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

persistent-terminal-mcp CLAUDE.md compared with instructions from other repositories

persistent-terminal-mcp CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
persistent-terminal-mcp CLAUDE.mdmasx200/persistent-terminal-mcpInstructions file46mo agoMITA1,910Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode