Mcp State Sidecar

io.github.askadvaith由 GitHub 账号 askadvaith 发布v0.1.0更新于 Oct 24, 2026

MCP State Sidecar: durable state persistence for multi-agent AI workflows

概览

AI 生成的概览

一个本地 MCP 服务器,为多智能体工作流提供持久状态存储:键值数据、工作流认领、租约、会话与审计历史。

可以做什么
  • 读写、列出和删除带可选 TTL 的 JSON 键值条目。
  • 创建、发现、认领、检查点、恢复和列出工作流及其运行 ID。
  • 获取、续期和释放独占租约以控制并发。
  • 保存与恢复会话快照,并读取最近的状态变更历史。
  • 查看 sidecar 健康状态与后端指标,或清空全部数据。
适用场景
当多个智能体或进程需要共享在崩溃、横向扩容或更换框架后仍保留的状态,并希望通过 MCP 工具而非进程内内存或带外通信来协调时适用。
运行要求
以 pip 安装的 Python 包在本地运行;Redis 后端需安装 redis 附加组件并连接可用的 Redis 地址。通过 STATE_BACKEND、DB_PATH、REDIS_URL、SIDECAR_HOST、SIDECAR_PORT 等环境变量配置。支持本地子进程的 stdio 模式,或默认绑定 0.0.0.0、端口 8000 的 HTTP SSE 模式。
安装前请注意
HTTP SSE 模式默认绑定所有网络接口,能访问该端口的人可能读取或修改已存状态,且未声明任何认证。sidecar_reset 会不可逆地清空全部数据,工作流认领、检查点与租约操作也会改动共享状态。数据存于本地 SQLite 文件或 Redis 实例,需妥善保护该存储。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp State Sidecar,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP State Sidecar Server

[PyPI version] [PyPI - Python Version] [License: MIT] [MCP Registry]

An MCP-native state sidecar that externalises workflow state for distributed agent deployments.

Quite a simple idea really; instead of storing state inside agents (which breaks when processes crash, scale horizontally, or span multiple frameworks), agents write to and read from this sidecar over the Model Context Protocol (MCP). The sidecar is itself an MCP server; agents call its tools exactly the same way they call any other tool!

The server itself is built with distributed environments in mind, and natively handles concurrency, crash resilience and atomic claims in addition to being a common interface for state management between agents.

Features

  • Durable Key-Value Store: CRUD operations with optional TTL (Time-To-Live).
  • Workflow Lifecycle Registry: Centralised coordination (create, claim, checkpoint, and resume) for distributed multi-agent workers without out-of-band communication.
  • TTL Leases & Locks: Concurrency control to prevent race conditions and split-brain scenarios.
  • Audit Logging & Session Snapshotting: Audit state transitions and persist session contexts.
  • Multiple Backends: SQLite (with WAL mode & serialisation) and high-concurrency Redis currently supported.

Installation

Install the package via pip or your favorite Python package manager:

bash
pip install mcp-state-sidecar

If you want to use the Redis backend:

bash
pip install mcp-state-sidecar[redis]

Building from Source

To build and install the package from source:

  1. Clone the repository:
    bash
    git clone https://github.com/askadvaith/MCP-State-Sidecar.gitcd MCP-State-Sidecar
  2. Install build dependencies:
    bash
    pip install --upgrade build
  3. Build the wheel and source distribution:
    bash
    python -m build
  4. Install the package locally:
    bash
    pip install dist/mcp_state_sidecar-*.whl
    Or install the package in editable mode for active development:
    bash
    pip install -e .

Quick Start

Running the Server

In a multi-agent distributed environment, you would typically run the state sidecar as an HTTP SSE service so multiple remote agents and clients can connect to it concurrently.

HTTP SSE Mode (Primary for Distributed Environments)

Start the SSE server to listen on a network port:

bash
mcp-state-sidecar-http

By default, the server binds to 0.0.0.0 and listens on port 8000. The MCP endpoint is available at http://localhost:8000/mcp.

Stdio Mode (For Subprocess / Local Agent Execution)

Launch the server via standard input/output:

bash
mcp-state-sidecar

Configuration

The server is configured entirely using environment variables:

Environment VariableDefaultDescription
STATE_BACKENDsqliteStorage backend: sqlite or redis
DB_PATHstate_sidecar.dbPath to the SQLite database file
REDIS_URLredis://localhost:6379Redis connection URL
SIDECAR_HOST0.0.0.0IP host to bind the HTTP SSE server
SIDECAR_PORT8000Port for the HTTP SSE server

Tool Reference

Group 1 — Key-Value Store

  • state_set(key, value, ttl_seconds?, agent_id?): Upsert a JSON-serialisable value with optional TTL.
  • state_get(key): Retrieve a value (returns found=False if missing or expired).
  • state_delete(key): Delete a key.
  • state_list(prefix?): List all live keys, optionally filtered by prefix.

Group 2 — Workflow Lifecycle

  • workflow_create(name, tags?): Register a workflow; returns a unique run_id.
  • workflow_discover(tags?, status?): Find workflows filtered by tags or status.
  • workflow_claim(run_id, agent_id): Atomically claim a created workflow.
  • workflow_checkpoint(run_id, step, output): Persist step output and advance the step counter.
  • workflow_resume(run_id): Get full resume context including last step and all step outputs.
  • workflow_status(run_id): Get lightweight status (status, last step, and timestamps).
  • workflow_list(): List all registered workflows.

Group 3 — Lease & Concurrency Control

  • lease_acquire(resource_id, holder_id, ttl_seconds): Attempt to acquire an exclusive lock.
  • lease_release(resource_id, holder_id): Voluntarily release a held lease.
  • lease_renew(resource_id, holder_id, ttl_seconds): Extend lease duration without releasing.

Group 4 — Sessions & History

  • session_save(session_id, context): Save a snapshot of workflow context.
  • session_restore(session_id): Retrieve saved context after crash or handoff.
  • history_log(key?, n?): Retrieve the last N state-transition records with timestamps and writer IDs.

Group 5 — Observability

  • sidecar_health(): Liveness, backend type, uptime, and database metrics.
  • sidecar_reset(): Irreversibly wipe all data.

License

This project is licensed under the MIT License. See LICENSE for details.

来源:README.md,提交 9a992d0

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分