feat(files-mcp): mount at /files-mcp via MCP_SERVICES registry

- main.py: import files_app, append McpService entry to MCP_SERVICES.
  Lifespan already iterates the list, so no edit to the lifespan function.
- tests/conftest.py: autouse fixture rebinds files_mcp.core.path_guard._ROOT
  to a per-test tmp_path so the sandbox is fresh for every test.
- files_mcp/__init__.py: drop the try/except around the server import now
  that server.py exists, restoring fail-fast on a missing/corrupt server
  module in production. The _init_root() try/except stays, since pytest
  collection can import the package before FILES_MCP_ROOT is set.

Verified via uv run pytest: 327 tests pass, no regressions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-30 18:15:45 +08:00
co-authored by Claude Fable 5
parent 8c110329b2
commit c17a33152f
3 changed files with 29 additions and 7 deletions
+6 -7
View File
@@ -16,13 +16,12 @@ try:
except RuntimeError:
_ROOT = None
# Re-export the FastAPI app once the sandbox root has been initialized.
# server.py is created in a later task; importing it lazily keeps this
# package importable (and unit-testable) before that task lands.
try: # pragma: no cover - exercised once server.py exists
from files_mcp.server import app # noqa: E402
except ImportError:
app = None # type: ignore[assignment]
# Re-export the FastAPI app. server.py now exists, so this import is
# unconditional — a missing/corrupt server.py fails loud at import time
# (production-correct behavior). The sandbox root is only needed by the
# tool routes at request time, not at import, so this stays safe to import
# even when FILES_MCP_ROOT is unset (e.g. during pytest collection).
from files_mcp.server import app # noqa: E402
ROOT: Path | None = _ROOT