refactor: extract tool definitions into tools/ subpackage#111
Merged
Jeomon merged 1 commit intoCursorTouch:mainfrom Mar 17, 2026
Merged
Conversation
Move all 16 MCP tool definitions from __main__.py (~956 lines) into a dedicated tools/ subpackage. Each tool category gets its own module: tools/__init__.py - register_all() orchestrator tools/_snapshot_helpers.py - shared capture/response helpers tools/app.py - App (launch/resize/switch) tools/shell.py - PowerShell tools/filesystem.py - FileSystem (8 modes) tools/snapshot.py - Snapshot + Screenshot tools/input.py - Click, Type, Scroll, Move, Shortcut, Wait tools/scrape.py - Scrape (async, with LLM sampling) tools/multi.py - MultiSelect, MultiEdit tools/clipboard.py - Clipboard tools/process.py - Process tools/notification.py - Notification tools/registry.py - Registry Architecture: - Each module exports register(mcp, *, get_desktop, get_analytics) - get_desktop / get_analytics are zero-arg callables for lazy resolution - __main__.py becomes a thin entrypoint (~140 lines): imports, globals, lifespan, mcp creation, register_all() call, CLI - Backward-compatible re-exports (state_tool, screenshot_tool) preserved for existing test_snapshot_display_filter.py All existing tests pass (no regressions introduced).
Member
|
Thanks |
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
Refactors
__main__.pyby extracting all 16 MCP tool definitions into a dedicatedtools/subpackage, keeping__main__.pyas a thin entrypoint (~140 lines).This was promised in the PR #104 conversation as a follow-up improvement to organize the growing tool code.
Changes
New
tools/subpackage structuretools/__init__.pyregister_all()orchestratortools/_snapshot_helpers.pycapture_desktop_state()/build_snapshot_response()tools/app.pytools/shell.pytools/filesystem.pytools/snapshot.pytools/input.pytools/scrape.pytools/multi.pytools/clipboard.pytools/process.pytools/notification.pytools/registry.pyArchitecture
register(mcp, *, get_desktop, get_analytics)get_desktop/get_analyticsare zero-arg callables for lazy resolution (registration happens beforelifespaninitializes singletons)__main__.pythin entrypoint: imports, globals,lifespan(),mcpcreation,register_all()call, CLIstate_tool,screenshot_tool) preserved in__main__fortest_snapshot_display_filter.pyStats