Skip to content

Commit afa4af4

Browse files
committed
Enhance per-user instance management and status tracking in DeployStack Satellite
- Updated hierarchical router documentation to clarify user-specific process routing and tool filtering. - Revised process management documentation to reflect per-user subprocess management and independent lifecycle. - Enhanced status tracking documentation to emphasize per-user instance status and filtering logic. - Introduced new instance lifecycle management documentation detailing creation, deletion, and team membership changes. - Improved team isolation documentation to highlight per-user access control and instance separation. - Updated tool discovery documentation to clarify per-user status integration and request logging settings.
1 parent 02a0394 commit afa4af4

13 files changed

+921
-365
lines changed

development/backend/mcp-configuration-architecture.mdx

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -82,88 +82,42 @@ The three-tier system addresses this by:
8282

8383
## Database Schema
8484

85+
The three-tier configuration system uses three main tables:
86+
8587
### Tier 1: MCP Catalog (`mcpServers`)
8688

87-
The catalog defines the configuration structure for each MCP server type:
88-
89-
**Core Configuration Fields:**
90-
```sql
91-
-- Template Level (with lock controls)
92-
template_args: text('template_args') -- [{value, locked, description}]
93-
template_env: text('template_env') -- Fixed environment variables
94-
template_headers: text('template_headers') -- Fixed HTTP headers (for HTTP/SSE)
95-
template_url_query_params: text('template_url_query_params') -- Fixed URL query params (for HTTP/SSE)
96-
97-
-- Team Schema (with lock/visibility controls)
98-
team_args_schema: text('team_args_schema') -- Schema with lock controls
99-
team_env_schema: text('team_env_schema') -- [{name, type, required, default_team_locked, visible_to_users}]
100-
team_headers_schema: text('team_headers_schema') -- HTTP headers schema (for HTTP/SSE)
101-
team_url_query_params_schema: text('team_url_query_params_schema') -- URL query params schema (for HTTP/SSE)
102-
103-
-- User Schema
104-
user_args_schema: text('user_args_schema') -- User-configurable argument schema
105-
user_env_schema: text('user_env_schema') -- User-configurable environment schema
106-
user_headers_schema: text('user_headers_schema') -- User HTTP headers schema (for HTTP/SSE)
107-
user_url_query_params_schema: text('user_url_query_params_schema') -- User URL query params schema (for HTTP/SSE)
108-
```
89+
Defines configuration structure for each MCP server type including template-level config, team/user schemas, transport configuration, and registry tracking.
10990

110-
**Transport Configuration:**
111-
```sql
112-
transport_type: text('transport_type') -- 'stdio' | 'http' | 'sse'
113-
packages: text('packages') -- JSON: npm/pip/docker packages (stdio)
114-
remotes: text('remotes') -- JSON: HTTP/SSE endpoints
115-
```
91+
### Tier 2: Team Installation (`mcpServerInstallations`)
11692

117-
**Official Registry Tracking Fields:**
118-
```sql
119-
official_name: text('official_name') -- Reverse-DNS name from registry
120-
synced_from_official_registry: boolean -- True if synced from registry
121-
official_registry_server_id: text -- Registry's server identifier
122-
official_registry_version_id: text -- Registry's version identifier
123-
official_registry_published_at: timestamp -- Original publication date
124-
official_registry_updated_at: timestamp -- Last update in registry
125-
```
93+
Manages shared team configurations including installation name, team args, environment variables, headers, and URL query params.
12694

127-
**GitHub Enhancement Fields:**
128-
```sql
129-
repository_source: text -- 'github' | 'gitlab' | 'bitbucket'
130-
repository_id: text -- Platform-specific repo ID
131-
repository_subfolder: text -- Monorepo subfolder path
132-
github_account_id: text -- For avatar URLs
133-
github_readme_base64: text -- Cached README content
134-
github_stars: integer -- Star count for social proof
135-
```
95+
### Per-User Instances (`mcpServerInstances`)
13696

137-
### Tier 2: Team Installation (`mcpServerInstallations`)
97+
While not strictly a "configuration tier", the instance table enables per-user isolation:
13898

139-
Team installations manage shared configurations:
99+
**Key Characteristics**:
100+
- One instance per user per installation (UNIQUE constraint)
101+
- Independent status tracking per user
102+
- CASCADE deletes when installation removed
103+
- Enables parallel status states (User A online, User B offline)
140104

141-
```sql
142-
installation_name: text('installation_name') -- Team-friendly name
143-
team_args: text('team_args') -- Team-level arguments (JSON array)
144-
team_env: text('team_env') -- Team environment variables (JSON object)
145-
team_headers: text('team_headers') -- Team HTTP headers (JSON object, for HTTP/SSE)
146-
team_url_query_params: text('team_url_query_params') -- Team URL query params (JSON object, for HTTP/SSE)
147-
```
105+
For complete database schema, see [Database Schema](/development/backend/database/).
148106

149-
### Tier 3: User Configuration (`mcpUserConfigurations`)
107+
For complete instance lifecycle, see [Instance Lifecycle](/development/satellite/instance-lifecycle).
150108

151-
Individual user configurations:
109+
### Tier 3: User Configuration (`mcpUserConfigurations`)
152110

153-
```sql
154-
installation_id: text('installation_id') -- References team installation
155-
user_id: text('user_id') -- User who owns this config
111+
Stores individual user configurations including personal args, environment variables, headers, and URL query params.
156112

157-
user_args: text('user_args') -- User arguments (JSON array)
158-
user_env: text('user_env') -- User environment variables (JSON object)
159-
user_headers: text('user_headers') -- User HTTP headers (JSON object, for HTTP/SSE)
160-
user_url_query_params: text('user_url_query_params') -- User URL query params (JSON object, for HTTP/SSE)
161-
```
113+
**For complete database schema details, see [Database Schema](/development/backend/database/).**
162114

163115
## Configuration Flow
164116

165117
### Runtime Assembly
166118

119+
**Per-User Instance Isolation**: Configurations are assembled **per user** at runtime. Each team member's instance receives their merged config (template + team + user).
120+
167121
### Configuration Schema Step
168122

169123
Global administrators categorize configuration elements through the Configuration Schema Step:

development/backend/mcp-server-oauth.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ if (provider) {
376376
status_message: 'Authenticated successfully, waiting for satellite to connect'
377377
});
378378
```
379+
380+
**Per-User Instance Creation**: OAuth callback creates the user's instance with status='connecting'. For multi-user teams:
381+
- Installing user's instance created with their OAuth credentials
382+
- Other team members' instances created with status='awaiting_user_config' (they must authenticate separately)
383+
- Each user authenticates independently with their own OAuth account
384+
385+
For instance lifecycle details, see [Instance Lifecycle](/development/satellite/instance-lifecycle).
379386
</Step>
380387

381388
<Step title="Encrypt and Store Tokens">
@@ -825,6 +832,8 @@ CREATE TABLE mcpOauthTokens (
825832
})
826833
.where(eq(mcpServerInstallations.id, installation.id));
827834
```
835+
836+
**Per-User Instance Impact**: Token refresh failures only affect the specific user's instance. Other team members' instances remain unaffected even if one user's OAuth token expires.
828837
</Step>
829838
</Steps>
830839

development/backend/satellite/commands.mdx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,28 @@ interface CommandPayload {
7676

7777
## Status Changes Triggered by Commands
7878

79-
Commands trigger installation status changes through satellite event emission:
79+
Commands trigger **per-user instance** status changes through satellite event emission:
8080

81-
| Command | Status Before | Status After | When |
82-
|---------|--------------|--------------|------|
83-
| `configure` (install) | N/A | `provisioning` `command_received``connecting` | Installation creation flow |
81+
| Command | Instance Status Before | Instance Status After | When |
82+
|---------|----------------------|---------------------|------|
83+
| `configure` (install) | N/A | `provisioning` or `awaiting_user_config` | New installation - depends on required user config |
8484
| `configure` (update) | `online` | `restarting``online` | Configuration change applied |
85-
| `configure` (delete) | Any | Process terminated | Installation removal |
86-
| `health_check` (credential) | `online` | `requires_reauth` | OAuth token invalid |
85+
| `configure` (delete) | Any | Instance deleted (CASCADE) | Installation removal |
86+
| `health_check` (credential) | `online` | `requires_reauth` | OAuth token invalid for this user |
8787
| `restart` | `online` | `restarting``online` | Manual restart requested |
8888

89-
**Status Lifecycle on Installation**:
90-
1. Backend creates installation → status=`provisioning`
91-
2. Backend sends `configure` command → status=`command_received`
92-
3. Satellite connects to server → status=`connecting`
93-
4. Satellite discovers tools → status=`discovering_tools`
94-
5. Satellite syncs tools to backend → status=`syncing_tools`
95-
6. Process complete → status=`online`
89+
**Per-User Status Tracking**: Each team member's instance has independent status. User A's config change only affects User A's instance status.
90+
91+
**Status Lifecycle on Installation** (per user):
92+
1. Backend creates installation → creates instances for all team members
93+
2. If user has required config → status=`provisioning`
94+
3. If user missing required config → status=`awaiting_user_config` (not sent to satellite)
95+
4. User configures settings → status changes to `provisioning` → satellite spawns
96+
5. Satellite connects → status=`connecting`
97+
6. Satellite discovers tools → status=`discovering_tools`
98+
7. Process complete → status=`online`
99+
100+
For complete instance lifecycle documentation, see [Instance Lifecycle](/development/satellite/instance-lifecycle).
96101

97102
For complete status transition documentation, see [Backend Events - Status Values](/development/backend/satellite/events#mcp-server-status_changed).
98103

@@ -118,6 +123,11 @@ All `configure` commands include an `event` field in the payload for tracking an
118123
3. Identifies added/removed/modified servers
119124
4. Takes appropriate action
120125

126+
**Per-User Instance Impact**: Configure commands trigger per-user instance creation/updates:
127+
- Installation created → All team members get instances (status depends on required user config)
128+
- Installation updated → Only affects users with existing configs (others remain `awaiting_user_config`)
129+
- Installation deleted → CASCADE deletes all user instances
130+
121131
**Purpose of Event Field**:
122132
- Database record keeping
123133
- Structured logging

development/backend/satellite/communication.mdx

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ The satellite communication system includes:
2525

2626
**Team-Aware Configuration Distribution**:
2727
- Global satellites receive ALL team MCP server installations
28-
- Each team installation becomes a separate process with unique identifier
29-
- Process ID format: `{server_slug}-{team_slug}-{installation_id}`
30-
- Team-specific configurations (args, environment, headers) merged per installation
28+
- Each team installation becomes separate per-user processes with unique identifiers
29+
- Process ID format: `{server_slug}-{team_slug}-{user_slug}-{installation_id}`
30+
- User-specific configurations (args, environment, headers) merged per user instance
3131

3232
**Configuration Merging Process**:
3333
1. Template-level configuration (from MCP server definition)
@@ -268,7 +268,9 @@ The backend provides REST and SSE endpoints for frontend access to installation
268268
### Status & Monitoring Endpoints
269269

270270
**GET `/api/teams/{teamId}/mcp/installations/{installationId}/status`**
271-
- Returns current installation status, status message, and last update timestamp
271+
- Returns authenticated user's instance status only (not installation-level)
272+
- Each user sees ONLY their own instance status, not other team members' statuses
273+
- Response: `{ status, status_message, status_updated_at, last_health_check_at }`
272274
- Used by frontend for real-time status badges and progress indicators
273275

274276
**GET `/api/teams/{teamId}/mcp/installations/{installationId}/logs`**
@@ -445,36 +447,21 @@ The satellite system integrates with existing DeployStack schema through 5 speci
445447
- Alert generation and notification triggers
446448
- Historical health trend analysis
447449

448-
### New Columns Added (Status & Health Tracking System)
449-
450-
**mcpServerInstallations** table:
451-
- `status` (text) - Current installation status (11 possible values)
452-
- `status_message` (text, nullable) - Human-readable status context or error details
453-
- `status_updated_at` (timestamp) - Last status change timestamp
454-
- `last_health_check_at` (timestamp, nullable) - Last health check execution time
455-
- `last_credential_check_at` (timestamp, nullable) - Last credential validation time
456-
- `settings` (jsonb, nullable) - Generic settings object (e.g., `request_logging_enabled`)
457-
458-
**mcpServers** table:
459-
- `health_status` (text, nullable) - Template-level aggregated health status
460-
- `last_health_check_at` (timestamp, nullable) - Last template health check time
461-
- `health_check_error` (text, nullable) - Last health check error message
462-
463-
**mcpServerLogs** table:
464-
- Stores batched stderr logs from satellites
465-
- 100-line limit per installation (enforced by cleanup cron job)
466-
- Fields: `installation_id`, `team_id`, `log_level`, `message`, `timestamp`
467-
468-
**mcpRequestLogs** table:
469-
- Stores batched tool execution logs
470-
- `tool_response` (jsonb, nullable) - MCP server response data
471-
- Privacy control: Only captured when `request_logging_enabled=true`
472-
- Fields: `installation_id`, `team_id`, `tool_name`, `request_params`, `tool_response`, `duration_ms`, `success`, `error_message`, `timestamp`
473-
474-
**mcpToolMetadata** table:
475-
- Stores discovered tools with token counts
476-
- Used for hierarchical router token savings calculations
477-
- Fields: `installation_id`, `server_slug`, `tool_name`, `description`, `input_schema`, `token_count`, `discovered_at`
450+
### Database Integration
451+
452+
**Per-User Instance Model**: Each team member gets their own instance with independent status tracking. Status exists ONLY at the instance level in `mcpServerInstances` table.
453+
454+
**Key Tables**:
455+
- `mcpServerInstances` - Per-user instance status tracking
456+
- `satellites` - Satellite registry
457+
- `satelliteCommands` - Command queue
458+
- `satelliteProcesses` - Process tracking
459+
- `satelliteUsageLogs` - Usage analytics
460+
- `satelliteHeartbeats` - Health monitoring
461+
462+
For complete database schema details, see [Database Schema](/development/backend/database/).
463+
464+
For complete instance lifecycle documentation, see [Instance Lifecycle](/development/satellite/instance-lifecycle).
478465

479466
### Team Isolation in Data Model
480467

@@ -602,15 +589,11 @@ server.get('/satellites/:satelliteId/commands', {
602589

603590
### Database Integration
604591

605-
The satellite system extends the existing database schema with 5 specialized tables:
592+
The satellite system uses specialized tables for registry, commands, processes, usage logs, and heartbeats.
606593

607-
**Schema Location**: `services/backend/src/db/schema.ts`
594+
**Per-User Instance Model**: `mcpServerInstances` table tracks status for each user's instance independently, with CASCADE delete when installation is removed.
608595

609-
**Table Relationships**:
610-
- `satellites` table links to existing `teams` and `authUser` tables
611-
- `satelliteProcesses` table references `mcpServerInstallations` for team context
612-
- `satelliteCommands` table includes team context for command execution
613-
- All tables use existing foreign key relationships for data integrity
596+
For complete database schema and relationships, see [Database Schema](/development/backend/database/).
614597

615598
### Configuration Query Implementation
616599

0 commit comments

Comments
 (0)