list_cached_repositories
Retrieve all GitHub repositories with documentation currently stored in cache for quick access to repository information through natural language queries.
Instructions
List all repositories currently cached
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:183-193 (handler)Handler for the 'list_cached_repositories' tool call. It invokes cacheManager.listRepositories() and returns the result as JSON-formatted text content.
case 'list_cached_repositories': { const repos = await cacheManager.listRepositories(); return { content: [ { type: 'text', text: JSON.stringify(repos, null, 2), }, ], }; } - src/server.ts:100-107 (registration)Registration of the 'list_cached_repositories' tool in the ListTools response, including name, description, and input schema.
{ name: 'list_cached_repositories', description: 'List all repositories currently cached', inputSchema: { type: 'object', properties: {}, }, }, - src/server.ts:103-106 (schema)Input schema for the 'list_cached_repositories' tool, which requires no parameters.
inputSchema: { type: 'object', properties: {}, }, - src/cache-manager.ts:142-194 (helper)Core implementation of listing cached repositories. Scans memory cache and disk cache files, filters by TTL, collects repo info, cleans expired entries, and sorts by lastUpdated.
async listRepositories(): Promise<Array<{ owner: string; repo: string; lastUpdated: Date; size: number }>> { const repositories: Array<{ owner: string; repo: string; lastUpdated: Date; size: number }> = []; // Check memory cache for (const [key, entry] of this.memoryCache.entries()) { if (Date.now() - entry.timestamp < entry.ttl) { const [owner, repo] = key.split('/'); if (owner && repo) { repositories.push({ owner, repo, lastUpdated: entry.docs.lastUpdated, size: entry.docs.metadata.size, }); } } } // Check disk cache try { const files = await fs.readdir(this.cacheDir); for (const file of files) { if (file.endsWith('.json')) { try { const filePath = path.join(this.cacheDir, file); const data = await fs.readFile(filePath, 'utf-8'); const entry: CacheEntry = JSON.parse(data); if (Date.now() - entry.timestamp < entry.ttl) { const [owner, repo] = file.replace('.json', '').split('_'); if (owner && repo) { repositories.push({ owner, repo, lastUpdated: entry.docs.lastUpdated, size: entry.docs.metadata.size, }); } } else { // Expired, remove it await fs.unlink(filePath).catch(() => {}); } } catch { // Skip corrupted cache files } } } } catch { // Cache directory doesn't exist or can't be read } return repositories.sort((a, b) => b.lastUpdated.getTime() - a.lastUpdated.getTime()); }