mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 14:06:27 +00:00
ae3ba18b9e
Fold the 1612-line services/atlasService.ts into the DI-native AtlasService: the stats aggregation, visited countries/regions with the #1490 tombstone and cascade logic, and the bucket-list CRUD become methods over the injected DatabaseService. The ~750-line pure-geo half — the bundled admin0/admin1 boundary stores with their #1576 streaming builders, the point-in-polygon indexes, Nominatim geocoding with its shared throttle, and every module-scoped cache including the import-time unref'd cleanup interval — moves verbatim to the plain module atlas-geo.ts so the caches stay process-global across the container instance, the bridge instance and test helpers (assetPath re-anchored one directory deeper, the only non-verbatim line). The 10-tool mcp/tools/atlas.ts registrar plus all four atlas resources in mcp/resources.ts move onto the decorator registry as atlas.mcp.ts — the when: atlas-addon gate is parity here (legacy tools and resources both gated; the REST controller deliberately does not). resources.test.ts retires with its last two cases, which move to tools-atlas-expanded.test.ts. The plugin RPC host swaps its 9 atlas imports for the injected AtlasService (23rd constructor dep); a minimal 2-export atlas.bridge.ts serves the one legacy consumer, authService.getTravelStats, and dies when authService migrates. Adopts atlas.dto.ts over the existing shared schemas and clears all three AtlasController entries from body-contract-allow-list.ts: the hand-rolled 'name and country_code are required' 400 becomes the ZodValidationPipe envelope (todo/places trade) while the whitespace-only bucket name keeps its legacy 'Name is required' trim guard. Fixes the verified defects the relocation had faithfully carried, each with a regression test (ATLAS-SVC-031..036 plus two MCP casing cases): the four multi-statement mark/unmark writes now run in db.transaction() (the region cascade nests as a savepoint), the trip-less countryPlaces early return honours manually_marked, the '|| null' bindings that dropped lat/lng 0 and empty-string notes on bucket update become '?? null', the mutating bucket SQL is user-scoped, and the MCP region/country-places tools uppercase their codes to match REST. Quirks deliberately preserved: the detached GET-path place_regions backfill writes, getStats' two divergent return shapes, the import-time cache-cleanup interval, getCountryFromAddress's unvalidated bare 2-letter codes, and the whitespace-only-name silent no-op on bucket update. Tests move with their case IDs: atlasService.test.ts becomes unit/nest/atlas.service.test.ts (pure-geo imports from atlas-geo, DB calls through the constructed service, plus bridge-delegation cases), the atlas e2e converts to the DI-native pattern (real SQL against the full temp-db schema), and the plugin-host path mock becomes a constructor stub.
68 lines
3.3 KiB
TypeScript
68 lines
3.3 KiB
TypeScript
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
import { registerJourneyTools } from './tools/journey';
|
|
import { registerMapsWeatherTools } from './tools/mapsWeather';
|
|
import { registerNotificationTools } from './tools/notifications';
|
|
import { registerTransportTools } from './tools/transports';
|
|
import { registerMcpPrompts } from './tools/prompts';
|
|
import { getMcpRegistry } from './registry-handoff';
|
|
|
|
export function registerTools(server: McpServer, userId: number, scopes: string[] | null, isStaticToken = false, getDeprecationNotice: () => string | null = () => null): void {
|
|
// The trip tools moved to the DI-discovered src/nest/trips/trips.mcp.ts and
|
|
// the share-link tools to src/nest/share/share.mcp.ts (@McpController,
|
|
// attached via the nest-mcp registry below — getDeprecationNotice rides the
|
|
// attach ctx).
|
|
|
|
// The place tools moved to the DI-discovered src/nest/places/places.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The collection tools moved to the DI-discovered src/nest/collections/
|
|
// collections.mcp.ts (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The budget tools moved to the DI-discovered src/nest/budget/budget.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The packing tools moved to the DI-discovered src/nest/packing/packing.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The reservation tools moved to the DI-discovered src/nest/reservations/
|
|
// reservations.mcp.ts (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The day + accommodation tools moved to the DI-discovered src/nest/days/
|
|
// days.mcp.ts (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The assignment tools moved to the DI-discovered src/nest/assignments/
|
|
// assignments.mcp.ts (@McpController, attached via the nest-mcp registry below).
|
|
|
|
registerMapsWeatherTools(server, userId, scopes);
|
|
|
|
registerNotificationTools(server, userId, scopes);
|
|
|
|
// The atlas tools moved to the DI-discovered src/nest/atlas/atlas.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The collab tools moved to the DI-discovered src/nest/collab/collab.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
registerTransportTools(server, userId, scopes);
|
|
|
|
// The transit tools moved to the DI-discovered src/nest/transit/transit.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
registerJourneyTools(server, userId, scopes);
|
|
|
|
// The vacay tools moved to the DI-discovered src/nest/vacay/vacay.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
// The todo tools moved to the DI-discovered src/nest/todo/todo.mcp.ts
|
|
// (@McpController, attached via the nest-mcp registry below).
|
|
|
|
registerMcpPrompts(server, userId, isStaticToken);
|
|
|
|
// Decorator-registered domains (@trek/nest-mcp) — migrating off the legacy
|
|
// registrar fan-out above, one domain at a time. Unset registry (direct
|
|
// callers without a Nest app, e.g. unit tests) ⇒ skip; the test harness
|
|
// attaches its own via createTestRegistry + setMcpRegistry.
|
|
const registry = getMcpRegistry();
|
|
if (registry) registry.attach(server, { userId, scopes, isStaticToken, getDeprecationNotice });
|
|
}
|