npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@elegant_white/session-mcp

v1.1.0

Published

Unified MCP service for AI session management and multi-session coordination

Readme

Session MCP

统一的 AI 会话管理与多会话协调 MCP 服务。合并了 session-coordinator-mcp(协调层)和 session-manager-mcp(管理层),提供完整的会话生命周期管理 + 跨会话消息协调。

与旧版区别

| 变化 | 旧版 | 新版 | |------|------|------| | MCP 数量 | 2 个(coordinator + manager) | 1 个 | | send_message | coordinator 写 inbox + manager push 激活(两个工具同名) | 统一一个工具:inbox + 条件 push | | register_session | 独立工具 | 合并到 update_session(自动注册) | | 默认 TTL | 5 分钟 | 4 小时(可配置) | | hook 脚本 | 5+ 个文件 | 3 个文件(core + onSend/onContinue + bridge) | | 场景/模型注入 | 独立脚本 scene-model-context.js | 合并到 session-mcp-core.js |

安装

1. 构建

cd services/session-mcp && npm install && npm run build

2. 配置 MCP

在 ~/.msun/mcp-servers.json 中,将原来的 session-coordinator 和 session-manager 替换为:

{
  "session-mcp": {
    "command": "node",
    "args": [
      "D:\\programming\\services\\session-mcp\\dist\\index.js",
      "--default-ttl=4h"
    ],
    "env": {},
    "enabled": true
  }
}

--default-ttl 参数支持以下格式:

  • 4h = 4 小时
  • 30m = 30 分钟
  • 300s = 300 秒
  • 14400 = 14400 秒(纯数字视为秒)

不传则默认 4h(14400 秒)。

3. 部署插件

项目使用 3 个插件(部署在 ~/.msun/plugins/),替代旧的 hook 脚本:

| 插件 | Hook | 功能 | |------|------|------| | session-coordination | onSend + onContinue | 注入 Session ID + 注册提醒 + 收件箱未读提醒 + 关注会话状态 | | session-manager-bridge | onToolResult | 检测工具结构化 JSON 生成 __actions(create_session/manage_session/send_message push) | | scene-model-context | onSend + onContinue | 注入场景/模型上下文 |

插件文件位于 ~/.msun/plugins/<插件名>/index.ts(或 .js),IDE 启动时自动加载。修改后需刷新插件页面或重启 IDE。

4. CLI 端接入(可选)

将 hooks/cli-plugin/ 目录复制到 .engineer/plugins/session-mcp/。

工具列表

协调工具

| 工具 | 说明 | |------|------| | update_session | 注册/更新会话信息。未注册时自动注册(需提供 task + projectPath) | | list_sessions | 列出所有会话(含已完成未过期的),可按 projectPath/groupId 过滤 | | send_message | 统一消息发送:content 写入 inbox + activationMessage 条件 push 激活 | | wait_for_sessions | 阻塞等待一个或多个会话完成 | | watch_session | 非阻塞关注目标会话,状态自动注入 system prompt | | complete_session | 标记完成,设 TTL 延时删除(默认 4h) | | query_session | 查询单个会话详情 | | read_inbox | 读取并消费收件箱消息 |

管理工具

| 工具 | 说明 | |------|------| | create_session | 创建新会话(经 __actions 触发前端) | | manage_session | tab 操作(switch/close/cancel/set_model/set_scene/set_input/pin/unpin/send_message/rename) |

send_message 双内容设计

send_message 有两个内容参数,用途不同:

| 参数 | 写入位置 | 显示位置 | 用途 | |------|----------|----------|------| | content | inbox 文件 | 不显示在聊天 UI | 详细信息,目标通过 read_inbox 读取 | | activationMessage | __actions push | 聊天 UI 中 | 简短激活文本,唤醒目标会话 |

activate 参数控制 push 行为:

  • auto(默认):目标停止/已完成时 push,活跃时跳过(hook 自然提醒)
  • always:强制 push
  • never:只写 inbox

存储结构

~/.msun/session-mcp/
  ├── sessions/{sessionId}.json      ← 每会话状态文件
  └── inboxes/{sessionId}/msg-*.json  ← 发给这个会话的消息

零并发写冲突:每会话只写自己的状态文件,发消息只往对方收件箱创建新文件。

技术栈

  • TypeScript + Node.js 18+
  • @modelcontextprotocol/sdk(唯一外部依赖)
  • 纯 fs 模块存储(零原生依赖,跨平台)