Skip to main content
Glama

clear_cache

Remove cached documentation from the CodeWiki MCP Server to refresh repository information and ensure up-to-date content access.

Instructions

Clear the documentation cache

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoSpecific repository to clear (optional)
repoNoRepository name when clearing specific repo

Implementation Reference

  • src/server.ts:108-124 (registration)
    Registration of the 'clear_cache' tool in the listTools handler, including its input schema.
    {
      name: 'clear_cache',
      description: 'Clear the documentation cache',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
            description: 'Specific repository to clear (optional)',
          },
          repo: {
            type: 'string',
            description: 'Repository name when clearing specific repo',
          },
        },
      },
    },
  • The MCP tool handler for 'clear_cache' that conditionally clears a specific repository cache or all caches via CacheManager.
    case 'clear_cache': {
      const { owner, repo } = args as any;
      if (owner && repo) {
        await cacheManager.clearRepository(owner, repo);
        return {
          content: [
            {
              type: 'text',
              text: `Cleared cache for ${owner}/${repo}`,
            },
          ],
        };
      } else {
        await cacheManager.clearAll();
        return {
          content: [
            {
              type: 'text',
              text: 'Cleared all cached documentation',
            },
          ],
        };
      }
    }
  • Helper method to clear a specific repository's cache from both memory and disk.
    async clearRepository(owner: string, repo: string): Promise<void> {
      const key = this.getCacheKey(owner, repo);
      
      // Remove from memory cache
      this.memoryCache.delete(key);
    
      // Remove from disk cache
      try {
        const filePath = this.getCacheFilePath(owner, repo);
        await fs.unlink(filePath);
      } catch {
        // File doesn't exist or can't be deleted
      }
    }
  • Helper method to clear all cached repositories from both memory and disk storage.
    async clearAll(): Promise<void> {
      // Clear memory cache
      this.memoryCache.clear();
    
      // Clear disk cache
      try {
        const files = await fs.readdir(this.cacheDir);
        await Promise.all(
          files.map(file => 
            fs.unlink(path.join(this.cacheDir, file)).catch(() => {})
          )
        );
      } catch {
        // Cache directory doesn't exist or can't be read
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cbuntingde/codewiki-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server