Skip to content

feat: --auto-watch flag to embed watcher inside MCP server process (conflict-resolved)#368

Open
tirth8205 wants to merge 4 commits intomainfrom
feat/auto-watch-mcp-server-resolved
Open

feat: --auto-watch flag to embed watcher inside MCP server process (conflict-resolved)#368
tirth8205 wants to merge 4 commits intomainfrom
feat/auto-watch-mcp-server-resolved

Conversation

@tirth8205
Copy link
Copy Markdown
Owner

Summary

This PR resolves the merge conflicts from PR #130 (originally from @Dhruv-Darji) and brings in the --auto-watch feature cleanly on top of main.

Original PR: #130 by @Dhruv-Darji

Changes from PR #130 (preserved):

  • serve --auto-watch / mcp --auto-watch flag to start filesystem watcher in a background daemon thread while MCP server runs
  • New mcp command as an alias for serve
  • watch command now raises RuntimeError and exits with code 1 when watcher lock is already held (e.g. daemon running)
  • start_watch_thread() helper in incremental.py for embedding watcher in MCP process
  • Daemon lock/PID file infrastructure (_acquire_watch_lock, _release_watch_lock, start_watch_daemon, stop_watch_daemon, get_watch_daemon_status)
  • New tests: TestServeCommand, TestDaemonCommand, TestWatchInteraction in test_cli.py; TestWatchDaemon in test_incremental.py

Conflict resolution:

  • cli.py: merged --auto-watch and mcp alias alongside existing --http/--tools/--host/--port flags
  • main.py: merged auto_watch param + watch store lifecycle into the full transport-aware main() function (keeping --http, --tools, Windows event loop fix)
  • incremental.py: kept on_files_updated callback from main + all lock/daemon helpers from PR
  • embeddings.py: kept both typing.cast (from PR) and urllib.parse.urlparse (from main)

Test plan

  • uv run pytest tests/test_cli.py tests/test_incremental.py -v
  • uv run code-review-graph serve --auto-watch starts MCP server with background watcher
  • uv run code-review-graph mcp --auto-watch works as alias
  • uv run code-review-graph serve --http --port 5555 still works
  • uv run code-review-graph daemon start / stop / status work
  • uv run code-review-graph watch exits with error when daemon is running

Closes #130

🤖 Generated with Claude Code

Dhruv-Darji and others added 4 commits April 9, 2026 10:43
Merged PR #130 (feat: --auto-watch flag to embed watcher inside MCP server process)
with main. Kept both sides' changes:
- cli.py: added --auto-watch/mcp alias alongside existing --http/--tools/--host/--port
- main.py: merged auto_watch param + watch_store lifecycle into full transport-aware main()
- incremental.py: kept on_files_updated callback from main + lock/daemon helpers from PR
- embeddings.py: kept both typing.cast and urllib.parse.urlparse imports
- tests: kept both test classes from each side

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.

2 participants