Skip to main content
Glama

Shared Memory MCP Server

Solving coordination tax in agentic teams - where Opus + 4 Sonnets burns 15x tokens but only gets 1.9x performance.

Prerequisites

  • Node.js 18+

  • npm or yarn

  • Claude Desktop (for MCP integration)

Related MCP server: universal-memory

The Problem

Current agentic team patterns have terrible token efficiency:

  • Traditional: 1 request × 4K tokens = 4K tokens

  • Agentic Team: 1 coordinator + 4 workers × 12K tokens each = 48K+ tokens

  • Efficiency: 1.9x performance / 15x cost = 12% efficiency

This MCP server provides shared memory for agentic teams to achieve 6x token efficiency while maintaining coordination benefits.

Core Features

1. Context Deduplication

  • Store shared context once, reference by key

  • 10:1 compression ratio with intelligent summarization

  • Workers get 100-token summaries instead of full context

2. Incremental State Sharing

  • Append-only discovery system

  • Workers share findings in real-time

  • Delta updates prevent retransmission

3. Work Coordination

  • Claim-based work distribution

  • Dependency tracking and resolution

  • Reactive task handoff between workers

4. Token Efficiency

  • Context compression and lazy loading

  • Delta updates since last version

  • Expansion on demand for specific sections

Installation

# Clone the repository
git clone https://github.com/haasonsaas/shared-memory-mcp.git
cd shared-memory-mcp

# Install dependencies
npm install

# Build the server
npm run build

Quick Start

# Run in development mode
npm run dev

# Or run the built server
npm start

# Test the agentic workflow
npm test
# or
npm run test-workflow

Usage Example

// 1. Create agentic session (coordinator)
const session = await mcp.callTool('create_agentic_session', {
  coordinator_id: 'opus-coordinator-1',
  worker_ids: ['sonnet-1', 'sonnet-2', 'sonnet-3', 'sonnet-4'],
  task_description: 'Analyze large codebase for performance issues',
  codebase_files: [...], // Full context stored once
  requirements: [...],
  constraints: [...]
});

// 2. Workers get compressed context (not full retransmission)
const context = await mcp.callTool('get_worker_context', {
  session_id: session.session_id,
  worker_id: 'sonnet-1'
}); // Returns summary + reference, not full context

// 3. Publish work units for coordination
await mcp.callTool('publish_work_units', {
  session_id: session.session_id,
  work_units: [
    { unit_id: 'analyze-auth', type: 'security', priority: 'high' },
    { unit_id: 'optimize-db', type: 'performance', dependencies: ['analyze-auth'] }
  ]
});

// 4. Workers claim and execute
await mcp.callTool('claim_work_unit', {
  session_id: session.session_id,
  unit_id: 'analyze-auth',
  worker_id: 'sonnet-1',
  estimated_duration_minutes: 15
});

// 5. Share discoveries incrementally
await mcp.callTool('add_discovery', {
  session_id: session.session_id,
  worker_id: 'sonnet-1', 
  discovery_type: 'vulnerability_found',
  data: { vulnerability: 'SQL injection in auth module' },
  affects_workers: ['sonnet-2'] // Notify relevant workers
});

// 6. Get only new updates (delta, not full context)
const delta = await mcp.callTool('get_context_delta', {
  session_id: session.session_id,
  worker_id: 'sonnet-2',
  since_version: 5 // Only get changes since version 5
});

Architecture

┌─────────────────┐    ┌─────────────────┐
│ Opus Coordinator│    │ Shared Memory   │
│                 │────│ MCP Server      │
│ - Task Planning │    │                 │
│ - Work Units    │    │ - Context Store │
│ - Coordination  │    │ - Discovery Log │
└─────────────────┘    │ - Work Queue    │
                       │ - Dependencies  │
┌─────────────────┐    └─────────────────┘
│ Sonnet Workers  │           │
│                 │───────────┘
│ - Specialized   │    
│ - Parallel      │    ┌─────────────────┐
│ - Coordinated   │    │ Token Efficiency│
└─────────────────┘    │                 │
                       │ 48K → 8K tokens │
                       │ 6x improvement  │
                       │ 1200% better ROI│
                       └─────────────────┘

Token Efficiency Strategies

Context Compression

// Instead of sending full context (12K tokens):
{
  full_context: { /* massive object */ }
}

// Send compressed reference (100 tokens):
{
  summary: "Task: Analyze TypeScript codebase...",
  reference_key: "ctx_123", 
  expansion_hints: ["codebase_files", "requirements"]
}

Delta Updates

// Instead of retransmitting everything:
get_full_context() // 12K tokens each time

// Send only changes:
get_context_delta(since_version: 5) // 200 tokens

Lazy Loading

// Workers request details only when needed:
expand_context_section("codebase_files") // 2K tokens
request_detail("file_content", "auth.ts") // 500 tokens

API Reference

Session Management

  • create_agentic_session - Initialize coordinator + workers

  • get_session_info - Get session details

  • update_session_status - Update session state

Context Management

  • get_worker_context - Get compressed context for worker

  • expand_context_section - Get detailed section data

  • get_context_delta - Get incremental updates

Work Coordination

  • publish_work_units - Publish available work

  • claim_work_unit - Claim work for execution

  • update_work_status - Update work progress

Discovery Sharing

  • add_discovery - Share findings with team

  • get_discoveries_since - Get recent discoveries

Dependency Resolution

  • declare_outputs - Declare future outputs

  • await_dependency - Wait for dependency

  • publish_output - Publish output for others

MCP Configuration

For Claude Desktop

  1. Copy the example configuration:

    cp claude-desktop-config.example.json claude-desktop-config.json
  2. Edit claude-desktop-config.json and update the path to your installation:

    {
      "mcpServers": {
        "shared-memory": {
          "command": "node",
          "args": ["/absolute/path/to/shared-memory-mcp/dist/server.js"]
        }
      }
    }
  3. Add this configuration to your Claude Desktop config file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    • Linux: ~/.config/Claude/claude_desktop_config.json

Note: The claude-desktop-config.json file is gitignored as it contains machine-specific paths.

Performance Benefits

Metric

Traditional

Agentic (Current)

Shared Memory MCP

Token Usage

4K

48K+

8K

Performance Gain

1x

1.9x

1.9x

Cost Efficiency

100%

12%

1200%

Coordination

None

Poor

Excellent

License

MIT

Available Tools

15 tools
add_discoveryC

Add a discovery that other workers can benefit from

Inputs: session_id (required), worker_id (required), discovery_type (required), data (required), +1 more.

await_dependencyC

Wait for a dependency to become available

Inputs: session_id (required), dependency_key (required), timeout_minutes.

claim_work_unitC

Claim a specific work unit for execution

Inputs: session_id (required), unit_id (required), worker_id (required), estimated_duration_minutes (required).

create_agentic_sessionC

Create a new agentic session with shared context for coordinator and workers

Inputs: coordinator_id (required), worker_ids (required), task_description (required), codebase_files, +3 more.

declare_outputsC

Declare what outputs this worker will produce

Inputs: session_id (required), worker_id (required), output_keys (required).

expand_context_sectionC

Get detailed information for a specific context section

Inputs: session_id (required), section (required).

get_context_deltaC

Get incremental updates since a specific version

Inputs: session_id (required), worker_id (required), since_version (required).

get_discoveries_sinceC

Get discoveries made since a specific timestamp

Inputs: session_id (required), since_timestamp (required).

get_session_infoC

Get information about an agentic session

Inputs: session_id (required).

get_session_statsB

Get statistics about the shared memory system

Inputs: no named parameters.

get_worker_contextC

Get compressed context for a specific worker

Inputs: session_id (required), worker_id (required), since_version.

publish_outputC

Publish an output for other workers to consume

Inputs: session_id (required), output_key (required), data (required).

publish_work_unitsC

Publish available work units for workers to claim

Inputs: session_id (required), work_units (required).

update_session_statusC

Update the status of an agentic session

Inputs: session_id (required), status (required).

update_work_statusC

Update the status of a work unit

Inputs: session_id (required), unit_id (required), status (required), result.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 15 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as 'create_agentic_session' for session creation and 'claim_work_unit' for task assignment, but some overlap exists between 'get_session_info' and 'get_session_stats', which could cause minor confusion as both relate to session data retrieval.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case, such as 'add_discovery', 'await_dependency', and 'publish_output', making them predictable and easy to parse for agents.

    Tool Count5/5

    With 15 tools, this server is well-scoped for managing shared memory, agentic sessions, and work coordination, covering essential operations without being overly complex or sparse.

    Completeness4/5

    The tool set provides comprehensive coverage for session management, work unit handling, and context sharing, with minor gaps such as the lack of a tool to delete or terminate sessions, which agents might need to work around.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      A production-grade coordination hub that enables AI agents and human teams to work as a single organism by sharing tasks, context, decisions, and persistent memory across projects. It features two-tier agentic memory with per-agent hot caches, inter-agent messaging, and multi-agent authorship tracking for seamless collaboration.
      2
      -
    • A
      license
      A
      quality
      B
      maintenance
      A vendor-agnostic cognitive persistence layer for AI agents. Eliminate the "repetition tax" by transporting your context, preferences, and history across sessions. Features an auto-adaptation engine that syncs global instructions to ensure operational cohesion and optimize token usage across any LLM or multi-agent workflow.
      38
      139 PyPI
      6
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables teams to share structured, git-synced context among AI coding agents working on the same repository, including living plans, task declarations, handoff briefs, file-provenance history, and conflict detection.
      12
      27 npm
      2
      MIT