Terminally MCP

Terminally MCP

An MCP server that gives AI assistants the ability to create, manage, and control terminal sessions through a safe, isolated tmux environment.

Category
访问服务器

README

<div align="center">

🖥️ Terminally MCP

Supercharge AI Assistants with Terminal Control Powers

MCP Protocol Node.js TypeScript License: ISC

Give your AI assistant the power to create, manage, and control terminal sessions like a pro developer! Built on the Model Context Protocol (MCP) for seamless integration with AI tools like Claude, ChatGPT, and more.

FeaturesQuick StartInstallationAPI ReferenceExamples

</div>


🎯 What is Terminally MCP?

Terminally MCP is a Model Context Protocol (MCP) server that bridges the gap between AI assistants and terminal operations. It provides a safe, controlled environment where AI can:

  • 🚀 Execute shell commands with full output capture
  • 📂 Manage multiple terminal sessions simultaneously
  • 🔍 Read terminal history and scrollback buffers
  • 🛡️ Isolated tmux environment that won't interfere with your existing sessions
  • Real-time command execution with timeout protection

Perfect for AI-powered development workflows, automation, system administration, and interactive coding assistance!

✨ Features

<table> <tr> <td width="50%">

🎮 Terminal Control

  • Create and manage multiple terminal tabs
  • Execute commands with proper quote/escape handling
  • Capture command output and exit codes
  • Read terminal history and scrollback

</td> <td width="50%">

🔒 Safe & Isolated

  • Dedicated tmux server instance
  • No interference with user's tmux sessions
  • Timeout protection for long-running commands
  • Clean session management

</td> </tr> <tr> <td width="50%">

🤖 AI-Optimized

  • MCP protocol compliance
  • Structured JSON responses
  • Error handling and recovery
  • Marker-based output capture

</td> <td width="50%">

🛠️ Developer Friendly

  • TypeScript with full type safety
  • Comprehensive test suite
  • Clean, modular architecture
  • Easy to extend and customize

</td> </tr> </table>

🚀 Quick Start

Get up and running in under 2 minutes!

# Clone the repository
git clone https://github.com/yourusername/terminally-mcp.git
cd terminally-mcp

# Install dependencies (we recommend pnpm for speed!)
pnpm install

# Build the TypeScript code
pnpm build

# Start the MCP server
pnpm start

That's it! The server is now ready to accept MCP connections.

📦 Installation

Prerequisites

  • Node.js v16 or higher
  • tmux installed on your system
  • pnpm (recommended) or npm/yarn

Install tmux

<details> <summary>🍎 macOS</summary>

brew install tmux

</details>

<details> <summary>🐧 Linux</summary>

# Ubuntu/Debian
sudo apt-get install tmux

# Fedora
sudo dnf install tmux

# Arch
sudo pacman -S tmux

</details>

Setup for AI Assistants

<details> <summary>🤖 Claude Desktop (via MCP)</summary>

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "terminally-mcp": {
      "command": "node",
      "args": ["/path/to/terminally-mcp/build/index.js"]
    }
  }
}

</details>

<details> <summary>⚡ Cline/Other MCP Clients</summary>

Add to your MCP client configuration:

{
  "terminally-mcp": {
    "command": "node",
    "args": ["/path/to/terminally-mcp/build/index.js"],
    "type": "stdio"
  }
}

</details>

📖 API Reference

🔧 Available Tools

create_tab

Creates a new terminal session.

// Request
{
  "name": "my-session"  // Optional: custom name for the tab
}

// Response
{
  "window_id": "@1"  // Unique identifier for the created tab
}

execute_command

Run any shell command in a specific terminal tab.

// Request
{
  "window_id": "@1",
  "command": "echo 'Hello, World!' && ls -la",
  "timeout": 5000  // Optional: timeout in ms (default: 10000)
}

// Response
{
  "output": "Hello, World!\ntotal 64\ndrwxr-xr-x  10 user  staff  320 Jan 15 10:00 ."
}

list_tabs

Get all active terminal sessions.

// Response
{
  "tabs": [
    {
      "window_id": "@0",
      "name": "default",
      "active": true
    },
    {
      "window_id": "@1",
      "name": "my-session",
      "active": false
    }
  ]
}

read_output

Read the terminal buffer including history.

// Request
{
  "window_id": "@1",
  "history_limit": 100  // Optional: number of history lines
}

// Response
{
  "content": "$ echo 'Previous command'\nPrevious command\n$ ls\nfile1.txt file2.txt"
}

close_tab

Close a terminal session.

// Request
{
  "window_id": "@1"
}

// Response
{
  "success": true
}

💡 Examples

Basic Command Execution

// Create a new terminal
const tab = await mcp.call('create_tab', { name: 'dev-server' });

// Navigate and start a development server
await mcp.call('execute_command', {
  window_id: tab.window_id,
  command: 'cd /my/project && npm run dev'
});

// Check the output
const output = await mcp.call('read_output', {
  window_id: tab.window_id
});

Multi-Tab Workflow

// Create tabs for different purposes
const webTab = await mcp.call('create_tab', { name: 'web-server' });
const dbTab = await mcp.call('create_tab', { name: 'database' });
const testTab = await mcp.call('create_tab', { name: 'tests' });

// Start services in parallel
await Promise.all([
  mcp.call('execute_command', {
    window_id: webTab.window_id,
    command: 'npm run dev'
  }),
  mcp.call('execute_command', {
    window_id: dbTab.window_id,
    command: 'docker-compose up postgres'
  })
]);

// Run tests
await mcp.call('execute_command', {
  window_id: testTab.window_id,
  command: 'npm test'
});

Complex Command Chains

// Execute multiple commands with proper escaping
await mcp.call('execute_command', {
  window_id: '@1',
  command: `
    echo "Setting up environment..." &&
    export NODE_ENV=development &&
    echo "Installing dependencies..." &&
    npm install &&
    echo "Running migrations..." &&
    npm run migrate &&
    echo "Starting application..." &&
    npm start
  `.trim()
});

🏗️ Architecture

terminally-mcp/
├── src/
│   ├── index.ts              # Entry point
│   ├── server.ts             # MCP server implementation
│   ├── services/
│   │   └── tmuxManager.ts    # tmux interaction layer
│   └── tools/
│       ├── definitions.ts    # Tool schemas
│       └── handlers.ts       # Tool implementations
├── test/                     # Test suite
├── build/                    # Compiled JavaScript
└── package.json

Key Design Decisions

  • 🔐 Isolated tmux Server: Each instance uses a unique socket path to prevent conflicts
  • 📍 Marker-Based Output Capture: Reliable command output extraction using UUID markers
  • ⏱️ Timeout Protection: Configurable timeouts prevent hanging on long-running commands
  • 🎯 Type Safety: Full TypeScript implementation with strict typing

🧪 Development

# Run in development mode (auto-rebuild)
pnpm dev

# Run tests
pnpm test

# Run tests with UI
pnpm test:ui

# Build for production
pnpm build

# Start production server
pnpm start

🤝 Contributing

We love contributions! Whether it's:

  • 🐛 Bug reports
  • 💡 Feature requests
  • 📖 Documentation improvements
  • 🔧 Code contributions

Please feel free to:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the ISC License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built on the Model Context Protocol specification
  • Powered by tmux - the terminal multiplexer
  • Inspired by the need for better AI-terminal integration

🌟 Star History

If you find this project useful, please consider giving it a ⭐ on GitHub!


<div align="center">

Built with ❤️ for the AI-assisted development community

Report BugRequest FeatureJoin Discussion

</div>

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选