Skip to main content
Glama
mattyatea

Git Conflict MCP

by mattyatea

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
NameRequiredDescriptionDefault
idYesThe ID of the file to read (from list_conflicts).

Implementation Reference

  • 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 };
        }
    }
  • 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)."),
    }),
  • 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 };
                }
            }
        );
    }
  • Invocation of the read_conflict registration within the main tools registration function.
    registerReadConflict(server);

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/mattyatea/git-conflict-mcp'

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