Split the monolithic syncthing_mcp.py into a proper src/syncthing_mcp/ package with focused modules: client, models, registry, server, and tool submodules (system, folders, devices, config, instances). New tools: browse_folder, file_info, folder_need (file-level queries), override_folder, revert_folder (conflict resolution), check_upgrade (system management). Bumps tool count from 30 to 36. Adds comprehensive test suite (96 tests) using pytest + respx for HTTP mocking, covering client methods, registry logic, model validation, and all tool functions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
791 B
Python
30 lines
791 B
Python
"""FastMCP server creation and lifespan."""
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
|
|
from syncthing_mcp.registry import get_all_instances
|
|
|
|
|
|
@asynccontextmanager
|
|
async def app_lifespan(app):
|
|
import sys
|
|
|
|
instances = get_all_instances()
|
|
missing = [n for n, c in instances.items() if not c.api_key]
|
|
if missing:
|
|
print(f"WARNING: API key missing for instance(s): {missing}", file=sys.stderr)
|
|
print(
|
|
f"Syncthing MCP: {len(instances)} instance(s) configured — "
|
|
f"{list(instances.keys())}",
|
|
file=sys.stderr,
|
|
)
|
|
yield {}
|
|
|
|
|
|
mcp = FastMCP("syncthing_mcp", lifespan=app_lifespan)
|
|
|
|
# Import all tool modules so they register with `mcp` via decorators.
|
|
import syncthing_mcp.tools # noqa: E402, F401
|