-
Notifications
You must be signed in to change notification settings - Fork 0
Performance improvements and benchmark framework #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wolfiesch
merged 11 commits into
master
from
feat/performance-improvements-and-benchmarks
Jan 11, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cc266e8
docs(CLAUDE.md): clarify MCP integration priority for local tools
wolfiesch 09f2462
feat(reminders): add timing instrumentation and increase timeouts
wolfiesch 93b1ada
feat(texting): add FDA-free database access with security-scoped bookβ¦
wolfiesch f22affd
feat(gmail): add batch optimization and CLI with daemon support
wolfiesch 2d247c3
feat(calendar): add CLI with daemon support and timing instrumentation
wolfiesch d7c935a
feat(google-daemon): add shared daemon for Gmail and Calendar services
wolfiesch e04a05a
feat(benchmarks): add comprehensive iMessage MCP benchmark framework
wolfiesch 82e5468
chore(benchmarks): add iMessage MCP performance benchmark results
wolfiesch ada395d
docs(plans): add Rust MCP clients handoff documentation
wolfiesch f836278
feat(imessage): implement Phase 3 - analytics, discovery, and groups β¦
wolfiesch c07119f
feat(imessage): add Phase 4 daemon infrastructure and fix PR review cβ¦
wolfiesch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| # Rust MCP Client Refactor - Handoff Prompt | ||
|
|
||
| **For:** Fresh Claude agent | ||
| **Project:** LIFE-PLANNER | ||
| **Date:** 01/08/2026 | ||
|
|
||
| --- | ||
|
|
||
| ## Context | ||
|
|
||
| We successfully built a high-performance iMessage CLI using the **Rust client + Python daemon** pattern, achieving **19x faster performance** than the original MCP-based approach (40ms vs 763ms per operation). | ||
|
|
||
| The architecture: | ||
| - **Rust CLI** (`wolfies-imessage`): Fast ~3ms spawn, sends requests via Unix socket | ||
| - **Python daemon** (`imessage_daemon.py`): Warm process handling iMessage operations | ||
| - **Protocol**: JSON-RPC over Unix socket at `~/.wolfies-imessage/daemon.sock` | ||
|
|
||
| This is now distributed via Homebrew (`brew install wolfiesch/executive-function/wolfies-imessage`). | ||
|
|
||
| --- | ||
|
|
||
| ## Task: Extend Pattern to Other MCP Servers | ||
|
|
||
| Three Python MCP servers currently exist that could benefit from Rust CLI wrappers: | ||
|
|
||
| | Module | Current Location | MCP Tools | | ||
| |--------|-----------------|-----------| | ||
| | **Gmail** | `src/integrations/gmail/server.py` | list_emails, get_email, search_emails, send_email, get_unread_count | | ||
| | **Calendar** | `src/integrations/google_calendar/server.py` | list_events, get_event, create_event, find_free_time | | ||
| | **Reminders** | `Reminders/mcp_server/server.py` | create_reminder, list_reminders, complete_reminder, delete_reminder, list_reminder_lists | | ||
|
|
||
| --- | ||
|
|
||
| ## Reference Implementation | ||
|
|
||
| Study these files to understand the pattern: | ||
|
|
||
| ### Rust Client (shared library + iMessage binary) | ||
| ``` | ||
| Texting/gateway/wolfies-client/ | ||
| βββ Cargo.toml # Workspace definition | ||
| βββ crates/ | ||
| β βββ wolfies-core/ # Shared library | ||
| β β βββ src/lib.rs # Protocol, client, response types | ||
| β β βββ Cargo.toml | ||
| β βββ wolfies-imessage/ # iMessage-specific binary | ||
| β βββ src/main.rs # CLI entry point | ||
| β βββ Cargo.toml | ||
| ``` | ||
|
|
||
| ### Python Daemon | ||
| ``` | ||
| Texting/gateway/ | ||
| βββ imessage_daemon.py # Unix socket server, handles JSON-RPC | ||
| βββ imessage_daemon_client.py # Python client for testing | ||
| βββ output_utils.py # Shared output formatting | ||
| ``` | ||
|
|
||
| ### Key Files to Read | ||
| 1. `Texting/gateway/wolfies-client/crates/wolfies-core/src/lib.rs` - Protocol definition | ||
| 2. `Texting/gateway/wolfies-client/crates/wolfies-imessage/src/main.rs` - CLI structure | ||
| 3. `Texting/gateway/imessage_daemon.py` - Daemon architecture | ||
| 4. `Plans/Rust_Gateway_Framework_2026-01-08.md` - Original implementation plan | ||
|
|
||
| --- | ||
|
|
||
| ## Benchmarking Approach | ||
|
|
||
| We used a normalized workload benchmark to compare implementations: | ||
|
|
||
| ### Benchmark Script | ||
| `Texting/benchmarks/normalized_workload_benchmarks.py` | ||
|
|
||
| ### Workloads Tested | ||
| 1. **recent** - Get recent messages (light read) | ||
| 2. **unread** - Get unread messages (light read) | ||
| 3. **find** - Search messages (medium read) | ||
| 4. **send** - Send message (write operation) | ||
| 5. **contacts** - List contacts (metadata read) | ||
|
|
||
| ### Metrics Captured | ||
| - Cold start time (first request) | ||
| - Warm request time (subsequent requests) | ||
| - P50, P95, P99 latencies | ||
| - Memory usage | ||
| - Throughput (requests/second) | ||
|
|
||
| ### Before/After Comparison | ||
| Create baseline benchmarks BEFORE implementing Rust clients, then compare after. | ||
|
|
||
| --- | ||
|
|
||
| ## Proposed Phases | ||
|
|
||
| ### Phase 1: Gmail Rust Client | ||
| 1. Create `wolfies-gmail` crate in workspace | ||
| 2. Convert `gmail/server.py` to daemon mode (Unix socket) | ||
| 3. Implement Rust CLI with subcommands: `list`, `search`, `read`, `send`, `unread` | ||
| 4. Benchmark before/after | ||
| 5. Update Homebrew formula | ||
|
|
||
| ### Phase 2: Calendar Rust Client | ||
| 1. Create `wolfies-calendar` crate | ||
| 2. Convert `google_calendar/server.py` to daemon mode | ||
| 3. Implement Rust CLI: `list`, `get`, `create`, `free-time` | ||
| 4. Benchmark before/after | ||
| 5. Update Homebrew formula | ||
|
|
||
| ### Phase 3: Reminders Rust Client | ||
| 1. Create `wolfies-reminders` crate | ||
| 2. Convert `Reminders/mcp_server/server.py` to daemon mode | ||
| 3. Implement Rust CLI: `create`, `list`, `complete`, `delete`, `lists` | ||
| 4. Benchmark before/after | ||
| 5. Update Homebrew formula | ||
|
|
||
| --- | ||
|
|
||
| ## Questions to Consider | ||
|
|
||
| 1. **Is Rust worth it for these?** iMessage benefited because it's used for quick lookups (`unread`, `recent`). Gmail/Calendar/Reminders are primarily MCP servers for Claude Code - direct CLI use is less common. Benchmark first to see if there's a real bottleneck. | ||
|
|
||
| 2. **Daemon vs Direct?** iMessage uses a daemon because the database reads are expensive to initialize. Gmail/Calendar use OAuth which has its own warm-up cost. Profile to see where time is spent. | ||
|
|
||
| 3. **Shared credentials?** Gmail and Calendar could share OAuth tokens. Consider a unified Google daemon. | ||
|
|
||
| --- | ||
|
|
||
| ## Quick Start Commands | ||
|
|
||
| ```bash | ||
| # Read the iMessage implementation | ||
| cat Plans/Rust_Gateway_Framework_2026-01-08.md | ||
|
|
||
| # Check the Rust workspace structure | ||
| ls -la Texting/gateway/wolfies-client/crates/ | ||
|
|
||
| # Read the core library | ||
| cat Texting/gateway/wolfies-client/crates/wolfies-core/src/lib.rs | ||
|
|
||
| # Run existing benchmarks | ||
| python3 -m Texting.benchmarks.normalized_workload_benchmarks --help | ||
|
|
||
| # Check current MCP servers | ||
| cat src/integrations/gmail/server.py | head -100 | ||
| cat src/integrations/google_calendar/server.py | head -100 | ||
| cat Reminders/mcp_server/server.py | head -100 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Success Criteria | ||
|
|
||
| - [ ] Baseline benchmarks for each MCP server | ||
| - [ ] Rust CLI achieving <50ms for common operations | ||
| - [ ] Homebrew formulas updated with Rust binaries | ||
| - [ ] Before/after performance comparison documented | ||
| - [ ] All existing functionality preserved | ||
|
|
||
| --- | ||
|
|
||
| ## Notes | ||
|
|
||
| - The Homebrew tap is at `wolfiesch/homebrew-executive-function` | ||
| - Release workflow at `.github/workflows/release.yml` handles multi-module builds | ||
| - Current version is v0.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
TimingContextclass is a useful utility for performance profiling. Since the PR description mentions adding timing instrumentation to other integrations likeGmailandCalendar, this context manager is likely to be needed in other server files as well.To promote code reuse and avoid duplication, consider moving
TimingContextand its_timinghelper function to a shared utility module within the project, for example, in amcp.utilsormcp.profilingmodule. This will make it easier to apply consistent timing instrumentation across all MCP servers.