MCP State Sidecar Server

MCP State Sidecar Server

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

Category
访问服务器

README

<!-- mcp-name: io.github.askadvaith/mcp-state-sidecar -->

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:

pip install mcp-state-sidecar

If you want to use the Redis backend:

pip install mcp-state-sidecar[redis]

Building from Source

To build and install the package from source:

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

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:

mcp-state-sidecar

Configuration

The server is configured entirely using environment variables:

Environment Variable Default Description
STATE_BACKEND sqlite Storage backend: sqlite or redis
DB_PATH state_sidecar.db Path to the SQLite database file
REDIS_URL redis://localhost:6379 Redis connection URL
SIDECAR_HOST 0.0.0.0 IP host to bind the HTTP SSE server
SIDECAR_PORT 8000 Port 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.

推荐服务器

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

官方
精选