Skip to main content
Glama
ephemeral-buffer

ephemeral-buffer

by k-rister

Ephemeral Buffer MCP Server (ephemeral-buffer)

CI License Python PyPI codecov

Ephemeral Buffer is an MCP server and command-line client for capturing command output in a bounded, searchable buffer. Coding agents can search captures and retrieve relevant portions instead of carrying entire build and test logs in their conversation context.

Quick start

Requires Python 3.11 or newer. Install the package in an isolated environment.

macOS and Linux

python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install ephemeral-buffer-mcp

The default distribution includes BM25, semantic, and hybrid search. To explicitly choose the smaller lexical-only install, use ephemeral-buffer-mcp-lexical; it supports BM25 while semantic and hybrid search require the full distribution.

Configure your MCP client using the user guide. For an isolated server, the server and ephbuf must use the same unique session ID. On macOS/Linux, export the ID before starting Codex with the launcher installed in the virtual environment:

export EPHEMERAL_SESSION_ID=quick-start-session
.venv/bin/codex-ephemeral

Set the same value in another MCP client's server environment. Then capture command output with ephbuf, passing the same ID.

macOS and Linux

.venv/bin/python -c 'print("Hello from a captured command")' 2>&1 |
  EPHEMERAL_SESSION_ID=quick-start-session .venv/bin/ephbuf --label "quick start"

Windows installation steps are in the user guide's Windows support section. Windows runtime behavior isn't covered by CI; that section describes the unverified CLI capture and process-control paths.

The agent can then search the capture and retrieve bounded slices through the MCP tools.

Related MCP server: AI Agent History RAG MCP Server

Context reduction in one agent comparison

In a five-repetition gpt-6-luna comparison run on 2026-10-09, mean MCP tool-response bytes fell from 6,681 to 1,501 (77.5%); the Codex context proxy fell from 23,910 to 17,643 bytes (26.2%). This is a result from one workload, not a general savings guarantee. The context figure is a prompt/event-envelope proxy, not the model's internal context size. See the benchmark methodology and comparison details.

Documentation

Topic

Document

Installation, client setup, and privacy

User guide

MCP tools and advanced workflows

Tool reference

Data flow

Architecture

Benchmark commands, metrics, and comparisons

Benchmarks

Runtime configuration and operations

Operations guide

Development setup and contribution workflow

Contributing

Release history

Changelog

Available Tools

19 tools
capture_fileA

Reads a file or log output from disk and ingests it into the ephemeral search index. Returns a compact versioned JSON summary and preserves optional named metrics in structured_metrics.

Validate the intended file path before calling: resolve symlinks when path identity matters, confirm the file belongs to the expected workspace, and use an explicit bounded max_bytes for large or untrusted files. Capture limits control output handling; they do not validate filesystem intent.

Inputs: file_path (required), label, max_bytes, content_type, +1 more. Returns: result

capture_textA

Ingest already-collected text and return capture metadata.

Use this when the caller already has output to index. For a noisy or potentially long command, use execute_and_capture so output remains bounded before it reaches the agent context. The return value is a compact versioned JSON summary; optional named metrics are retained in structured_metrics.

Inputs: content (required), label, content_type, structured_metrics. Returns: result

clear_capturesA

Clears all or a specific capture from the ephemeral buffer to free memory.

Inputs: capture_id. Returns: result

consolidate_capturesB

Create one bounded, searchable JSON capture from multiple captures.

The consolidated capture keeps source capture IDs and source line numbers. If records do not fit, the complete source captures remain available through their original IDs until normal LRU eviction. The operation fails if the consolidated capture cannot be admitted while retaining those sources.

Inputs: label, max_bytes, capture_ids, max_captures. Returns: result

execute_and_captureA

Runs a shell command, captures stdout/stderr, indexes it, and returns a compact versioned JSON summary without flooding the prompt context with thousands of lines. The summary includes status, duration, sizes, approximate token counts, truncation, signals, and optional named metrics.

Use this for noisy tests, builds, logs, and other output that benefits from bounded capture and later search. Direct command execution is usually faster for a small, targeted inspection; use capture once output may be noisy, large, or uncertain. This is an advisory routing heuristic, not an enforced threshold. Before running, verify the command, intended repository, and working directory: an omitted cwd inherits the server process directory, and symlinks or shell expansion can target a different path than expected. This tool bounds output but does not validate command intent, path identity, or filesystem safety.

Args: command: Shell command line to execute. cwd: Optional working directory for command execution; pass an explicit validated path for repository-sensitive commands. label: Optional human-readable description/label for this capture. content_type: Content type hint - 'auto' (default, detects diff/log/text), 'diff', 'log', or 'text'. max_output_bytes: Maximum command output retained (default: configured buffer byte limit). timeout_seconds: Optional maximum runtime; timed-out commands return exit code 124.

Inputs: command (required), cwd, label, content_type, +3 more. Returns: result

get_buffer_statsB

Returns aggregate capture, accounting, prefetch, and process RSS metrics.

Inputs: no named parameters. Returns: result

get_capture_sliceA

Fetches an exact range of lines (1-indexed) from a capture to inspect full context around a match.

Inputs: end_line (required), start_line (required), capture_id. Returns: result

get_capture_summaryA

Returns a compact versioned JSON summary. Set include_previews when head and tail samples are needed; full output remains available through get_capture_slice.

Inputs: capture_id, include_previews. Returns: result

get_executionB

Return durable phase metadata and event history for one execution.

Inputs: execution_id (required), include_output. Returns: result

get_execution_outputA

Retrieve one bounded output chunk for all phases or one named phase.

Inputs: execution_id (required), offset, max_bytes, phase_name. Returns: result

get_runtime_diagnosticsA

Returns opt-in runtime metadata without exposing captured content.

Inputs: no named parameters. Returns: result

get_usage_metricsC

Return content-free usage metrics, optionally since a snapshot token.

Inputs: since. Returns: result

list_capturesA

Lists all captures currently retained in the ephemeral ring buffer.

Inputs: no named parameters. Returns: result

list_executionsA

List durable executions with compact partial/completion summaries.

Inputs: limit, offset. Returns: result

preflight_commandA

Return content-free path and executable diagnostics without running command.

This resolves the working directory, symlink target, detectable Git repository root, and first executable token. Shell expansion, aliases, pipelines, redirections, environment changes, and arbitrary shell logic cannot be verified here. The requested command is never executed.

Inputs: command (required), cwd. Returns: result

resume_executionA

Resume an execution from its first incomplete phase.

Completed phases are skipped. Failed and timed-out phases require retry_failed=True; a safe phase recovered as interrupted resumes on the normal call. Retries of unsafe phases additionally need confirm_unsafe=True unless the execution was created with the explicit allow-unsafe resume policy.

Inputs: execution_id (required), retry_failed, confirm_unsafe. Returns: result

search_captureA

Searches the captured command output using BM25, Semantic embedding, or Hybrid (RRF) ranking. Semantic prefetch is on by default. Hybrid search waits at most the configured semantic wait budget for an active index job and may return BM25 results marked pending while that job continues. Semantic indexing is bounded by a per-capture input-byte budget and token-budgeted inference batches. Captures over the input budget use immediate BM25 fallback for semantic and hybrid searches; semantic mode waits for indexing unless the capture exceeds that budget.

Args: query: Search keywords or natural language question (e.g. 'auth failure', 'ECONNREFUSED', 'why did the build fail?'). mode: Search mode - 'hybrid' (recommended, lexically weighted BM25 + Semantic), 'bm25' (keyword terms), or 'semantic' (vector concepts). capture_id: The capture ID to query (defaults to 'latest'). top_k: Number of matching snippets to return (default: 5). context_lines: Number of surrounding lines of context to include with each match (default: 3; must be non-negative).

Inputs: query (required), mode, top_k, capture_id, +1 more. Returns: result

set_semantic_index_budgetC

Adjust this session's semantic-index chunk budget when explicitly enabled.

Inputs: max_indexed_chunks (required). Returns: result

start_executionA

Run a sequential, durably checkpointed set of command phases.

Each phase is an object with name and command plus optional cwd, timeout_seconds, max_output_bytes, structured_metrics, and side_effects (none or unsafe). A completed phase is never rerun by resume_execution. An unsafe phase that must be retried after failure, timeout, or interruption requires confirm_unsafe=True or the explicit resume_policy='allow-unsafe'. Outputs and phase event history are stored under EPHEMERAL_EXECUTION_STATE_DIR.

Inputs: phases (required), cwd, label, execution_id, +3 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools target clearly different resources or actions: capture ingestion, capture search, durable execution lifecycle, and diagnostics are separable. Some boundaries are softer, especially execute_and_capture versus start_execution and the family of stats/diagnostics/usage tools, but descriptions generally help distinguish them.

    Naming Consistency5/5

    Tool names consistently use snake_case and mostly follow a predictable verb_noun pattern, such as search_capture, get_execution, list_captures, and clear_captures. The few compound or longer names remain readable and do not break the overall convention.

    Tool Count3/5

    At 19 tools, the surface is heavy for an ephemeral buffer server and includes several utility/diagnostic tools that could feel like surface-area expansion. Most tools are purposeful, but the count sits in the borderline 16-25 range where scoping can become harder to manage.

    Completeness4/5

    The server covers the core capture lifecycle well: ingestion, search, slice/summary retrieval, listing, clearing, consolidation, and execution start/resume/read operations. Minor gaps remain, such as explicit execution cancellation/deletion or broader cross-execution querying, but agents can work around them.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI coding assistants to search and retrieve information from a locally ingested knowledge base using hybrid search, grounded in user-curated documentation.
      17
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Provides persistent, searchable memory across AI coding agent and chat history (Claude Code, Codex, Gemini CLI, ChatGPT, and more) via retrieval-augmented generation, enabling semantic and hybrid search to retain context across sessions.
      5
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI coding agents to intelligently index and search codebases with sub-20ms retrieval, 8x memory compression, and cross-encoder reranking via MCP stdio.
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI coding agents to retrieve developer context, semantic memory, decisions, and checkpoints across sessions through hybrid full-text and vector search, with token-budgeted retrieval for task-relevant context.
      MIT