---
title: "Patch one file by replacing exact text"
method: POST
path: "/api/mcp/tools/patch_app_file"
tags: ["tools"]
---

# Patch one file by replacing exact text

`POST /api/mcp/tools/patch_app_file`

## Request

- Base URL: `https://finestructure.ai`
- URL: `https://finestructure.ai/api/mcp/tools/patch_app_file`
- Auth: HTTP bearer

Patch one file by replacing exact text. Safer than full overwrite for targeted edits. Creates a Saved Version before changing content. Paths follow the Fine Structure app file API, documented at https://finestructure.ai/api/mcp/docs.

## Request body

- object
  - `app_id` string, required: The app ID
  - `path` string, required: Virtual file path
  - `old_text` string, required: Exact existing text to replace
  - `new_text` string, required: Replacement text
  - `replace_all` boolean: Replace all matches instead of the first match

## Response `200`

Tool executed successfully

- ToolResult
  - `ok` boolean, required
  - `tool` string, required
  - `result` object, required

## Other responses

- `400`: Invalid arguments for this tool
- `401`: Missing or invalid bearer token
- `402`: Not enough credits on the account
- `403`: Token scope does not permit this tool
- `404`: Unknown tool name
- `429`: Rate limit exceeded, retry after the indicated delay
- `500`: Internal error while executing the tool

---

[API](https://skmtc.dev/finestructure/apis/fine-structure-api.md) · [All operations](https://skmtc.dev/finestructure/apis/fine-structure-api/llms.txt) · [OpenAPI document](https://skmtc.dev/finestructure/apis/fine-structure-api/revisions/02c50ed5fd70?raw)
