Skip to main content

MCP server for multi-session awareness and coordination

Project description

mcp-session-registry

CI Python 3.11+ License: Apache-2.0

Lightweight MCP server for multi-session awareness — lets AI agents know who else is active on the same machine.

Why

When you run multiple AI CLI sessions (Kiro, Claude Code, Gemini CLI) on the same machine, they are blind to each other. This causes:

  • File conflicts — two sessions editing the same file
  • Duplicated work — agents picking up the same task
  • Wasted context — no way to know what another session is doing

mcp-session-registry solves this with a shared presence layer:

  • Sessions register on spawn, declare a theme, and heartbeat every 2-3 minutes
  • Sessions claim files/resources — other sessions see the claim before touching them
  • Stale sessions (no heartbeat >5min) are automatically reaped
  • Everything persists in SQLite — survives individual session crashes

Quick Start

# Run directly
uvx mcp-session-registry

# Or install
pip install mcp-session-registry

# Configure port (default: 8000)
MSR_PORT=3203 mcp-session-registry

MCP Tools

Tool Description
session_register Register a new session. Returns session_id for subsequent calls.
session_list List all active sessions on this machine.
session_heartbeat Send heartbeat to keep session alive (call every 2-3 min).
session_end Gracefully end a session and release all its claims.
session_claim Claim a resource (file, branch, work item). Advisory lock.
session_release Release a previously claimed resource.
session_conflicts Check if resources are claimed by another active session.

How It Works

Session A registers → gets session_id
Session A claims "src/main.py"
Session B calls session_conflicts(["src/main.py"])
  → returns: claimed by Session A (pid 1234, theme "refactor auth")
Session B picks a different file

Sessions that stop sending heartbeats are reaped after 5 minutes — their claims are released automatically.

Configuration

Environment Variable Default Description
MSR_PORT 8000 HTTP port for StreamableHTTP transport
MSR_DB_PATH ~/.local/share/session-registry/sessions.db SQLite database path

Integration with Kiro CLI

Add to your ~/.kiro/settings/mcp.json:

{
  "mcpServers": {
    "session-registry": {
      "url": "http://localhost:3203/mcp",
      "autoApprove": ["session_register", "session_list", "session_heartbeat", "session_end", "session_claim", "session_release", "session_conflicts"]
    }
  }
}

Run as a systemd user service:

# ~/.config/systemd/user/session-registry.service
[Unit]
Description=MCP Session Registry

[Service]
ExecStart=%h/.local/bin/mcp-session-registry
Environment=MSR_PORT=3203
Restart=on-failure

[Install]
WantedBy=default.target

Health Check

curl http://localhost:3203/health
# {"status": "healthy", "version": "0.2.0", "uptime_seconds": 3600}

Development

git clone https://github.com/filhocf/mcp-session-registry
cd mcp-session-registry
uv sync
uv run pytest tests/ -v
uv tool run ruff check src/ tests/

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_session_registry-0.2.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_session_registry-0.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_session_registry-0.2.0.tar.gz.

File metadata

  • Download URL: mcp_session_registry-0.2.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcp_session_registry-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0b4476fb490dffdc497ce9a86cceb8eae8923284a6adffe369eb87296f600882
MD5 8cbcb5c302054d8218d7be126defc69e
BLAKE2b-256 c19a6e37be836bdeb6e97f565d8af0e5d209d4d2b3d15d4aec21d2c3f88ce5d5

See more details on using hashes here.

File details

Details for the file mcp_session_registry-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_session_registry-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcp_session_registry-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 334217eeab277247be321ae2f51042a5a97ede0b9a76cd05ec12df2d039d752a
MD5 a1e01a164abb139020194f1a15970c3c
BLAKE2b-256 e9083514fa8fc1acf9c8e6b2c228f7c003eb798c59a64ed7d792967ffe3df8ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page