Skip to content

refactor: split mcp_server.py into tools/ sub-package by domain - #72

Merged
himanshu231204 merged 1 commit into
mainfrom
refactor/mcp-tools-subpackage
Aug 31, 2026
Merged

himanshu231204 merged 1 commit into
mainfrom
refactor/mcp-tools-subpackage

Conversation

@himanshu231204

@himanshu231204 himanshu231204 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • mcp_server.py was a 309-line flat file with all 9 MCP tools inline, making it hard to navigate, test, or extend without scrolling through unrelated code
  • Split into a tools/ sub-package — one module per domain, each with a register(mcp) function:
    • tools/control.pyscreen_enable, screen_disable, screen_status
    • tools/screen.pyscreen_capture, screen_list_displays
    • tools/audio.pyscreen_capture_audio (includes _Audio fallback)
    • tools/watch.pyscreen_watch_start, screen_watch_stop, screen_watch_latest
  • mcp_server.py becomes a ~40-line orchestrator: creates the FastMCP instance, calls register_all(mcp) from tools/__init__.py
  • No external contracts changed — mcp object, run() entry point, and all test imports are identical

Docs updated

  • docs/architecture.md — module map updated with tools/ sub-package; test table expanded; "Three surfaces" description updated
  • docs/index.md — tool count corrected (8 → 9)
  • docs/help/development.md — test table expanded with test_audio.py, test_mcp_server.py, test_wsl.py
  • AGENTS.md — rule 8 updated to describe the register(mcp) pattern and where to add new tools; build-order step 4 updated; definition of done tool count corrected (8 → 9)

Test plan

  • 58/58 tests pass (pytest -v)
  • End-to-end: all 9 tools exercised via fastmcp.Client — enable, status, capture (returns image+text), disable (safety gate confirmed), watch start/latest/stop, audio (env-gate confirmed)
  • output_schema=None preserved on screen_capture and screen_capture_audio
  • from screensight.mcp_server import mcp still works (no import path changes)

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
Copilot AI lite review requested due to automatic review settings August 31, 2026 18:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@himanshu231204
himanshu231204 merged commit 8db7fcc into main Aug 31, 2026
12 checks passed
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.

3 participants