refactor(server): decorate the weather, airport and transport MCP tools

Three of the four remaining hand-written registrars are gone. The tools keep
their names, descriptions, input schemas, annotations and result shapes; the
registration-time scope gates (`if (canWeather)`, `if (canGeo)`,
`if (!canWrite(scopes, 'reservations')) return`) become declarative access
markers, resolved by trekMcpAccessPolicy like every other decorated domain.

get_weather / get_detailed_weather move into a new WeatherMcp over the injected
WeatherService, including the catch that answers with the upstream message and
isError rather than throwing - a client sees "Weather service not available."
instead of a transport failure when the provider is down.

search_airports / get_airport move into a new AirportsMcp with no injected
service at all: the airport table is a static dataset. AirportsService owns the
flight-endpoint backfill against the database, which neither tool touches.

create/update/delete_transport move into ReservationsMcp rather than a domain of
their own, because a transport IS a reservation - same table, same service, same
reservation_edit permission - and that class already injects everything they
needed from the four bridges the registrar was importing.

That was budget.bridge's last outside-container consumer, so
linkBudgetItemToReservation is pruned with it; the file is down to one export and
dies as soon as BudgetMcp stops needing AuthService.

journey.ts stays: it still reaches into services/journeyService, which cannot
fold until memories does.
This commit is contained in:
Maurice
2026-08-08 14:28:45 +02:00
committed by Maurice
parent 790dd3b728
commit cacab0795f
11 changed files with 372 additions and 352 deletions
@@ -408,10 +408,11 @@ describe('rebaseTripCurrency', () => {
});
describe('budget.bridge delegation', () => {
// The listBudgetItems / rebaseTripCurrency / removeUserFromBudgetItems bridge
// exports were pruned when their last outside-container consumers (legacy
// tripService, the trips MCP registrar, services/userCleanupService) migrated
// — 015/016/017 pin the same behavior on the service.
// Every bridge export except removeUserFromBudgetItems has been pruned as its
// last outside-container consumer migrated (legacy tripService, the trips MCP
// registrar, services/userCleanupService, and the create_transport registrar,
// which moved into reservations.mcp.ts). 015-018 pin the same behavior on the
// service.
it('BUDGET-SVC-DB-015: listBudgetItems returns the hydrated list', () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
@@ -447,14 +448,14 @@ describe('budget.bridge delegation', () => {
expect(row).toEqual({ currency: 'EUR', exchange_rate: RATES.RUB.EUR });
});
it('BUDGET-SVC-DB-018: linkBudgetItemToReservation stamps the reservation id through the bridge', () => {
it('BUDGET-SVC-DB-018: linkBudgetItemToReservation stamps the reservation id', () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
const reservationId = Number(testDb
.prepare("INSERT INTO reservations (trip_id, title, type) VALUES (?, 'Flight', 'flight')")
.run(trip.id).lastInsertRowid);
const item = bridge.linkBudgetItemToReservation(trip.id, reservationId, { name: 'Flight', total_price: 200 });
const item = budget.linkBudgetItemToReservation(trip.id, reservationId, { name: 'Flight', total_price: 200 });
expect(item.reservation_id).toBe(reservationId);
const row = testDb.prepare('SELECT reservation_id FROM budget_items WHERE id = ?').get(item.id) as { reservation_id: number | null };