Skip to main content
Glama
transparentlyok

MCP Context Manager

index_repository

Index or re-index a repository to enable code navigation and retrieval tools. Uses cached index for unchanged files to reduce token usage when querying specific code symbols.

Instructions

🔧 REQUIRED FIRST STEP: Index or re-index the repository to enable all context-manager tools. Uses cached index if files haven't changed. ALWAYS call this when starting work on a repository or if files have changed significantly. Fast (<2s for most repos).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoPath to repository root. Default: process.cwd()
forceReindexNoForce re-indexing even if cache is available. Default: false

Implementation Reference

  • The handler for the index_repository tool which parses the arguments and calls the indexer.indexRepository method.
    case 'index_repository': {
      const path = (args as any).path || process.cwd();
      const forceReindex = (args as any).forceReindex || false;
      await indexer.indexRepository(path, forceReindex);
      return {
        content: [
          {
            type: 'text',
            text: `Repository indexed successfully.\nFiles: ${indexer.getStats().totalFiles}\nSymbols: ${indexer.getStats().totalSymbols}`,
          },
        ],
      };
  • src/index.ts:126-142 (registration)
    The definition of the index_repository tool in the tools array.
    {
      name: 'index_repository',
      description: '🔧 REQUIRED FIRST STEP: Index or re-index the repository to enable all context-manager tools. Uses cached index if files haven\'t changed. ALWAYS call this when starting work on a repository or if files have changed significantly. Fast (<2s for most repos).',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to repository root. Default: process.cwd()',
          },
          forceReindex: {
            type: 'boolean',
            description: 'Force re-indexing even if cache is available. Default: false',
          },
        },
      },
    },
  • The implementation of indexRepository in the Indexer class, which handles the actual indexing logic.
    async indexRepository(rootPath: string, forceReindex: boolean = false): Promise<void> {
      this.rootPath = rootPath;
    
      // Try to load from cache if not forcing re-index
      if (!forceReindex) {
        const loaded = await this.loadFromCache(rootPath);
        if (loaded) {
          console.error(`Loaded from cache: ${this.index.size} files with ${this.getTotalSymbols()} symbols`);
          return;
        }
      }
    
      // Clear existing index
      this.index.clear();
      this.symbolMap.clear();
    
      // Load ignore patterns
      await this.loadIgnorePatterns();
    
      // Index all files
      await this.indexDirectory(rootPath);
    
      console.error(`Indexed ${this.index.size} files with ${this.getTotalSymbols()} symbols`);
    
      // Save to cache
      await this.saveToCache(rootPath);
    }
    
    private async loadIgnorePatterns(): Promise<void> {
      const gitignorePath = path.join(this.rootPath, '.gitignore');
    
      // Default patterns
      this.ignorePatterns = [
        'node_modules',
        '.git',
        'dist',
        'build',
        'coverage',
        '.next',
        '.nuxt',
        'out',
        '.cache',
        '*.min.js',
        '*.map',
        'package-lock.json',
        'yarn.lock',
        'pnpm-lock.yaml',
      ];
    
      try {
        const gitignore = await fs.readFile(gitignorePath, 'utf-8');
        const lines = gitignore
          .split('\n')
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a required first step for enabling other tools, uses caching for efficiency, is fast (<2s for most repos), and can be forced to re-index. It doesn't cover error conditions or permissions, but for a tool with no annotations, this is strong coverage of operational behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and front-loaded, with every sentence earning its place: it states the purpose, caching behavior, usage guidelines, and performance. No wasted words, and the emoji adds visual emphasis without distraction.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a prerequisite indexing operation with caching), no annotations, and no output schema, the description does well by covering purpose, usage, caching, and performance. It could mention error handling or output format, but for a tool with 100% schema coverage and clear behavioral context, it's largely complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description doesn't add any parameter-specific details beyond what the schema provides (e.g., it doesn't explain 'path' or 'forceReindex' further). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('index or re-index'), the target resource ('the repository'), and the purpose ('to enable all context-manager tools'). It distinguishes this tool from siblings by emphasizing it as a required first step for repository work, unlike other tools that perform specific queries or analyses.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'when starting work on a repository or if files have changed significantly.' It also specifies when not to use it by noting it 'uses cached index if files haven't changed,' implying it's unnecessary without changes. While it doesn't name specific alternatives, it positions this as a prerequisite for other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/transparentlyok/mcp-context-manager'

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