claude-code - 💡(How to fix) Fix Feature request: Remote session control (compact, loop, slash commands via API/MCP) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46697Fetched 2026-04-12 13:35:26
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Fix Action

Fix / Workaround

Current Workaround

RAW_BUFFERClick to expand / collapse

Problem

Claude Code slash commands (/compact, /loop, etc.) can only be typed directly in the terminal. There's no way to trigger them remotely — not from hooks, not from MCP tools, not from external integrations like Telegram.

This creates significant friction for users who:

  • Interact primarily via Telegram/Discord MCP integrations from mobile
  • Run long sessions where compaction is needed but they're away from the terminal
  • Want to trigger /loop or other commands from external automation

Current Workaround

Run Claude Code inside tmux, then use tmux send-keys -t session "/compact" Enter from SSH/remote. This works but requires terminal multiplexer setup and SSH access.

Proposed Solutions (any of these would help)

Option A: Remote command API

Expose a local API endpoint (e.g., localhost:PORT/api/command) that accepts slash commands: ```bash curl -X POST localhost:3456/api/command -d '{"command": "/compact"}' ```

Option B: MCP tool for session control

Add a built-in MCP tool (e.g., `SessionControl`) that the agent can invoke: ``` SessionControl({ action: "compact" }) SessionControl({ action: "loop", prompt: "check CI" }) ```

Option C: File-based command interface

Watch a file (e.g., `~/.claude/remote-commands`) for commands. External processes write to it, Claude Code reads and executes.

Option D: Hook-triggered commands

Allow hooks to return special directives that trigger slash commands: ```json { "directive": "compact" } ```

Use Case

User runs Claude Code with Telegram MCP. They interact from their phone all day. When context gets full, the agent auto-prepares for compaction but cannot trigger /compact itself. User must physically go to the terminal. With remote control, the Telegram message "!compact" could trigger it seamlessly.

Environment

  • Claude Code 2.1.101
  • macOS, Opus 4.6 (1M context)
  • Telegram MCP integration

extent analysis

TL;DR

Implementing a remote command interface, such as a local API endpoint or a file-based command interface, would allow users to trigger Claude Code slash commands remotely.

Guidance

  • Consider implementing Option A: Remote command API to expose a local API endpoint that accepts slash commands, allowing users to trigger commands remotely using tools like curl.
  • Evaluate Option C: File-based command interface as a simpler alternative, where external processes write commands to a file and Claude Code reads and executes them.
  • Assess the feasibility of Option B: MCP tool for session control and Option D: Hook-triggered commands, considering the existing MCP tool infrastructure and hook functionality.
  • Verify the chosen solution by testing remote command execution using the implemented interface, ensuring that slash commands are triggered correctly.

Example

curl -X POST localhost:3456/api/command -d '{"command": "/compact"}'

This example demonstrates how to use curl to send a POST request to a local API endpoint to trigger the /compact command.

Notes

The chosen solution should be compatible with the existing Claude Code version (2.1.101) and environment (macOS, Opus 4.6, Telegram MCP integration).

Recommendation

Apply Option A: Remote command API as it provides a flexible and widely-supported interface for remote command execution, allowing users to trigger slash commands seamlessly from external integrations like Telegram.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING