# MCPRequestHandler.respond(to:emit:)

- **Module:** MCPRequestHandler
- **Package:** libtmux-swift
- **Language:** Swift
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-swift/blob/f02a4668570e1cc5198c941413750e021f42c214/Sources/LibTmuxMCP/MCPProtocol.swift#L46
- **Page:** https://libtmux.org/reference/swift/mcprequesthandler-respond(to-emit-)/

```
MCPRequestHandler.respond(to:emit:)(to: String, emit: @escaping (String) async -> Void) -> String?
```

Answers one newline-delimited JSON-RPC request.

Returns the response line, or `nil` for a valid notification, an
oversized request, or a tool call whose id cannot fit in a bounded
response. Malformed JSON and invalid request objects receive the
standard JSON-RPC error with a null id.

- Parameters:
  - line: one JSON-RPC request without its trailing newline.
  - emit: where a notification sent *before* the answer goes — progress,
    while a long call is still running. Writing them is the caller's job
    because they share the one stdout the answer uses, and two writers
    there would interleave.
