> For the complete documentation index, see [llms.txt](https://ai.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai.ortusbooks.com/model-context-protocol-mcp/server/pause-resume.md).

# Pause & Resume

Temporarily halt an MCP server without destroying its configuration.

Temporarily halt an MCP server without destroying its configuration.

{% hint style="info" %}
**Since BoxLang AI v3.2.0+**
{% endhint %}

## Overview

Pausing a server keeps it registered but rejects all incoming requests (except `ping`) with a `SERVER_PAUSED` error (code `-32005`).

**Useful for:**

* Maintenance windows
* Admin interfaces that need to disable a server temporarily
* Rate limiting or circuit breaker patterns
* Graceful shutdown sequences

## Basic Usage

```javascript
server = MCPServer( "my-tools" )
    .registerTool( searchTool )
    .registerTool( createTicketTool )

// Pause the server
server.pause()

// Check if paused
if ( server.isPaused() ) {
    println( "Server is currently paused" )
}

// Resume the server
server.resume()
```

## Fluent Chaining

```javascript
server = MCPServer( "admin-tools" )
    .registerTool( adminTool )
    .pause()      // Start paused
    .resume()     // Resume when ready
```

## Events

Pausing and resuming fire interception points:

| Event               | When                   |
| ------------------- | ---------------------- |
| `onMCPServerPause`  | When `pause()` called  |
| `onMCPServerResume` | When `resume()` called |

```javascript
BoxRegisterInterceptor( "onMCPServerPause", function( event ) {
    println( "MCP server paused: #event.name#" )
    // Notify admin, send alert, etc.
})

BoxRegisterInterceptor( "onMCPServerResume", function( event ) {
    println( "MCP server resumed: #event.name#" )
})
```

## Error Response When Paused

When a paused server receives a request (except `ping`), it returns:

```json
{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32005,
        "message": "Server is paused"
    }
}
```

## Monitoring Pause State

```javascript
summary = server.getStatsSummary()
println( "Paused: #summary.paused#" )  // true or false
```

## Example: Maintenance Mode

```javascript
// Application.bx
class {

    function onApplicationStart() {
        MCPServer( "myApp" )
            .registerTool( productTool )
            .registerTool( orderTool )
    }

    function enterMaintenance() {
        var server = MCPServer( "myApp" )
        if ( !isNull( server ) ) {
            server.pause()
            writeLog( "Server paused for maintenance" )
        }
    }

    function exitMaintenance() {
        var server = MCPServer( "myApp" )
        if ( !isNull( server ) ) {
            server.resume()
            writeLog( "Server resumed" )
        }
    }

}
```

## Next Steps

* ✅ [Best Practices](https://ai.ortusbooks.com/model-context-protocol-mcp/server/best-practices.md) — Production patterns
* 📊 [Observability](https://ai.ortusbooks.com/model-context-protocol-mcp/server/observability.md) — Monitor operations
* 💡 [Examples](https://ai.ortusbooks.com/model-context-protocol-mcp/server/_examples.md) — Complete examples


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://ai.ortusbooks.com/model-context-protocol-mcp/server/pause-resume.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
