3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Answer a group name in scene_capabilities with its topics (#2055)
Nguyen Xuan An593e90257ac5
diff --git a/changes/2055.md b/changes/2055.mdnew file mode 100644index 00000000..0228e9ea--- /dev/null+++ b/changes/2055.md@@ -0,0 +1 @@+- `scene_capabilities` topic `schemas`, `scene` or `runtime` now answers with the topics that group holds instead of "Unknown topic", and the index no longer reads as if schemas were a topic (#2055)diff --git a/scripts/capabilities-topics.mjs b/scripts/capabilities-topics.mjsindex 5e1b3a13..639c607b 100644--- a/scripts/capabilities-topics.mjs+++ b/scripts/capabilities-topics.mjs@@ -180,20 +180,26 @@ class UnknownTopicError extends TopicEntryError {}}+const GROUP_NAMES = ['scene', 'runtime', 'schemas'];+function indexAnswer(capabilities, names) {return {format: capabilities.scene.format, schemaVersion: capabilities.scene.schemaVersion,phase: capabilities.phase, availableIn: capabilities.availableIn,- how: `Call scene_capabilities with topic set to a name below, or to a list of up to ${MAX_TOPICS_PER_CALL} names to read several at once. Tools list common fields; schemas names the full field list of a recipe part (meshEdit and meshStack also take <name>.<op>, geometries takes geometries.<type>). examples.<tool> is one complete call.`,+ how: `Call scene_capabilities with topic set to a name below, or to a list of up to ${MAX_TOPICS_PER_CALL} names to read several at once. Tools list common fields; each name in topics.schemas gives the full field list of a recipe part, and the group names scene, runtime and schemas list their topics (meshEdit and meshStack also take <name>.<op>, geometries takes geometries.<type>). examples.<tool> is one complete call.`,topics: names,};}function answerOneTopic(capabilities, topic, names, outlineSources) {const allNames = [...names.scene, ...names.runtime, ...names.schemas];+ // A group name is not a topic, but an agent that read the index asks for it: answer with the topics it holds.+ if (GROUP_NAMES.includes(topic) && !allNames.includes(topic)) {+ return { topic, value: { topics: names[topic], use: `${topic} is a group of topics; ask for one of its names, or ${topic}.<name>.` } };+ }const parts = topic.split('.');// The index groups topics under scene, runtime and schemas; a caller may repeat the group as a prefix (schemas.geometries).- if (['scene', 'runtime', 'schemas'].includes(parts[0]) && parts.length > 1) parts.shift();+ if (GROUP_NAMES.includes(parts[0]) && parts.length > 1) parts.shift();const [requestedName, branchName] = parts;const aliased = TOPIC_ALIASES[requestedName.toLowerCase()];const name = closestTopic(requestedName, allNames) ?? (allNames.includes(aliased) ? aliased : requestedName);diff --git a/tests/capabilities-group-topic.test.js b/tests/capabilities-group-topic.test.jsnew file mode 100644index 00000000..c0c6d31d--- /dev/null+++ b/tests/capabilities-group-topic.test.js@@ -0,0 +1,60 @@+import './support/load-agent-scene-modules.mjs';+import test from 'node:test';+import assert from 'node:assert/strict';+import { Client } from '@modelcontextprotocol/client';+import { InMemoryTransport } from '@modelcontextprotocol/server';+import { createAgentMcpServer } from '../scripts/mcp-server.mjs';+import { AGENT_SCENE_CAPABILITIES } from '../src/agent-scene.js';++// Issue 2055: the index lists a "schemas" group, and asking for topic schemas used to answer "Unknown topic schemas."++async function connectClient(context) {+ const runtime = {+ async capabilities() { return { scene: AGENT_SCENE_CAPABILITIES, phase: 'idle', availableIn: 'test' }; },+ async close() {},+ activeSessionId() { return null; },+ };+ const server = createAgentMcpServer(runtime);+ const client = new Client({ name: 'capabilities-group-topic-test', version: '1' });+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();+ await server.connect(serverTransport);+ await client.connect(clientTransport);+ context.after(async () => {+ await client.close();+ await server.close();+ });+ return client;+}++async function ask(client, topic) {+ return client.callTool({ name: 'scene_capabilities', arguments: { topic } });+}++test('the schemas group answers with the names of its topics', async context => {+ const client = await connectClient(context);+ const index = (await ask(client, undefined)).structuredContent;+ const answer = await ask(client, 'schemas');+ assert.notEqual(answer.isError, true, answer.content?.[0]?.text);+ assert.equal(answer.structuredContent.topic, 'schemas');+ assert.deepEqual(answer.structuredContent.value.topics, index.topics.schemas);+ assert.ok(answer.structuredContent.value.topics.includes('skin'));+});++test('the scene and runtime groups answer the same way, and a list may mix a group with a topic', async context => {+ const client = await connectClient(context);+ const index = (await ask(client, undefined)).structuredContent;+ for (const group of ['scene', 'runtime']) {+ const answer = await ask(client, group);+ assert.notEqual(answer.isError, true, answer.content?.[0]?.text);+ assert.deepEqual(answer.structuredContent.value.topics, index.topics[group]);+ }+ const mixed = await ask(client, ['schemas', 'skin']);+ assert.deepEqual(Object.keys(mixed.structuredContent.answers), ['schemas', 'skin']);+});++test('the index no longer reads as if schemas were a topic to ask for on its own', async context => {+ const client = await connectClient(context);+ const index = (await ask(client, undefined)).structuredContent;+ assert.doesNotMatch(index.how, /; schemas names the full field list/);+ assert.match(index.how, /each name in topics\.schemas gives the full field list/);+});