Skip to content

Merge MCP server into the tempyr binary#2

Merged
cleak merged 1 commit into
masterfrom
codex/merge-mcp-into-tempyr-binary
Apr 2, 2026
Merged

Merge MCP server into the tempyr binary#2
cleak merged 1 commit into
masterfrom
codex/merge-mcp-into-tempyr-binary

Conversation

@cleak
Copy link
Copy Markdown
Owner

@cleak cleak commented Apr 2, 2026

Summary

  • merge the MCP server into the tempyr binary behind an early tempyr --mcp launch path
  • convert tempyr-mcp from a standalone binary crate into an internal library with serve_stdio()
  • add launch-path tests and update docs to describe the new packaging model

Details

  • tempyr-cli now inspects raw args before clap parsing and routes --mcp into MCP stdio mode
  • extra arguments after --mcp are rejected instead of being ignored
  • tempyr-mcp exposes library entrypoints and TempyrServer now implements Default
  • the old crates/tempyr-mcp/src/main.rs binary entrypoint is removed
  • repo docs now describe tempyr-mcp as a library launched via tempyr --mcp

Verification

  • cargo clippy -p tempyr-cli -p tempyr-mcp --all-targets
  • cargo test --workspace
  • cargo build --release -p tempyr-cli -F tempyr-index/local-embeddings

Packaging result

  • release builds now emit only tempyr.exe
  • local-embeddings size dropped from the old combined tempyr.exe + tempyr-mcp.exe footprint of 64,291,328 bytes to a single tempyr.exe at 37,658,624 bytes

Summary by CodeRabbit

  • New Features

    • Added --mcp startup mode to launch the MCP server over standard I/O.
  • Documentation

    • Clarified that the MCP server is launched via the tempyr --mcp option.
    • Updated CLI and configuration documentation to reflect the new launch approach.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 101ff69d-7378-4b0f-b5f5-2bc56323642f

📥 Commits

Reviewing files that changed from the base of the PR and between fe83a95 and f303a5c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • AGENTS.md
  • CLAUDE.md
  • crates/tempyr-cli/Cargo.toml
  • crates/tempyr-cli/src/main.rs
  • crates/tempyr-cli/tests/integration.rs
  • crates/tempyr-mcp/Cargo.toml
  • crates/tempyr-mcp/src/handler.rs
  • crates/tempyr-mcp/src/lib.rs
  • crates/tempyr-mcp/src/main.rs
  • docs/graphspec.md
💤 Files with no reviewable changes (1)
  • crates/tempyr-mcp/src/main.rs

📝 Walkthrough

Walkthrough

The changes convert tempyr-mcp from a standalone binary crate into a library. A new --mcp launch mode is added to the CLI that detects this flag and invokes the MCP server via the library's public serve_stdio() function. Documentation is updated to reflect this architectural shift.

Changes

Cohort / File(s) Summary
Documentation Updates
AGENTS.md, CLAUDE.md, docs/graphspec.md
Updated descriptions of tempyr-mcp from an MCP server binary to a library consumed by the tempyr --mcp mode; removed references to standalone binary and TCP transport option.
CLI Launch Mode Detection
crates/tempyr-cli/src/main.rs
Replaced synchronous main() with async #[tokio::main] main() that detects --mcp flag from raw arguments and routes to either standard CLI parsing or tempyr_mcp::serve_stdio(). Added LaunchMode enum, detect_launch_mode_from_args(), mcp_args_error() helpers, and unit tests for argument validation.
CLI Integration & Testing
crates/tempyr-cli/Cargo.toml, crates/tempyr-cli/tests/integration.rs
Added tempyr-mcp path dependency to CLI crate; introduced two integration tests validating --mcp argument parsing and server startup behavior.
MCP Library Conversion
crates/tempyr-mcp/Cargo.toml, crates/tempyr-mcp/src/lib.rs, crates/tempyr-mcp/src/handler.rs
Removed explicit [[bin]] target declaration and added anyhow dependency; created new library entrypoint with public serve_stdio() function that wraps server initialization and stdio transport; added Default trait impl for TempyrServer.
MCP Binary Removal
crates/tempyr-mcp/src/main.rs
Deleted standalone main() function that previously served the MCP server over stdio directly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • cleak/blueberry#103: Converts tempyr-mcp from a standalone binary to a library integrated via serve_stdio(), which conflicts with retrievals pointing CLI at tempyr-mcp.exe binary path.

Poem

🐰 A hopping tale of transformation, sweet!
From binary paths to library's neat retreat,
The CLI now calls with --mcp in hand,
And serve_stdio() answers, as planned! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main objective: merging the MCP server into the tempyr binary by converting tempyr-mcp from a standalone binary into a library accessed via 'tempyr --mcp'.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/merge-mcp-into-tempyr-binary

Comment @coderabbitai help to get the list of available commands and usage tips.

@cleak cleak merged commit 0770a07 into master Apr 2, 2026
1 check passed
@cleak cleak deleted the codex/merge-mcp-into-tempyr-binary branch April 2, 2026 04:26
cleak added a commit that referenced this pull request Apr 28, 2026
…on-miss in journal_get

Three findings, all valid:

1. **`ingest_open_file` slurped the whole file**: `std::fs::read(path)`
   on a JSONL that's been growing across many agent invocations
   could OOM the indexer on very large sessions. Switched to
   `File::open` + `BufReader` + `seek(SeekFrom::Start(start))` and
   `read_until(b'\n')` to stream line-by-line, keeping memory bounded
   to one line buffer at a time. Partial-trailing-line behavior is
   preserved exactly: if the last line is missing its `\n` (writer
   mid-append), we stop *before* it and don't advance the offset, so
   the next refresh picks it up once the writer adds the newline.

2. **`read_last_offset` / `read_last_sha` swallowed all DB errors**
   via `.ok().flatten()`, hiding real problems (corrupt
   `indexer_state` table, locked db, etc.) behind silent re-ingestion.
   Switched to explicit match: `QueryReturnedNoRows` → `Ok(0)` / `Ok(None)`
   for first-time scans; everything else propagates. Distinguishes
   "no row yet" from real errors so a corrupted state surfaces
   instead of looking like a healthy fresh scan.

3. **`journal_get` returned null on cache miss without retrying**: an
   agent that called `journal_log` and then immediately called
   `journal_get(id)` would get null, because the indexer is the only
   writer and `journal_log` only appends to the JSONL. Fixed by
   adding a single refresh-on-miss retry. Re-opening the db alone
   wouldn't help — the index is the same. Calling `refresh_index`
   first ingests the new line, then the second `get_entry` hits.
   Bounded to exactly one retry; a still-missing id after refresh
   is a legitimate result (cross-machine entry not yet fetched).

Two new regression tests:

- `partial_trailing_line_is_left_for_next_refresh`: writes a complete
  line + a partial line (no `\n`), verifies refresh #1 ingests only
  the complete one and `j-partial` is absent. Then appends `\n` and
  verifies refresh #2 picks up the now-complete line.
- `read_last_offset_returns_zero_for_first_time_scan`: pins the
  happy-path behavior of the new error-handling path so a future
  regression can't silently swallow errors again.

Tests: 545 workspace-wide (+2 net). Clippy + fmt clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cleak added a commit that referenced this pull request Apr 29, 2026
feat: cross-encoder reranking on journal search (v2 backlog #2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant