Skip to content

refactor: extract tool definitions into tools/ subpackage#111

Merged
Jeomon merged 1 commit intoCursorTouch:mainfrom
yasuhirofujii-medley:refactor/tools-subpackage
Mar 17, 2026
Merged

refactor: extract tool definitions into tools/ subpackage#111
Jeomon merged 1 commit intoCursorTouch:mainfrom
yasuhirofujii-medley:refactor/tools-subpackage

Conversation

@yasuhirofujii-medley
Copy link
Copy Markdown

Summary

Refactors __main__.py by extracting all 16 MCP tool definitions into a dedicated tools/ subpackage, keeping __main__.py as 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 structure

Module Tools
tools/__init__.py register_all() orchestrator
tools/_snapshot_helpers.py Shared capture_desktop_state() / build_snapshot_response()
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 (registration happens before lifespan initializes singletons)
  • __main__.py thin entrypoint: imports, globals, lifespan(), mcp creation, register_all() call, CLI
  • Backward-compatible re-exports (state_tool, screenshot_tool) preserved in __main__ for test_snapshot_display_filter.py

Stats

  • 14 files changed, 999 insertions(+), 824 deletions(-)
  • All existing tests pass (no regressions)

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).
@Jeomon Jeomon merged commit 4e56e34 into CursorTouch:main Mar 17, 2026
@Jeomon
Copy link
Copy Markdown
Member

Jeomon commented Mar 17, 2026

Thanks

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