# libtmux.Server.list_buffers

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/server.py#L1971
- **Page:** https://libtmux.org/reference/py/libtmux-server-list_buffers/

```
libtmux.Server.list_buffers(self, format_string: str | None = None, filter: str | None = None, # noqa: A002) -> list[str]
```

List paste buffers via ``$ tmux list-buffers``.

Without arguments returns tmux's default template
(``name: N bytes: "sample"``) — kept for backward compatibility.
Pass *format_string* to request a specific tmux format, or *filter*
to have tmux return only matching buffers.

## Parameters

- `self`
- `format_string` (str | None) — Output template (``-F`` flag). Example: ``"#{buffer_name}"`` for
raw names only.
- `filter` (str | None) — Filter expression evaluated by tmux (``-f`` flag). Buffers for
which the expanded expression is false are omitted. Example:
``"#{m:libtmux_mcp_*,#{buffer_name}}"``.
Note: this kwarg shadows the Python builtin ``filter`` by design —
it mirrors tmux's own flag name (``-f filter``) for grep-friendly
symmetry between the wrapper and the tmux manual.
tmux silently expands a malformed filter (unclosed
``#{...}``, unknown format token) to empty, which the
filter treats as false — every row is suppressed and no
stderr is emitted. A bad filter is
indistinguishable from "filter matched nothing"; verify
filter syntax against the FORMATS section of ``tmux(1)``. Warning:
- `# noqa: A002`

## Returns

list[str]
    Raw output lines.

## Example

Default template (backward-compatible):

```python
>>> server.set_buffer('buf_data')
>>> result = server.list_buffers()
>>> len(result) >= 1
True
```

## Example

Project just the names:

```python
>>> server.set_buffer('hello', buffer_name='gap6_demo')
>>> 'gap6_demo' in server.list_buffers(format_string='#{buffer_name}')
True
```

## Example

Filter via tmux:

```python
>>> matches = server.list_buffers(
...     format_string='#{buffer_name}',
...     filter='#{m:gap6_*,#{buffer_name}}',
... )
>>> 'gap6_demo' in matches
True
```
