48 lines
1.4 KiB
Markdown
48 lines
1.4 KiB
Markdown
|
|
# Task ID: 84
|
||
|
|
|
||
|
|
**Title:** Implement Section Drill-Down for Tool Results
|
||
|
|
|
||
|
|
**Status:** done
|
||
|
|
|
||
|
|
**Dependencies:** 82 ✓
|
||
|
|
|
||
|
|
**Priority:** medium
|
||
|
|
|
||
|
|
**Description:** Extend tool result handling to support _section parameter for drilling into specific sections of large tool responses.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
Modify tool call handling in `src/mcplocal/src/router.ts`:
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
// When processing tool calls
|
||
|
|
if (args._section) {
|
||
|
|
const sectionId = args._section;
|
||
|
|
delete args._section; // Don't pass to upstream
|
||
|
|
|
||
|
|
// Check cache for previous full result
|
||
|
|
const cacheKey = `tool:${serverName}/${toolName}:${JSON.stringify(args)}`;
|
||
|
|
const cachedResult = this.toolResultCache.get(cacheKey);
|
||
|
|
|
||
|
|
if (cachedResult?.sections) {
|
||
|
|
const section = findSection(cachedResult.sections, sectionId);
|
||
|
|
if (section) {
|
||
|
|
return { content: [{ type: 'text', text: section.content }] };
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// If no cache, make the full call and process, then serve section
|
||
|
|
}
|
||
|
|
|
||
|
|
// After receiving tool result, process through pipeline
|
||
|
|
const processed = await this.processContent(result, 'toolResult', `${serverName}/${toolName}`, sessionId);
|
||
|
|
if (processed.sections) {
|
||
|
|
this.toolResultCache.set(cacheKey, processed);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
Add a toolResultCache Map with appropriate TTL.
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
Integration tests: large tool result gets processed into sections, _section parameter returns specific section, _section removed before upstream call, cache hit serves from cache, cache miss processes and caches.
|