Skip to content

feat: per-service remote/local routing, lifecycle logging, and preconnect#26

Merged
rodaddy merged 5 commits into
mainfrom
feat/remote-routing-and-lifecycle-logging
Jun 9, 2026
Merged

feat: per-service remote/local routing, lifecycle logging, and preconnect#26
rodaddy merged 5 commits into
mainfrom
feat/remote-routing-and-lifecycle-logging

Conversation

@rodaddy

@rodaddy rodaddy commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Per-service source field in services.json controls whether calls route through a remote daemon ("remote"), stay local ("local"), or try remote first with local fallback ("remote-local")
  • 4-event structured request lifecycle logging: request_inmcp_call_startmcp_call_endresponse_out
  • Connection pool preconnect at startup via MCP2CLI_PRECONNECT=1 — all services hot on boot
  • Remote retry with exponential backoff (3 attempts, 500ms/1s/2s)
  • Version now sourced from package.json in /health and /metrics endpoints
  • Stderr log rotation for MCP server child processes (10MB max, single backup)

Test plan

  • 869 tests pass
  • Typecheck clean
  • Verified remote routing: proxmox → CT 216, qmd → local, open-brain → remote-local
  • Verified lifecycle logs in journald (4 events per call)
  • Verified preconnect (11/11 services connected at startup)
  • Verified version in /health and /metrics endpoints

🤖 Generated with Claude Code

rodaddy and others added 3 commits June 9, 2026 00:06
9 features, 3 fixes, and 2 infra changes since 0.2.0.
Initializes VERSION file for pre-PR hook enforcement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nect

Adds `source` field to service config ("local", "remote", "remote-local")
for per-service control over whether calls route through a remote daemon
or stay local. Default when MCP2CLI_REMOTE_URL is set: remote-local
(try remote with 3x retry + exponential backoff, fall back to local).

Adds 4-event request lifecycle logging to structured JSON output:
request_in → mcp_call_start → mcp_call_end → response_out.

Also adds:
- Pool preconnect at startup (MCP2CLI_PRECONNECT=1)
- Stderr log rotation (10MB max, single backup)
- Version from package.json in /health and /metrics endpoints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

rodaddy and others added 2 commits June 9, 2026 01:58
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes 2 CRITICAL, 4 HIGH, 8 MEDIUM findings from review swarm:

- fetchRemote checks response body for app errors + skips retry on 401/403
- Remote connect timeout split to 10s (down from 60s)
- Error-path mcp_call_end uses resolved tool name
- preconnectAll has 15s per-service timeout + batches of 4
- request_in log sanitizes params via exported sanitizeParams
- Stderr rotation uses async I/O, initializes counter from file size
- ServiceSource/SourceSchema re-exported from config barrel
- Dead metrics methods removed (onConnect/onDisconnect/onHealthCheckFailure)
- package.json imports use `with { type: "json" }` consistently
- Retry constants configurable via MCP2CLI_REMOTE_RETRIES/BACKOFF_MS
- Graceful drain on shutdown (server.stop() without force)
- Test assertions updated for response_out event format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@rodaddy rodaddy merged commit 2abd0f0 into main Jun 9, 2026
3 of 4 checks passed
@rodaddy rodaddy deleted the feat/remote-routing-and-lifecycle-logging branch June 9, 2026 06:10
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