Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

MCP server for Claude Code self-management, enabling hot restart and context compaction commands.

README.md

self-claude-mcp

Requires Claude Code | SIGN UP HERE

MCP server for Claude Code self-management commands (hot restart, compaction).

Installation

pip install self-claude-mcp

Add to your Claude MCP config:

{
  "mcpServers": {
    "self-claude": {
      "command": "self-claude-mcp",
      "env": {
        "AUTOPOIESIS": "1"
      }
    }
  }
}

Note: AUTOPOIESIS=1 is optional. If set, restart messages will remind Claude to enable autopoiesis-mcp (makes Claude loop on purpose). Remove the env block if you don't use it.

Setup

After installing the MCP, Claude needs to install bash scripts for the commands to work.

Ask Claude to run: `` Use self_claude with setup_only=True and install the scripts ``

Or manually: call self_claude(cmd="", setup_only=True) to get the installation instructions.

Requirements

  • tmux: Scripts use tmux for session management
  • Claude Code: Must be running inside a tmux session named "claude"

Starting Claude in tmux

Use claude-debug (installed by setup) or manually:

tmux -u new-session -d -s claude
tmux send-keys -t claude 'claude --debug' Enter
tmux -u attach -t claude

Usage

Once set up, Claude can use these commands:

| Command | Description | |---------|-------------| | self_claude("self_restart") | Hot restart with auto-resume | | self_claude("self_compact") | Trigger context compaction | | self_claude("", setup_only=True) | Get installation instructions |

Hot Restart

Use when MCP configs change and you need to reload without losing conversation:

  1. Claude calls self_claude("self_restart") → returns bash self_restart
  2. Claude runs bash self_restart
  3. Handler sends /exit, waits for death, relaunches, sends /resume, selects session 1

Compaction

Use when context is running low:

  1. Claude calls self_claude("self_compact") → returns bash self_compact
  2. Claude runs bash self_compact
  3. Sends /compact to the tmux session

Troubleshooting

"No tmux session 'claude'"

Make sure Claude Code is running inside a tmux session named "claude": ``bash tmux -u new-session -s claude claude --debug ``

"Handler not found"

Run the setup instructions again: `` self_claude(cmd="", setup_only=True) ` Then install the scripts to /usr/local/bin/`.

Restart hangs

Check the handler log: ``bash cat /tmp/claude_restart_handler.log ``

Common issues:

  • pgrep -x "claude" matches wrong process → verify with pgrep -x "claude"
  • tmux session died → restart with claude-debug

Docker / Container

If running in a container, make sure:

  • tmux is installed: apt install tmux
  • Scripts are in PATH: /usr/local/bin/ or ~/.local/bin/
  • Container user can write to /tmp/

Scripts Installed

| Script | Location | Purpose | |--------|----------|---------| | claude-debug | /usr/local/bin/ | Start Claude in tmux background | | self_restart | /usr/local/bin/ | Orchestrator (spawns handler) | | claude_restart_handler | /usr/local/bin/ | Detached handler (does actual restart) | | self_compact | /usr/local/bin/ | Trigger compaction | | rules | /usr/local/bin/ | Manage Claude Code rule files |

rules command

Manage Claude Code rule files from the command line:

# Add a rule
rules global my-rules "Always use TypeScript"
rules project api-rules "Use REST conventions"

# List rules
rules show global
rules show project

# Delete a rule
rules delete global my-rules

Rules are stored in ~/.claude/rules/ (global) or ./.claude/rules/ (project).

Environment Variables

| Variable | Description | |----------|-------------| | AUTOPOIESIS=1 | Enable autopoiesis warning in restart message. Requires autopoiesis-mcp. |

Set in your shell profile or export before running Claude.

Security Note

⚠️ Warning: You should disallow this MCP on subagents. Subagents running these commands can cause strange interactions.

License

MIT

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Developer Tools servers.