Files
gods-eye-view/server/mcp/services.js
T
Sameh Khamis 85fee59da1 feat: add public camera and radio tools
Add find_cctv_cameras, get_cctv_snapshot and find_radio_stations. A
snapshot returns the camera's current frame as image content with its
credit. Tool results may now carry base64 images, which the MCP adapter
sends as image content.
2026-10-01 12:11:00 -07:00

52 lines
1.9 KiB
JavaScript

/**
* Local composition of tool services: the portable source factories, pointed
* at a running God's Eye View server's `/api` routes.
*/
import { createCctvSource } from '../../src/layers/cctv/source.js';
import { createUsgsEarthquakeSource } from '../../src/layers/earthquakes/source.js';
import { createFirmsSource } from '../../src/layers/firms/source.js';
import { createLaunchSource } from '../../src/layers/launches/source.js';
import { createRadioSource } from '../../src/layers/radio/source.js';
import { createSatelliteSource } from '../../src/layers/satellites/source.js';
import {
createAdsbLolSource,
createOpenSkySource,
} from '../../src/sources/live/standalone.js';
import { createGeocodePlaceService } from '../../src/tools/places.js';
export const DEFAULT_API_BASE = 'http://localhost:4173';
/** Resolve the sources' relative `/api/...` requests against `apiBase`. */
export function createApiFetch({
apiBase = DEFAULT_API_BASE,
fetchImpl = (...args) => globalThis.fetch(...args),
} = {}) {
const base = new URL(apiBase);
if (!['http:', 'https:'].includes(base.protocol))
throw new TypeError(`apiBase must be an http(s) URL: ${apiBase}`);
return (input, init) =>
fetchImpl(
typeof input === 'string' && input.startsWith('/')
? new URL(input, base)
: input,
init,
);
}
/** Construct every service Core's tools read, backed by the local server. */
export function createLocalToolServices(options = {}) {
const fetchImpl = createApiFetch(options);
return {
earthquakes: createUsgsEarthquakeSource({ fetchImpl }),
fires: createFirmsSource({ fetchImpl }),
launches: createLaunchSource({ fetchImpl }),
aircraft: createOpenSkySource({ fetchImpl }),
military: createAdsbLolSource({ fetchImpl }),
satellites: createSatelliteSource({ fetchImpl }),
cctv: createCctvSource({ fetchImpl }),
radio: createRadioSource({ fetchImpl }),
places: createGeocodePlaceService({ fetchImpl }),
};
}