---
title: "Compute a stateless 3-way merge for a vault file. Server runs `git merge-file --diff3 --stdout` over (base_text, local_text, current remote from file_indices) and returns the merged text plus the exact remote_sha it merged against. NO database mutation — to commit the result, follow up with sync_push(content=merged_text, base_sha=merged_against.remote_sha, resolves_conflict_id=conflict_id)."
method: POST
path: "/api/mcp/tools/sync_merge"
tags: ["sync"]
---

# Compute a stateless 3-way merge for a vault file. Server runs \`git merge-file --diff3 --stdout\` over (base_text, local_text, current remote from file_indices) and returns the merged text plus the exact remote_sha it merged against. NO database mutation — to commit the result, follow up with sync_push(content=merged_text, base_sha=merged_against.remote_sha, resolves_conflict_id=conflict_id).

`POST /api/mcp/tools/sync_merge`

## Request

- Base URL: `https://api.ainote.dev`
- URL: `https://api.ainote.dev/api/mcp/tools/sync_merge`
- Auth: API key in header `Authorization`

Compute a stateless 3-way merge for a vault file. Server runs `git merge-file --diff3 --stdout` over (base_text, local_text, current remote from file_indices) and returns the merged text plus the exact remote_sha it merged against. NO database mutation — to commit the result, follow up with sync_push(content=merged_text, base_sha=merged_against.remote_sha, resolves_conflict_id=conflict_id).

## Request body

- object
  - `path` string, required: Relative vault path (e.g., 'global/MEMORY.md').
  - `base_text` string, required: Common ancestor text — what the client had cached when it started editing. Source: client state.json baseline. Required.
  - `base_sha` string: Optional: git_sha the client believes is the merge base. When supplied, server verifies (informational; merge still runs).
  - `local_text` string, required: Current local text on the client (post-edit). Required.
  - `device_id` string: Optional: client device identifier. Recorded on any vault_conflict row created downstream.

## Response `200`

Tool executed successfully

- ToolSuccessResponse: Successful tool invocation. `content` mirrors the MCP `tools/call` result shape: an array of content blocks (text and optionally a structured resource payload).
  - `content` object[]
    - `type` 'text' | 'resource'
    - `text` string

## Other responses

- `400`: Invalid arguments or business-rule violation
- `401`: Missing or invalid McpKey

---

[API](https://skmtc.dev/ainote/apis/ainote-mcp-openapi-mirror.md) · [All operations](https://skmtc.dev/ainote/apis/ainote-mcp-openapi-mirror/llms.txt) · [OpenAPI document](https://skmtc.dev/ainote/apis/ainote-mcp-openapi-mirror/revisions/f6c91d85e027?raw)
