read_conflict
Read the content of a conflicted Git file to identify merge conflicts and understand differences between versions for resolution.
Instructions
Read the content of a conflicted file by its ID. (Rate limit: 5 calls per minute). You must use list_conflicts to get the ID first.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the file to read (from list_conflicts). |
Implementation Reference
- src/tools/readConflict.ts:19-43 (handler)The core handler function executing the "read_conflict" tool logic: checks rate limit, retrieves conflicted files, finds file by ID, reads and returns its content.async ({ id }) => { if (!rateLimiter.check("read_conflict", 5, 60 * 1000)) { return { content: [{ type: "text", text: "Rate limit exceeded. Please wait." }], isError: true }; } try { const projectPath = state.getProjectPath(); if (!projectPath) { return { content: [{ type: "text", text: "Project not initialized. Run init_project first." }], isError: true }; } const files = await getConflictedFiles(); const file = files.find(f => generateId(f) === id); if (!file) { return { content: [{ type: "text", text: "Invalid ID (file not found)." }], isError: true }; } const fullPath = path.join(projectPath, file); const content = await fs.readFile(fullPath, "utf-8"); return { content: [{ type: "text", text: content }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], isError: true }; } }
- src/tools/readConflict.ts:15-17 (schema)Zod input schema defining the 'id' parameter for the "read_conflict" tool.inputSchema: z.object({ id: z.string().describe("The ID of the file to read (from list_conflicts)."), }),
- src/tools/readConflict.ts:10-45 (registration)The registration function that sets up the "read_conflict" tool on the MCP server, including name, description, schema, and handler.export function registerReadConflict(server: McpServer) { server.registerTool( "read_conflict", { description: "Read the content of a conflicted file by its ID. (Rate limit: 5 calls per minute). You must use list_conflicts to get the ID first.", inputSchema: z.object({ id: z.string().describe("The ID of the file to read (from list_conflicts)."), }), }, async ({ id }) => { if (!rateLimiter.check("read_conflict", 5, 60 * 1000)) { return { content: [{ type: "text", text: "Rate limit exceeded. Please wait." }], isError: true }; } try { const projectPath = state.getProjectPath(); if (!projectPath) { return { content: [{ type: "text", text: "Project not initialized. Run init_project first." }], isError: true }; } const files = await getConflictedFiles(); const file = files.find(f => generateId(f) === id); if (!file) { return { content: [{ type: "text", text: "Invalid ID (file not found)." }], isError: true }; } const fullPath = path.join(projectPath, file); const content = await fs.readFile(fullPath, "utf-8"); return { content: [{ type: "text", text: content }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], isError: true }; } } ); }
- src/tools/index.ts:19-19 (registration)Invocation of the read_conflict registration within the main tools registration function.registerReadConflict(server);