Skip to main content
Glama

review.fixIds.apply

Apply ID-fix plans to Re:VIEW manuscript files, creating backups while correcting duplicate and empty identifiers to maintain document integrity.

Instructions

Apply a previously calculated ID-fix plan; creates .bak backups.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYes
fixesYes

Implementation Reference

  • Core handler function that applies the provided fixes: groups by file, reads file content, replaces lines in reverse order to preserve positions, creates .bak backup, writes updated content, and returns count of applied fixes.
    async function applyFixes(cwd: string, fixes: any[]) {
      const byFile = new Map<string, any[]>();
      for (const f of fixes) {
        if (!byFile.has(f.file)) byFile.set(f.file, []);
        byFile.get(f.file)!.push(f);
      }
      let applied = 0;
      for (const [file, list] of byFile) {
        const full = path.join(cwd, file);
        const txt = await fs.readFile(full, "utf-8");
        const lines = txt.split(/\r?\n/);
        for (const f of list.sort((a,b)=>b.lineStart-a.lineStart)) {
          lines[f.lineStart-1] = f.after;
          applied++;
        }
        await fs.copyFile(full, full + ".bak");
        await fs.writeFile(full, lines.join("\n"), "utf-8");
      }
      return applied;
    }
  • Tool input schema definition specifying cwd (string) and fixes (array of objects), along with name and description for registration.
    name: "review.fixIds.apply",
    description: "Apply a previously calculated ID-fix plan; creates .bak backups.",
    inputSchema: {
      type: "object",
      properties: { cwd: { type: "string" }, fixes: { type: "array", items: { type: "object" } } },
      required: ["cwd","fixes"]
    }
  • Dispatch handler in CallToolRequestSchema switch that extracts arguments, calls applyFixes, and formats response as MCP text content.
    case "review.fixIds.apply": {
      const applied = await applyFixes(args.cwd as string, args.fixes as any[]);
      return {
        content: [
          { 
            type: "text", 
            text: JSON.stringify({ applied }) 
          }
        ]
      };
  • src/index.ts:425-428 (registration)
    Registers all tools including review.fixIds.apply by returning the tools array in ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: 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/dsgarage/ReviewMCP'

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