refactor: split mcp_server.py into tools/ sub-package by domain - #72
Merged
Merged
Conversation
mcp_server.py was a 309-line flat file with all 9 MCP tools inline. Split into a tools/ sub-package so each domain is independently navigable, importable, and testable: tools/control.py — screen_enable, screen_disable, screen_status tools/screen.py — screen_capture, screen_list_displays tools/audio.py — screen_capture_audio (+ _Audio fallback) tools/watch.py — screen_watch_start/stop/latest mcp_server.py becomes a ~40-line orchestrator: creates the FastMCP instance and calls register_all(mcp) from tools/__init__.py. No external contracts change — mcp object, run() entry point, and all test imports are identical. Update docs/architecture.md module map, docs/index.md tool count (8 -> 9), docs/help/development.md test table, and AGENTS.md rule 8 and build-order step 4 to reflect the new structure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGJmVMdVAbyTnUV2KYWfF7
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
mcp_server.pywas a 309-line flat file with all 9 MCP tools inline, making it hard to navigate, test, or extend without scrolling through unrelated codetools/sub-package — one module per domain, each with aregister(mcp)function:tools/control.py—screen_enable,screen_disable,screen_statustools/screen.py—screen_capture,screen_list_displaystools/audio.py—screen_capture_audio(includes_Audiofallback)tools/watch.py—screen_watch_start,screen_watch_stop,screen_watch_latestmcp_server.pybecomes a ~40-line orchestrator: creates theFastMCPinstance, callsregister_all(mcp)fromtools/__init__.pymcpobject,run()entry point, and all test imports are identicalDocs updated
docs/architecture.md— module map updated withtools/sub-package; test table expanded; "Three surfaces" description updateddocs/index.md— tool count corrected (8 → 9)docs/help/development.md— test table expanded withtest_audio.py,test_mcp_server.py,test_wsl.pyAGENTS.md— rule 8 updated to describe theregister(mcp)pattern and where to add new tools; build-order step 4 updated; definition of done tool count corrected (8 → 9)Test plan
pytest -v)fastmcp.Client— enable, status, capture (returns image+text), disable (safety gate confirmed), watch start/latest/stop, audio (env-gate confirmed)output_schema=Nonepreserved onscreen_captureandscreen_capture_audiofrom screensight.mcp_server import mcpstill works (no import path changes)