# Long operations: progress and cancellation

Index jobs and Agent Result Loop runs can take minutes on large EDT exports. MCP Gateway exposes progress notifications and explicit cancellation.

## MCP tools

| Tool | Purpose |
|------|---------|
| `operation.list` | List in-flight operations (`id`, `cancelled`) |
| `operation.cancel` | Request cancellation by `operationId` |

Index tools return `operationId` in the JSON result:

- `bsl.index_project`
- `form.index_project`
- `extension.index_project`
- `discover_1c_context`

Agent Result Loop uses `runId` as `operationId` for `run_agent_result_loop`.

## Example workflow

```json
// Start BSL index with stable operation id
{
  "tool": "bsl.index_project",
  "arguments": {
    "rootPath": "/exports/MyConfig",
    "profileId": "<profile-id>",
    "operationId": "index-job-2026-06-27"
  }
}

// Cancel if the agent or user stops the task
{
  "tool": "operation.cancel",
  "arguments": {
    "operationId": "index-job-2026-06-27",
    "reason": "User cancelled indexing"
  }
}
```

## MCP progress notifications

When the MCP client sends a `progressToken` in `_meta`, long tools emit `notifications/progress`:

- `bsl.index_project`
- `form.index_project`
- `extension.index_project`
- `discover_1c_context`
- `run_agent_result_loop`

## Production read-only mode

On production (`ONEC_PRODUCTION=1`) write/beta tools are hidden from `tools/list`. `operation.list` and `operation.cancel` remain available for read-only index jobs.

To enable beta write tools on production, set `ONEC_MCP_BETA_TOOLS=1` and restart the gateway.

## Live 1C E2E (optional)

For CI against a real published-web base, configure:

```bash
export ONEC_LIVE_E2E_BASE_URL="https://your-1c-host/base"
export ONEC_LIVE_E2E_ODATA_PATH="/odata/standard.odata/\$metadata"
export ONEC_LIVE_E2E_AUTH_USER="..."
export ONEC_LIVE_E2E_AUTH_PASSWORD="..."
npm run test
```

Tests in `tests/live-onec-e2e.test.ts` skip automatically when `ONEC_LIVE_E2E_BASE_URL` is unset.
