# Ruby MCP examples

Source: https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/examples/

> Run complete Ruby programs for an MCP client or an embedded application.

**MCP concept example** A working example of the core library. It can change without notice.

Both examples include their complete program, pinned dependencies, run
commands, expected results, and cleanup. Each creates its own tmux daemon.

## Default read-only catalog

The [client guide](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/guides/connect-client/#configure-a-client) generates an
MCP configuration using the launcher's absolute path and the current Ruby
executable. Its default catalog contains [`tmux_capabilities`](<https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/tools/tmux_capabilities/>) and
[`tmux_snapshot`](<https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/tools/tmux_snapshot/>). Listing the tools and querying the example session verifies
the connection.

The [embedded example](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/examples/page-session-metadata/) calls those tools from Ruby
inside an Async scope. It creates two sessions and prints their names by
following a snapshot cursor.

## Add bounded observation

For capture or waits in the client launcher, add
`"--enable-tool", "`[`tmux_capture`](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/tools/tmux_capture/)`"` or `"--enable-tool", "`[`tmux_wait`](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/tools/tmux_wait/)`"` to the
array passed to [`LibTmux::MCP::CLI.run`](<https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/reference/libtmux-mcp-cli-run-19of/>) in `run-mcp.rb`. Adding them to the
generated client configuration's arguments has no effect: the launcher does
not forward those arguments. Enable creation, input, close, or authored
execution only when the client needs those effects.
The [guides overview](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/guides/#enable-observation) explains the tool choices;
the [source-owned guide](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/source-guide/) gives their lifecycle contracts.

- [Page session metadata](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/examples/page-session-metadata/): Embed the MCP application, page two session names from one capture, and close owned resources.
- [Launch a client server](https://libtmux.org/en/ruby/v0.1.0.alpha.3/mcp/guides/connect-client/): Run a stdio MCP server with a private tmux daemon and a generated client configuration.
