You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Naming Convention**: All event data fields use **snake_case** (e.g., `server_id`, `team_id`, `spawn_duration_ms`) to match the backend API convention.
66
66
</Note>
67
67
68
-
The satellite emits 12 event types across 4 categories:
68
+
The satellite emits 13 event types across 4 categories:
69
69
70
70
### MCP Server Lifecycle
71
71
@@ -226,21 +226,40 @@ Emitted when SSE connection closes (client disconnect, timeout, or error).
226
226
### Tool Discovery
227
227
228
228
#### `mcp.tools.discovered`
229
-
Emitted after successful tool discovery from HTTP or stdio MCP server.
229
+
Emitted after successful tool discovery from HTTP or stdio MCP server with complete tool metadata and token consumption.
230
230
231
231
**Data Structure:**
232
232
```typescript
233
233
{
234
-
server_id: string;
235
-
server_slug: string;
234
+
installation_id: string;
235
+
installation_name: string;
236
236
team_id: string;
237
-
tool_count: number;
238
-
tool_names: string[];
239
-
discovery_duration_ms: number;
240
-
previous_tool_count: number;
237
+
server_slug: string;
238
+
tool_count: number; // Total tools discovered
239
+
total_tokens: number; // Sum of all tool token counts
240
+
tools: Array<{
241
+
tool_name:string;
242
+
description:string;
243
+
input_schema:Record<string, unknown>;
244
+
token_count:number; // Tokens for this specific tool
245
+
}>;
246
+
discovered_at: string; // ISO 8601 timestamp
241
247
}
242
248
```
243
249
250
+
**Purpose:**
251
+
- Store tool metadata in backend database (`mcpToolMetadata` table)
252
+
- Calculate hierarchical router token savings (traditional vs 2-meta-tool approach)
253
+
- Enable frontend tool catalog display with token consumption metrics
254
+
- Provide analytics on MCP server complexity and context window usage
255
+
256
+
**Emission Timing:**
257
+
- stdio servers: After handshake completion and tool caching
258
+
- HTTP/SSE servers: After startup tool discovery and caching
259
+
260
+
**Token Calculation:**
261
+
Uses `token-counter.ts` utility to estimate tokens for each tool based on name, description, and input schema JSON.
262
+
244
263
#### `mcp.tools.updated`
245
264
Emitted when tool list changes during configuration refresh.
Copy file name to clipboardExpand all lines: development/satellite/tool-discovery.mdx
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -231,6 +231,58 @@ stdio tools persist in cache for optimal performance:
231
231
**Idle Process Management**: stdio processes that remain inactive for the configured idle timeout (default: 3 minutes) are automatically terminated to save memory. However, **tools remain cached** so when a client requests them, the process respawns instantly without needing to rediscover tools. This reduces respawn time from 1-3 seconds to 1-2 seconds. See [Idle Process Management](/development/satellite/idle-process-management) for details.
232
232
</Info>
233
233
234
+
## Tool Metadata Collection
235
+
236
+
After tool discovery completes, the satellite emits tool metadata to the backend for storage and analysis.
237
+
238
+
### Event Emission (Post-Discovery)
239
+
240
+
Following successful tool discovery (both HTTP/SSE and stdio), the satellite:
241
+
242
+
1.**Calculates token consumption** using the `token-counter.ts` utility
243
+
2.**Builds event payload** with tool metadata including per-tool token counts
244
+
3.**Emits `mcp.tools.discovered` event** to backend via EventBus
245
+
4.**Backend stores metadata** in `mcpToolMetadata` table for team visibility
246
+
247
+
**Event Payload Structure:**
248
+
```typescript
249
+
{
250
+
installation_id: string;
251
+
installation_name: string;
252
+
team_id: string;
253
+
server_slug: string;
254
+
tool_count: number; // Total tools discovered
255
+
total_tokens: number; // Sum of all tool token counts
256
+
tools: Array<{
257
+
tool_name:string;
258
+
description:string;
259
+
input_schema:Record<string, unknown>;
260
+
token_count:number; // Tokens for this specific tool
261
+
}>;
262
+
discovered_at: string; // ISO 8601 timestamp
263
+
}
264
+
```
265
+
266
+
**Integration Points:**
267
+
-`StdioToolDiscoveryManager`: Emits after stdio tool discovery completes
268
+
-`RemoteToolDiscoveryManager`: Emits after HTTP/SSE tool discovery completes
269
+
-`EventBus`: Batches events every 3 seconds for efficient transmission
270
+
- Backend handler: Stores tools with delete-then-insert strategy
271
+
272
+
**Token Calculation:**
273
+
The satellite uses `estimateMcpServerTokens()` from `token-counter.ts` to calculate:
0 commit comments