mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat: show views as the live globe in MCP Apps clients
show_on_globe replaces open_in_gods_eye_view and names an MCP Apps view, a ui:// panel that loads the app in embed mode and posts each later view to it, so the globe in the conversation changes without reloading. It also takes a view another answer returned. Tools can declare a UI resource, and the MCP adapter serves resources/list and resources/read and lists each tool's resource in _meta.ui.resourceUri.
This commit is contained in:
1 parent
60c40865e9
commit
216a75ac71
17 files changed
+417
-41
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
GLOBE_PANEL_URI,
|
||||
MCP_APP_MIME_TYPE,
|
||||
createGlobePanelResource,
|
||||
} from './globePanel.js';
|
||||
import { composeCatalog, coreTools } from './index.js';
|
||||
|
||||
test('the globe panel is an MCP Apps resource that may frame only the app', () => {
|
||||
const resource = createGlobePanelResource({
|
||||
appUrl: 'http://localhost:5173/some/path',
|
||||
});
|
||||
assert.equal(resource.uri, GLOBE_PANEL_URI);
|
||||
assert.equal(resource.mimeType, MCP_APP_MIME_TYPE);
|
||||
assert.equal(MCP_APP_MIME_TYPE, 'text/html;profile=mcp-app');
|
||||
assert.deepEqual(resource._meta.ui.csp, {
|
||||
frameDomains: ['http://localhost:5173'],
|
||||
});
|
||||
assert.match(resource.text, /const APP_ORIGIN = "http:\/\/localhost:5173";/);
|
||||
assert.match(resource.text, /'ui\/initialize'/);
|
||||
assert.match(resource.text, /'ui\/notifications\/tool-result'/);
|
||||
assert.match(resource.text, /protocolVersion: "2026-01-26"/);
|
||||
});
|
||||
|
||||
test('show_on_globe names the panel and shows a view another answer returned', async () => {
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { app: { baseUrl: 'http://localhost:5173/' } },
|
||||
});
|
||||
assert.deepEqual(catalog.get('show_on_globe').ui, {
|
||||
resourceUri: GLOBE_PANEL_URI,
|
||||
});
|
||||
const earlier = {
|
||||
camera: {
|
||||
lat: 25,
|
||||
lon: 121,
|
||||
altitude_m: 300000,
|
||||
heading_deg: 0,
|
||||
pitch_deg: -90,
|
||||
},
|
||||
layers: ['ais-live-vessels'],
|
||||
style: null,
|
||||
map: null,
|
||||
follow: null,
|
||||
annotations: [],
|
||||
url: 'http://localhost:5173/#v=2',
|
||||
};
|
||||
const shown = await catalog.call('show_on_globe', {
|
||||
view: earlier,
|
||||
layers: ['ais-live-vessels', 'military'],
|
||||
style: 'thermal',
|
||||
});
|
||||
assert.deepEqual(shown.data.view.camera, earlier.camera);
|
||||
assert.deepEqual(shown.data.view.layers, ['ais-live-vessels', 'military']);
|
||||
assert.equal(shown.data.view.style, 'thermal');
|
||||
await assert.rejects(
|
||||
catalog.call('show_on_globe', { view: { camera: { lat: 'x' } } }),
|
||||
(error) => error.code === 'invalid_arguments',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user