claude-session

claude-session

MCP server for programmatic lifecycle management of Claude Code sessions, supporting list, create, read, send, fork, wait, and interrupt operations.

Category
访问服务器

README

claude-session

Machine-readable lifecycle control for Claude Code sessions. It provides the small session API needed by another agent or orchestrator: list, create, read, send, fork, wait, and interrupt.

Install

Requirements: Bun and an authenticated claude CLI on PATH.

bun add --global \
  "claude-session@https://github.com/celados/claude-session/releases/latest/download/claude-session.tgz"
claude-session --help

This installs the same GitHub Release artifact used by every public user. The package remains marked private so it cannot be published to npm by mistake.

Install the agent integration

The plugin combines an MCP server, which exposes executable session tools, with a Skill that teaches the host when to create, continue, fork, wait for, or interrupt a session. Install it from this public repository after installing the CLI above.

Claude Code:

claude plugin marketplace add celados/claude-session
claude plugin install claude-session@claude-session --scope user

Codex:

codex plugin marketplace add celados/claude-session
codex plugin add claude-session@claude-session

Start a new Claude Code or Codex session after installation. The MCP server appears as claude-session; its tools are list_sessions, read_session, create_session, send_to_session, fork_session, wait_for_session, and interrupt_session.

Commands

Command Behavior
list Merge native Claude agents, indexed history, and locally managed runs.
create Allocate a session UUID and start a detached headless Claude turn.
read Return normalized user/assistant text and an opaque cursor.
send Start another detached turn on the same idle session UUID.
fork Copy completed context into a new session UUID and start a turn.
wait Wait until completion or a bounded timeout, then return new messages.
interrupt Interrupt the managed process group or native Claude process.

Human-readable commands return YAML:

claude-session list --all
claude-session create --cwd "$PWD" --name investigation \
  --prompt "Investigate the failing build."
claude-session read --id SESSION_ID
claude-session send --id SESSION_ID --prompt "Continue and run the tests."
claude-session fork --id SESSION_ID --prompt "Try the alternative design."
claude-session wait --id SESSION_ID --timeoutMs 30000
claude-session interrupt --id SESSION_ID

For strict JSON, use argc's @run interface. --json belongs to @run, not to an individual command:

claude-session @run 'await argc.call.list({ all: true })' --json
claude-session @run \
  'await argc.call.wait({ id: "SESSION_ID", timeoutMs: 30000 })' --json

The complete machine-readable API is available through:

claude-session @schema

The same API is available to MCP clients over stdio:

claude-session-mcp

Lifecycle model

Runs started by this tool use Claude's headless JSON mode rather than Claude's native --background agent manager. This is intentional: headless mode accepts a caller-provided UUID, so send can resume the exact same session and fork can return the new UUID immediately.

If send or fork targets an idle native background agent, the tool first releases it with claude stop, preserving its conversation, and then resumes it as a managed run. Concurrent turns are rejected with session_busy.

Managed job metadata and private stdout/stderr logs live under $XDG_STATE_HOME/claude-session/jobs, or ~/.local/state/claude-session/jobs when XDG_STATE_HOME is unset. Prompt handoff files use mode 0600 and are unlinked immediately after the child process starts.

Development

bun install
bun run test
bun run typecheck
bun run check
bun run verify:package

Releases are deliberately created through the Release claude-session GitHub Actions workflow. It tests the source, verifies an isolated global install, publishes versioned and stable tarballs plus SHA256SUMS, and then repeats the install without a GitHub token.

推荐服务器

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

官方
精选