Transport-level routing for MCP/ACP protocols
Workers Overview
Worker implementations for stdio Bus kernel - high-performance message routing for agent protocols.
What are Workers?
Workers are child processes spawned by the stdio Bus kernel that implement specific protocol functionality. The stdio Bus kernel provides the core message routing infrastructure, while workers handle the actual protocol implementations (ACP, MCP, etc.) and use cases.
Workers communicate with the stdio Bus kernel via stdin/stdout using NDJSON (Newline-Delimited JSON), enabling high-performance, language-agnostic protocol implementations.
Architecture
The stdio Bus architecture consists of two main layers:
- stdio Bus kernel - The core message routing daemon that manages worker processes and routes messages between clients and workers
- Workers Registry - A collection of worker implementations that run as child processes of the kernel
Loading diagram...
Workers Launcher
The Workers Launcher is responsible for initializing and managing the lifecycle of worker processes. It ensures automatic discovery of agents from the ACP Registry and provides dynamic management of worker processes with session affinity routing. The launcher serves as a critical component in maintaining the seamless execution of multiple agents with varying protocols, offering support for orchestration and scalability within the stdio Bus framework.
Launcher: npx @stdiobus/workers-registry
Available Workers
The @stdiobus/workers-registry package provides the following worker implementations:
ACP Worker
Protocol: ACP (Agent Client Protocol)
Launch: acp-worker
Purpose: Complete ACP protocol support including initialize, session management, prompts, and MCP server integration
Use Cases: Running ACP agents with tool execution capabilities
Registry Launcher
Protocol: ACP (Agent Client Protocol)
Launch: registry-launcher
Purpose: Automatic agent discovery from ACP Registry, dynamic agent process management, and session affinity routing
Use Cases: Running multiple ACP agents (Claude, Goose, Cline, GitHub Copilot, etc.) with automatic routing based on agentId
MCP-to-ACP Proxy
Protocol: MCP → ACP (protocol bridge)
Launch: mcp-to-acp-proxy
Purpose: Enables MCP clients to communicate with ACP agents by translating between protocols
Use Cases: IDE integration, connecting MCP-based tools to ACP agents
Echo Worker
Protocol: NDJSON (JSON-RPC)
Launch: echo-worker
Purpose: Testing stdio Bus kernel functionality and serving as a reference implementation for custom workers
Use Cases: Protocol testing, development, and learning
MCP Echo Server
Protocol: MCP (Model Context Protocol)
Launch: mcp-echo-server
Purpose: Provides example MCP tools (echo, reverse, uppercase, delay, error) for testing
Use Cases: Testing MCP integration, development, and debugging
NDJSON Protocol
Workers communicate with stdio Bus kernel via stdin/stdout using NDJSON (Newline-Delimited JSON), a simple and efficient protocol for streaming JSON messages.
Protocol Rules
- Input (stdin): stdio Bus sends JSON-RPC messages, one per line
- Output (stdout): Workers write JSON-RPC responses, one per line
- Errors (stderr): All logging and debug output goes to stderr
- Critical: Never write non-JSON to stdout - it will break the protocol
Message Types
Request (requires response):
{"jsonrpc":"2.0","id":"1","method":"test","params":{"foo":"bar"}}
Response:
{"jsonrpc":"2.0","id":"1","result":{"status":"ok"}}
Notification (no response):
{"jsonrpc":"2.0","method":"notify","params":{"event":"started"}}
Session Affinity
Messages with the same sessionId are routed to the same worker instance, ensuring session state is maintained:
{"jsonrpc":"2.0","id":"1","method":"test","sessionId":"sess-123","params":{}}
Workers must preserve sessionId in responses for proper routing.
Graceful Shutdown
Workers must handle SIGTERM for graceful shutdown:
- Stop accepting new messages
- Complete in-flight processing
- Exit with code 0
stdio Bus sends SIGTERM during shutdown or worker restarts.
Getting Started
To get started with workers:
- Install the package:
npm install @stdiobus/workers-registry - Get stdio Bus kernel: Available via Docker or build from source
- Configure workers: Create a configuration file specifying which workers to run
- Run stdio Bus: Start the kernel with your configuration
See the Installation Guide for detailed setup instructions.
Next Steps
- Installation - Install and set up the workers package
- Configuration - Configure workers for your use case
- Integration - Integrate workers into your application
- ACP Worker - Learn about the ACP Worker implementation
- Registry Launcher - Discover how to use the Registry Launcher
Resources
- stdio Bus kernel - Core protocol and daemon
- stdio Bus on Docker Hub - Docker images
- ACP Registry - Available ACP agents
- Agent Client Protocol SDK - Official ACP SDK
- Model Context Protocol SDK - Official MCP SDK