# Edit documents from your backend

> **Note**
>
> This scenario defines the MCP server in the deployment configuration, so it runs on-premises. See [On-Premises](on-premises.md). On SaaS, register the server through the [admin API](extensions/mcp-tools.md) instead.
>
> This page shows one way to set this up. The extensions it uses fit this scenario, and other combinations work too. See [Ways to use it](overview.md#ways-to-use-it) and [Choose an extension](extensions/overview.md) for the full list.

A company prepares regulatory filings that must follow its style guide: how it introduces defined terms, how it formats amounts, and how it writes cross-references. The company already runs automated checks for those rules. It wants a backend job that restyles each filing to the guide and verifies the edited filing with those checks before a reviewer opens it.

You expose those checks as tools on an [MCP server](extensions/mcp-tools.md), and the job sends each filing to [Document Processing](document-processing.md). The agent calls your checks while it edits the filing.

<a id="how-the-document-is-processed">

## How the document is processed

The job sends a filing to `POST /v1/documents/process` with the style guide as the prompt. The agent restyles the filing and calls your checks on the edited filing. Each finding names the affected element by its `data-id`. The agent corrects that element and runs the check again.

<a id="what-you-set-up">

## What you set up

1. Expose each of your existing checks as an MCP tool. Each finding must name the affected element by its `data-id` and describe the violation.
2. Add the server to `mcp_servers` in the deployment configuration with a service token. A backend job has no signed-in user to authorize OAuth, so the server must accept a shared credential.
3. Set `allowedEnvironments` to the environments that process filings. Add any tool that must not run unattended to `tools.disabled`. If you set neither, every environment gets the server with every tool on it, in chat as well as in Document Processing. See [MCP tools](../../onpremises/ckeditor-ai-onpremises/mcp-tools.md).
4. Write the prompt. It contains the style guide and an instruction to the agent: run your checks on the edited filing, correct every violation the checks report, and name in the summary every violation it did not correct.
5. Store the prompt in a [context](extensions/context-library.md). Each request then references the context by its id. When the style guide changes, edit the context.
6. Submit each queued filing from the job. Set the client timeout to 10 minutes or more, as described under [Before you go to production](#before-you-go-to-production). Save the returned filing and the summary where reviewers read them.

<a id="what-you-get">

## What you get

* **One call per filing:** the agent runs your checks while it edits, so the job needs no verification step of its own.
* **A filing ready for review:** the response carries the edited filing and a `summary` that lists every violation the checks still report. The job stores both for a reviewer.

<a id="before-you-go-to-production">

## Before you go to production

* **Processing timeout:** the service allows up to 10 minutes for each call to `POST /v1/documents/process`. Several rounds of checks on a long filing take minutes, so set the client timeout to 10 minutes or more.
* **Unresolved findings:** the prompt tells the agent to run your checks, and it cannot make the filing pass them. Send every violation the summary reports as unresolved to a reviewer.

<a id="next-steps">

## Next steps

* **[Document restyling job with MCP verification in Node.js](../../examples/ckeditor-ai/restyling-job-nodejs.md)** has the configuration, the prompt, and the backend job code.
* **[Document Processing](document-processing.md)** covers the request, the response, and the streaming endpoint.
* **[MCP tools](extensions/mcp-tools.md)** covers what the agent can do with a connected server and where its tools apply.

---

Full index of the Cloud Services documentation: [llms.txt](../../../llms.txt)
