> 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.

{% 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](/model-context-protocol-mcp/server/best-practices.md) — Production patterns
* 📊 [Observability](/model-context-protocol-mcp/server/observability.md) — Monitor operations
* 💡 [Examples](https://github.com/ortus-boxlang/bx-ai-docs/blob/v2.x/_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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
