Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

A terminal window displays code and logs, with a labeled metric showing 61% token reduction from aiterm-mcp for…
Open SourceScore: 77

Cut Token Waste 61% on Server Tasks with aiterm-mcp

Install aiterm-mcp for a persistent terminal MCP server that cuts token waste by 61% on logs, eliminates SSH reconnection boilerplate, and prunes output before Claude Code reads it.

·1d ago·3 min read··7 views·AI-Generated·Report error
Share:
Source: dev.tovia devto_claudecodeCorroborated
How do I install and use aiterm-mcp to reduce token usage in Claude Code?

Install aiterm-mcp with `claude mcp add --scope user --transport stdio aiterm -- npx -y aiterm-mcp`. It holds one terminal session, so SSH connects once, state persists, and output is pruned before the AI reads it, saving up to 61% on logs.

TL;DR

aiterm-mcp gives Claude Code a single persistent terminal, slashing token usage by eliminating redundant SSH reconnections and pruning output.

What Changed — aiterm-mcp: A Persistent Terminal MCP Server

How Anthropic’s MCP Cut Token Costs by 95% | by Minervee | Coding Nexus ...

A new MCP server called aiterm-mcp has been published to npm. It gives Claude Code a single persistent terminal session instead of spawning a fresh shell for every command. This eliminates the "connect → authenticate → execute → disconnect" cycle that silently burns tokens on every SSH or server task.

What It Means For You — Concrete Impact on Daily Claude Code Usage

Optimizing Token Usage in MCP Servers with GraphQL: A 70–80% Token ...

When you ask Claude Code to run server commands, it typically sends one command at a time. For SSH, that means ssh host "command" every single time. Each call repeats the full connection, authentication, and MOTD boilerplate. The author measured SSH login MOTD alone at ~385 tokens per connection. For a 10-command task, that's 3,800 tokens of pure boilerplate — before any real work.

aiterm-mcp fixes this by holding one terminal session. SSH connects once. cd and environment variables persist. All subsequent commands are sent directly through the same session. You pay the MOTD token cost once, then zero.

But there's more: aiterm-mcp also prunes output before Claude Code reads it. It removes control characters, folds repeated lines, truncates long output (keeping head and tail), and even summarizes common commands like git status, git log, grep, and pytest into key points. The author measured a 61% reduction on 120 lines of journalctl logs.

Try It Now — Installation and Usage

Installation is a single command. No cloning or building required:

claude mcp add --scope user --transport stdio aiterm -- npx -y aiterm-mcp

Restart Claude Code, then verify with /mcp. You'll see six new tools: pty_open, pty_send, pty_read, pty_send_key, pty_close, pty_list.

Requirements:

  • Node.js 18+
  • tmux (apt install tmux / brew install tmux)
  • Linux / WSL2 / macOS (Windows bridges to WSL)

How to use it in practice:

  1. Open a terminal: pty_open creates a tmux session.
  2. SSH once: pty_send("ssh 192.168.1.2") — authentication happens here, once.
  3. Run commands: pty_send("uname -a"), pty_send("docker ps -a"), etc. — all run in the same SSH session.
  4. Read pruned output: pty_read returns output with control characters stripped, repeated lines folded, and long content truncated.

Because the terminal is backed by tmux, sessions persist across Claude Code restarts. You can also tmux attach to watch the AI work in real-time.

Honest note: This doesn't eliminate round-trips — Claude Code still needs to send, read, and decide. What it eliminates is the cost per round-trip: no re-authentication, no re-setup, and no output noise.


Source: dev.to

Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from multiple verified sources, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

**What Claude Code users should do differently:** 1. **Install aiterm-mcp immediately if you do any server work through Claude Code.** Every SSH command you run today is paying a hidden token tax of ~385 tokens per connection. For a typical debugging session with 10-20 commands, that's 4,000-8,000 wasted tokens just on MOTD boilerplate. aiterm-mcp reduces that to a one-time cost. 2. **Use `pty_send` instead of having Claude Code construct `ssh host "command"` strings.** The key insight is that aiterm-mcp transforms your workflow from "send command → reconnect → send next command" to "open connection → send commands → read pruned output." You'll need to adjust your prompts to tell Claude Code to use the pty tools rather than the default terminal tool. 3. **Add a CLAUDE.md entry** to remind Claude Code to use aiterm-mcp for server tasks: "When running commands on remote servers, use the aiterm-mcp pty tools to maintain a persistent SSH session and reduce token usage." 4. **Take advantage of the output pruning for log-heavy tasks.** If you frequently ask Claude Code to analyze logs (`journalctl`, `docker logs`, `kubectl logs`), aiterm-mcp's built-in summarization can cut token consumption by 60% or more on those outputs. This is especially valuable for long-running monitoring or debugging sessions.
Compare side-by-side
Claude Code vs aiterm-mcp
Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Open Source

View all