Skip to main content
Glama

mine_changed_files

Re-index files modified after the last commit to keep the codebase search index current. Call after making code changes.

Instructions

Re-index files changed since last commit into MemPalace. Call after making code changes to keep the search index current.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The mineChangedFiles function that executes the core logic: gets committed and working-tree changed files via GitAccess, deduplicates, filters mineable paths via FileFilterEngine, and mines each file individually via MemPalaceAccess.mineFile.
    async function mineChangedFiles(
      repoDir: string,
    ): Promise<{ mined: string[]; skipped: string[] }> {
      // Combine committed changes (HEAD~1..HEAD) and uncommitted working-tree changes,
      // deduplicating by path so each file is only mined once.
      const [committedFiles, workingTreeFiles, gitRoot] = await Promise.all([
        git.getChangedFiles(repoDir),
        git.getWorkingTreeFiles(repoDir),
        git.getGitRoot(repoDir),
      ]);
      const seen = new Set<string>();
      const merged = [...committedFiles, ...workingTreeFiles].filter(({ path }) => {
        if (seen.has(path)) return false;
        seen.add(path);
        return true;
      });
      // git returns paths relative to the git toplevel (where .git lives), which may differ
      // from repoDir — use gitRoot to construct correct absolute paths.
      const allPaths = merged.map((f) => `${gitRoot}/${f.path}`);
      const mineable = fileFilter.filterPaths(allPaths);
      const skipped = allPaths.filter((p) => !mineable.includes(p));
    
      if (mineable.length > 0) {
        // Mine each changed file individually so we get targeted re-indexing
        for (const path of mineable) {
          await memPalace.mineFile(path, palaceWing);
        }
      }
    
      return { mined: mineable, skipped };
    }
  • Zod schema for mine_changed_files (empty object, no inputs needed).
    export const MineChangedFilesSchema = z.object({});
  • Registers the 'mine_changed_files' tool on the MCP server with its schema and handler that calls manager.mineChangedFiles(repoDir).
    server.tool('mine_changed_files', 'Re-index files changed since last commit into MemPalace. Call after making code changes to keep the search index current.', MineChangedFilesSchema.shape, async () => {
      const result = await manager.mineChangedFiles(repoDir);
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify({ mined: result.mined, skipped: result.skipped }),
          },
        ],
      };
    });
  • GitAccess.getGitRoot returns the git top-level directory via 'git rev-parse --show-toplevel'.
    async function getGitRoot(repoDir: string): Promise<string> {
      const { stdout } = await execFileAsync('git', ['-C', repoDir, 'rev-parse', '--show-toplevel']);
      return stdout.trim();
    }
  • GitAccess.getChangedFiles returns files changed between HEAD~1 and HEAD via 'git diff --name-status'.
    async function getChangedFiles(repoDir: string, base?: string): Promise<ChangedFile[]> {
      const ref = base ?? 'HEAD~1';
      const { stdout } = await execFileAsync('git', [
        '-C',
        repoDir,
        'diff',
        '--name-status',
        ref,
        'HEAD',
      ]);
    
      return stdout
        .trim()
        .split('\n')
        .filter(Boolean)
        .map((line) => {
          const [rawStatus, ...parts] = line.split('\t');
          const path = parts[parts.length - 1] ?? '';
          const statusChar = (rawStatus ?? '')[0] ?? 'M';
          const statusMap: Record<string, ChangedFile['status']> = {
            A: 'added',
            M: 'modified',
            D: 'deleted',
            R: 'renamed',
          };
          return {
            path,
            status: statusMap[statusChar] ?? 'modified',
          };
        });
    }
Behavior3/5

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

With no annotations, the description carries the burden of disclosing behavior. It describes the re-indexing action but provides no additional context about side effects, performance impact, or safety. It is minimally adequate.

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 a single, well-structured sentence that gets straight to the point without any fluff. Every word is necessary.

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

Completeness3/5

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

Given the tool has no parameters or output schema, the description covers the essentials but lacks details about prerequisites (e.g., git repository) or consequences. It is adequate but not comprehensive.

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

Parameters4/5

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

The tool has no parameters and the input schema coverage is 100% (empty). The description adds no parameter information, but none is needed. Baseline for zero parameters is 4.

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

Purpose4/5

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

The description clearly states the tool re-indexes files changed since the last commit into MemPalace, using a specific verb and resource. It does not explicitly distinguish from siblings like get_changed_files or update_track_index, but the action is distinct enough.

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

Usage Guidelines4/5

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

The description explicitly says to call it after making code changes to keep the search index current, providing clear context for use. However, it does not mention when not to use it or alternative 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/2loch-ness6/mempalace-mcp-dev'

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