> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebulaonchain.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# mpp_close_session — Settle and Close an MPP Channel

> Settle the active MPP payment channel on-chain. Pays the recipient the total committed amount and refunds any unused USDC budget to your wallet.

`mpp_close_session` settles your active MPP payment channel on the Stellar network. It broadcasts the final channel state as a single on-chain transaction, pays the recipient the total amount committed across all `mpp_fetch` calls, and refunds any unused portion of your original budget back to your wallet.

This tool takes no parameters — it operates on the currently active session.

## Parameters

`mpp_close_session` takes no parameters.

## Response

### Success

```json title="Success response" theme={null}
{
  "status": "ok",
  "data": {
    "tx_hash": "9d3e1a7f...4c88",
    "channel_id": "ch_4f8a2b1e",
    "amount_paid_usdc": 0.013,
    "amount_refunded_usdc": 0.987,
    "session_state": "closed"
  }
}
```

<ResponseField name="status" type="string">
  Always `"ok"` when the session is settled successfully.
</ResponseField>

<ResponseField name="data.tx_hash" type="string">
  The Stellar transaction hash for the on-chain settlement.
</ResponseField>

<ResponseField name="data.channel_id" type="string">
  The ID of the channel that was closed.
</ResponseField>

<ResponseField name="data.amount_paid_usdc" type="number">
  The total USDC paid to the recipient, equal to the sum of all `mpp_fetch` commitments in the session.
</ResponseField>

<ResponseField name="data.amount_refunded_usdc" type="number">
  The USDC returned to your wallet from the unused portion of the original budget.
</ResponseField>

<ResponseField name="data.session_state" type="string">
  Will be `"closed"` after successful settlement.
</ResponseField>

### Error — no active session

```json title="No active session" theme={null}
{
  "status": "error",
  "reason": "No active MPP session to close."
}
```

### Error — settlement failure

```json title="Settlement failure" theme={null}
{
  "status": "error",
  "reason": "On-chain settlement failed: transaction rejected by Stellar network"
}
```

## Best practice

Always close your MPP session explicitly when you are finished making requests. While sessions may eventually expire, calling `mpp_close_session` immediately frees up your locked budget and returns unused funds to your spendable balance without delay.

## Example

```json title="Tool call" theme={null}
{
  "tool": "mpp_close_session",
  "input": {}
}
```

```json title="Response" theme={null}
{
  "status": "ok",
  "data": {
    "tx_hash": "9d3e1a7fc4b2...4c88",
    "channel_id": "ch_4f8a2b1e",
    "amount_paid_usdc": 0.013,
    "amount_refunded_usdc": 0.987,
    "session_state": "closed"
  }
}
```

<Note>
  After closing a session, you can immediately open a new one with `mpp_open_session` if you need to make more MPP-gated requests.
</Note>
