Skip to main content
Glama
Terminal Renamer MCP

Terminal Renamer MCP

by kvicala888
README.md
# Terminal Renamer MCP

An MCP (Model Context Protocol) server for Claude Code that lets you name your terminal tabs and monitor RAM usage.

## The Problem

When working with multiple Claude Code sessions, it's hard to tell which terminal is which:

```
Terminal | Terminal | Terminal | Terminal
   ???        ???        ???        ???
```

## The Solution

Name your terminals and see RAM usage at a glance:

```
Frontend | 256MB | free: 11Gi    Backend API | 312MB | free: 11Gi
```

## Features

- **Easy terminal naming** - Just say "rename terminal to my-project"
- **Multi-language support** - Works in English, Czech, German, Spanish, French, and more
- **RAM monitoring** - Shows terminal's RAM usage and free system RAM
- **Auto-detection** - Automatically detects which terminal to rename
- **Multiple terminals** - Each terminal maintains its own name

## Installation

### 1. Clone the repository

```bash
git clone https://github.com/kvicala888/terminal-renamer-mcp.git
cd terminal-renamer-mcp
```

### 2. Install and build

```bash
npm install
npm run build
```

### 3. Add to Claude Code settings

Add to your `~/.claude.json`:

```json
{
  "mcpServers": {
    "terminal-renamer": {
      "command": "node",
      "args": ["/path/to/terminal-renamer-mcp/dist/index.js"]
    }
  }
}
```

### 4. Add the terminal watcher to your shell

Add to `~/.zshrc` or `~/.bashrc`:

```bash
# Terminal Renamer - background watcher (updates terminal title)
_claude_terminal_watcher() {
    local my_tty=$(tty 2>/dev/null)
    local tty_id=$(echo "$my_tty" | tr '/' '-' | sed 's/^-dev-//')
    local config_file="$HOME/.claude-terminal-name-${tty_id}"

    while true; do
        if [[ -f "$config_file" ]]; then
            local name=$(cat "$config_file" 2>/dev/null)
            if [[ -n "$name" ]]; then
                local term_ram=$(ps -t ${my_tty##*/} -o rss= 2>/dev/null | awk '{sum+=$1} END {printf "%.0f", sum/1024}')
                local free_ram=$(free -h 2>/dev/null | awk '/^Mem:/ {print $7}')
                printf '\e]0;%s | %sMB | free: %s\a' "$name" "$term_ram" "$free_ram"
            fi
        fi
        sleep 2
    done
}
_claude_terminal_watcher &!
```

**For Oh My Zsh users**, also add this before the `source $ZSH/oh-my-zsh.sh` line:
```bash
DISABLE_AUTO_TITLE="true"
```

### 5. Restart your terminal and Claude Code

## Usage

In Claude Code, just say:

| Language | Command |
|----------|---------|
| English | "rename terminal to backend" |
| Czech | "přejmenuj terminal na backend" |
| German | "benenne terminal um zu backend" |
| Spanish | "renombrar terminal a backend" |
| French | "renommer terminal en backend" |

Other commands:
- "list terminals" - Show all named terminals
- "clear terminal name" - Remove the current terminal's name

## How It Works

```
┌─────────────────┐                              ┌─────────────────┐
│   MCP Server    │──── detects TTY via ────────▶│   /proc/PID/    │
│                 │     process tree             │   (Linux)       │
└────────┬────────┘                              └─────────────────┘
         │ writes name
         ▼
┌──────────────────┐
│ ~/.claude-term-  │◀─────── reads ──────┐
│   inal-name-*    │                     │
└──────────────────┘              ┌──────┴────────┐
                                  │ Shell Watcher │
                                  │ (updates title)│
                                  └───────────────┘
```

1. **MCP server** detects its own TTY by walking up the process tree (no race conditions!)
2. **Config file** is written for that specific terminal
3. **Shell watcher** picks up the change and updates the terminal title

## Available MCP Tools

| Tool | Description |
|------|-------------|
| `rename_terminal` | Rename the current terminal tab |
| `list_terminals` | List all named terminal sessions |
| `clear_terminal_name` | Clear the current terminal's name |

## Requirements

- Node.js 18+
- Linux (Ubuntu, Debian, Fedora, etc.) or macOS
- Bash or Zsh
- Claude Code CLI

## Terminal Title Format

```
<name> | <terminal RAM>MB | free: <system free RAM>
```

Example: `Backend API | 312MB | free: 11Gi`

## Troubleshooting

### Terminal title not updating?
- Make sure you restarted your terminal after adding the watcher
- Check if watcher is running: `ps aux | grep _claude_terminal_watcher`
- Check if config file exists: `ls ~/.claude-terminal-name-*`

### "Could not detect terminal TTY" error?
- This happens on non-Linux systems or non-standard environments
- The MCP server uses `/proc` filesystem to detect the terminal
- Make sure Claude Code is running in a real terminal (not piped)

### Oh My Zsh overwriting title?
- Add `DISABLE_AUTO_TITLE="true"` to your `.zshrc`

## License

MIT

## Contributing

PRs welcome! Ideas for improvement:
- macOS support improvements
- Windows support
- CPU usage monitoring
- Custom title format configuration

TDQS

A3.6/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct action: rename the current terminal, list named terminals, and clear the current name. There is no meaningful overlap in purpose.

Naming Consistency4/5

All names use snake_case with a verb-first pattern, making them predictable. However, clear_terminal_name adds an extra noun compared with rename_terminal, creating a slight asymmetry.

Tool Count5/5

Three tools are well matched to the narrow terminal-renaming purpose, with each operation earning its place. There is no unnecessary surface area.

Completeness4/5

The set covers the core lifecycle of naming, listing, and clearing terminal names. Minor gaps exist, such as retrieving the current terminal's name or targeting a specific terminal by identifier.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues