Skip to main content

Event Emission

The satellite communicates with the backend through a centralized EventBus that emits typed events. These events enable real-time status updates, log streaming, and tool metadata synchronization without polling.

Overview

The satellite emits events for:
  • Status Changes: Real-time instance status updates (per-user)
  • Server Logs: Batched stderr output from MCP servers
  • Request Logs: Batched tool execution logs with request/response data
  • Tool Metadata: Tool discovery results with token counts
  • Process Lifecycle: Server start, crash, restart, permanent failure events
All events are processed by the backend’s event handler system and trigger database updates, SSE broadcasts to frontend, and health monitoring actions.
Per-User Instance Events: Status change events now include user_id field to target the correct user’s instance. Each user has independent status tracking in the mcpServerInstances table.

Event System Architecture

Event Types Reference

mcp.server.status_changed

Purpose: Update instance status in real-time (per-user) Emitted by:
  • ProcessManager (connecting, online, crashed, permanently_failed)
  • McpServerWrapper (offline, error, requires_reauth on tool execution failures)
  • RemoteToolDiscoveryManager (connecting, online, offline, error, requires_reauth)
For complete status transition triggers and lifecycle flows, see Status Tracking. Payload:
Example:
Backend Action: Updates mcpServerInstances.status for the specific user’s instance and broadcasts via SSE
Per-User Status: The user_id field ensures status updates are applied to the correct user’s instance. Status exists ONLY in mcpServerInstances table (removed from mcpServerInstallations).

mcp.server.logs

Purpose: Stream server logs (stderr, connection errors, startup messages) to backend Emitted by:
  • ProcessManager (batched stderr output from stdio MCP servers)
Batching Strategy:
  • Interval: 3 seconds after first log entry
  • Max Size: 20 logs per batch (forces immediate flush)
  • Grouping: By installation_id + team_id + user_id (per-user instance)
Payload:
Example:
Backend Action: Inserts logs into mcpServerLogs table, enforces 100-line limit per user instance

mcp.request.logs

Purpose: Stream tool execution logs with full request/response data Emitted by:
  • McpServerWrapper (batched tool call logs)
Batching Strategy:
  • Interval: 3 seconds after first request
  • Max Size: 20 requests per batch
  • Grouping: By installation_id + team_id + user_id (per-user instance)
Payload:
Example:
Backend Action: Inserts requests into mcpRequestLogs table, enforces 100-line limit per user instance Privacy Note: Only emitted if settings.request_logging_enabled !== false

mcp.tools.discovered

Purpose: Synchronize discovered tools and metadata to backend Emitted by:
  • UnifiedToolDiscoveryManager (after tool discovery completes)
Payload:
Example:
Backend Action: Updates mcpTools table with discovered tools and metadata

Process Lifecycle Events

These events track stdio MCP server process state:
Per-User Process Context: The process_id field uniquely identifies each user’s process instance using the format {server_slug}-{team_slug}-{user_slug}-{installation_id}. This ensures process lifecycle events target the correct user’s instance.Example: filesystem-acme-alice-abc123

mcp.server.started

Emitted when: Stdio process successfully spawned Payload:

mcp.server.crashed

Emitted when: Stdio process terminates unexpectedly Payload:

mcp.server.restarted

Emitted when: Stdio process automatically restarted after crash Payload:

mcp.server.permanently_failed

Emitted when: Stdio process crashes 3 times within 5 minutes Payload:
Backend Action: Sets instance status to permanently_failed for the user’s specific instance, requires manual restart

Event Batching Strategy

Why Batching?

Batching reduces:
  • Backend API calls (20 logs = 1 API call instead of 20)
  • Database transactions (bulk insert instead of individual inserts)
  • Network overhead (fewer HTTP requests)
  • Backend processing load (batch operations are more efficient)

Batching Configuration

Batching Implementation

Log batching implementation details are in Log Capture - Buffering Implementation for both server logs and request logs.

EventBus Usage

Emitting Events

Event Registry

All event types are defined in the event registry:

Backend Event Handlers

Each event type has a dedicated backend handler: Status Changed:
Server Logs:
Request Logs:
Tools Discovered:

Integration Points

Process Manager:
  • Emits server logs (stderr batching)
  • Emits lifecycle events (started, crashed, restarted, permanently_failed)
  • Emits status changes (connecting, online, permanently_failed)
MCP Server Wrapper:
  • Emits request logs (tool execution batching)
  • Emits status changes (offline, error, requires_reauth on failures)
  • Emits status changes (connecting, online on recovery)
Tool Discovery Managers:
  • Emit status changes (connecting, discovering_tools, online, offline, error)
  • Trigger tool metadata emission via UnifiedToolDiscoveryManager
Unified Tool Discovery Manager:
  • Emits mcp.tools.discovered after successful discovery
  • Coordinates status callbacks from discovery managers

Implementation Components

The event emission system consists of several integrated components:
  • Backend event handler system
  • Satellite status event emission
  • Server and request log batching
  • Tool metadata event emission
  • Stdio permanently_failed event
  • Tool execution failure status events