56 lines
1.7 KiB
Markdown
56 lines
1.7 KiB
Markdown
|
|
# Task ID: 50
|
||
|
|
|
||
|
|
**Title:** Implement progressive tool exposure for gated sessions
|
||
|
|
|
||
|
|
**Status:** done
|
||
|
|
|
||
|
|
**Dependencies:** 48 ✓, 49 ✓
|
||
|
|
|
||
|
|
**Priority:** high
|
||
|
|
|
||
|
|
**Description:** Modify tools/list behavior to only expose begin_session while gated, and expose all tools plus read_prompts after ungating.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
1. Update tools/list handling in `/src/mcplocal/src/router.ts`:
|
||
|
|
```typescript
|
||
|
|
async handleToolsList(sessionId: string): Promise<Tool[]> {
|
||
|
|
const state = this.getSessionState(sessionId);
|
||
|
|
|
||
|
|
if (state.gated) {
|
||
|
|
// Only show begin_session while gated
|
||
|
|
return [this.getBeginSessionTool()];
|
||
|
|
}
|
||
|
|
|
||
|
|
// After ungating: all upstream tools + read_prompts
|
||
|
|
const upstreamTools = await this.discoverTools();
|
||
|
|
return [...upstreamTools, this.getReadPromptsTool()];
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Block direct tool calls while gated:
|
||
|
|
```typescript
|
||
|
|
async handleToolCall(sessionId: string, toolName: string, args: any): Promise<any> {
|
||
|
|
const state = this.getSessionState(sessionId);
|
||
|
|
|
||
|
|
if (state.gated && toolName !== 'begin_session') {
|
||
|
|
// Intercept: extract keywords, match prompts, inject briefing
|
||
|
|
return this.handleInterceptedCall(sessionId, toolName, args);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Normal routing
|
||
|
|
return this.routeToolCall(toolName, args);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
3. Ensure notifications/tools/list_changed is sent after ungating
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
- Unit test: tools/list while gated returns only begin_session
|
||
|
|
- Unit test: tools/list after ungating returns all tools + read_prompts
|
||
|
|
- Unit test: begin_session not visible after ungating
|
||
|
|
- Unit test: Tool call while gated (not begin_session) triggers intercept
|
||
|
|
- Unit test: Tool call after ungating routes normally
|
||
|
|
- Unit test: notifications/tools/list_changed sent on ungate
|