MCP State Sidecar — durable state persistence for multi-agent AI workflows
Project description
MCP State Sidecar Server
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:
- Clone the repository:
git clone https://github.com/askadvaith/MCP-State-Sidecar.git cd MCP-State-Sidecar
- Install build dependencies:
pip install --upgrade build
- Build the wheel and source distribution:
python -m build
- 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 (returnsfound=Falseif 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 uniquerun_id.workflow_discover(tags?, status?): Find workflows filtered by tags or status.workflow_claim(run_id, agent_id): Atomically claim acreatedworkflow.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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_state_sidecar-0.1.0.tar.gz.
File metadata
- Download URL: mcp_state_sidecar-0.1.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb065c2438b20a0a1feacb5c92c027ed0cba6520a6a7e2d21f5ab0b2e0528128
|
|
| MD5 |
c1e394d008774b05bd04cae49cbe3440
|
|
| BLAKE2b-256 |
67f30acf00adc68a95bc5db6cdb7e4ff6e9880b442cd66e70075085abea2e1aa
|
Provenance
The following attestation bundles were made for mcp_state_sidecar-0.1.0.tar.gz:
Publisher:
publish.yml on askadvaith/MCP-State-Sidecar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_state_sidecar-0.1.0.tar.gz -
Subject digest:
fb065c2438b20a0a1feacb5c92c027ed0cba6520a6a7e2d21f5ab0b2e0528128 - Sigstore transparency entry: 1804223556
- Sigstore integration time:
-
Permalink:
askadvaith/MCP-State-Sidecar@6c683b6934328751d3c32c9e315b9cc059f94b6c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/askadvaith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c683b6934328751d3c32c9e315b9cc059f94b6c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_state_sidecar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_state_sidecar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e680a7ac7cd49d9b7f6bad8350efdf7fd1580139c81a9973779a5ca96977317
|
|
| MD5 |
8b4631158361ddad364669367b8b4c35
|
|
| BLAKE2b-256 |
d39dba435f4ef3db924e64b7e94f6dec69c7f422a22d6ea8b185d13980923372
|
Provenance
The following attestation bundles were made for mcp_state_sidecar-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on askadvaith/MCP-State-Sidecar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_state_sidecar-0.1.0-py3-none-any.whl -
Subject digest:
1e680a7ac7cd49d9b7f6bad8350efdf7fd1580139c81a9973779a5ca96977317 - Sigstore transparency entry: 1804223573
- Sigstore integration time:
-
Permalink:
askadvaith/MCP-State-Sidecar@6c683b6934328751d3c32c9e315b9cc059f94b6c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/askadvaith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c683b6934328751d3c32c9e315b9cc059f94b6c -
Trigger Event:
push
-
Statement type: