mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat: add a tool catalog and local MCP server
Define tools that answer questions from the app's data once, independent of the surface that exposes them. A tool declares its arguments and the services it reads; applications compose tools with their own services and optional call interceptors. Queries reuse the layers' portable source factories, so they run wherever an application routes /api requests. The first queries are get_earthquakes, get_active_fires and get_recent_launches, with a shared area argument (place name, bounding box, or point and radius) and capped lists. gods-eye-view/tools/mcp adapts a catalog to the Model Context Protocol with a small JSON-RPC handler and a stateless HTTP transport, adding no dependencies. npm run mcp serves Core's tools over stdio to local clients such as Claude Code, reading from a running app. Both exports are portable and checked by check:boundaries; the app does not import them.
This commit is contained in:
1 parent
e7707d9a0f
commit
c3dfa8e853
26 files changed
+1886
-3
No files matched your search
@@ -0,0 +1,49 @@
|
||||
/** Space queries: launches. */
|
||||
|
||||
import { defineTool, ToolError } from '../catalog.js';
|
||||
import { LIMIT_SCHEMA, capRows, countNoun } from '../results.js';
|
||||
|
||||
const text = (value) => (typeof value === 'string' && value ? value : null);
|
||||
|
||||
export const getRecentLaunches = defineTool({
|
||||
name: 'get_recent_launches',
|
||||
title: 'Recent launches',
|
||||
description:
|
||||
'Orbital launches from Launch Library 2 over the last 30 days, newest ' +
|
||||
'first, with provider, rocket, pad, mission and outcome.',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: { limit: LIMIT_SCHEMA },
|
||||
additionalProperties: false,
|
||||
},
|
||||
requires: ['launches'],
|
||||
async run(args, { services, signal }) {
|
||||
const payload = await services.launches.getLaunches({ signal });
|
||||
const launches = Array.isArray(payload) ? payload : payload.results;
|
||||
if (!Array.isArray(launches))
|
||||
throw new ToolError('malformed', 'The launch feed returned no launches');
|
||||
const rows = launches
|
||||
.map((launch) => ({
|
||||
id: text(launch?.id),
|
||||
name: text(launch?.name),
|
||||
time: text(launch?.net),
|
||||
status: text(launch?.status?.name),
|
||||
provider: text(launch?.launch_service_provider?.name),
|
||||
rocket: text(
|
||||
launch?.rocket?.configuration?.full_name ??
|
||||
launch?.rocket?.configuration?.name,
|
||||
),
|
||||
pad: text(launch?.pad?.name),
|
||||
location: text(launch?.pad?.location?.name),
|
||||
mission: text(launch?.mission?.name),
|
||||
orbit: text(launch?.mission?.orbit?.name),
|
||||
}))
|
||||
.filter((launch) => launch.name)
|
||||
.sort((a, b) => String(b.time).localeCompare(String(a.time)));
|
||||
const result = capRows(rows, args.limit);
|
||||
return {
|
||||
summary: `${countNoun(rows.length, 'launch', 'launches')} in the last 30 days${rows[0] ? `; latest ${rows[0].name}` : ''}.`,
|
||||
data: result,
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user