Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Test that the documented MCP tool count matches tools/list

Nguyen Xuan An8250c5ac0b32
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6e925f7..66aed99d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Unreleased
+- Add a test that fails when the MCP tool count in `docs/guide.md`, `docs/mcp.md`, `index.html` or `scripts/smoke-mcp.mjs` differs from the `tools/list` result (issue #180). The server registers 22 tools; the 23rd `register(` in the file is the function definition, so the documented count was right.
- A renderer no longer draws its shadow map a second time on the first frame when the frame has no assembly; the constructor already drew it. On `mountain-valley` that removes 9.72 million shadow triangles from the first frame, with identical pictures (issue #171). `node bench/reference/profile-scene.mjs <scene>` prints where a scene's time goes, and `frame-time.mjs --plain` measures scenes that are too large for the light bake.
- Tell an agent when its scene is a closed room with no bake (issue #163). `scene_inspect` now returns a `closed-room-without-bake` diagnostic when 90 percent or more of 48 rays from the middle of the scene hit a front face, and names `bake`; measured against Cycles a closed room goes from 0.1430 and 0.1436 (`dark-shaft`, `temple-hall`) to 0.0609 and 0.0560 once baked. No frame cost and no schema change; agent scene entry grows 884 bytes gzip. `bakeSkyVisibility` in `light-bake` writes only the occlusion map (0.1021 and 0.0856 in under a second) and is not applied automatically. **A closed room without a bake now shows a warning in `scene_inspect`.**
- Clean up docs, media and scripts. Remove stale logs, six unreferenced PNG previews (about 6.1 MB) with their render sidecars, the OpenAI skill metadata and ten scripts that aimed at harness pages that no longer exist. Update the roadmap, the mesh and verification docs and the contributing guide, point the links to unshipped docs at GitHub, and add `npm run check:links`, `smoke:modeling`, `smoke:material-maps` and `benchmark:mesh-query`.
diff --git a/tests/mcp-tool-count.test.js b/tests/mcp-tool-count.test.js
new file mode 100644
index 00000000..db7a9c93
--- /dev/null
+++ b/tests/mcp-tool-count.test.js
@@ -0,0 +1,45 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import { Client } from '@modelcontextprotocol/client';
+import { InMemoryTransport } from '@modelcontextprotocol/server';
+import { createAgentMcpServer } from '../scripts/mcp-server.mjs';
+
+const numberWords = new Map([
+ ['twenty-one', 21], ['twenty-two', 22], ['twenty-three', 23], ['twenty-four', 24],
+ ['twenty-five', 25], ['twenty-six', 26], ['twenty-seven', 27], ['twenty-eight', 28],
+ ['thirty', 30],
+]);
+
+async function listedToolCount() {
+ const server = createAgentMcpServer({ async close() {} });
+ const client = new Client({ name: '67js-tool-count-test', version: '1' });
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
+ await server.connect(serverTransport);
+ await client.connect(clientTransport);
+ const { tools } = await client.listTools();
+ await client.close();
+ await server.close();
+ return tools.length;
+}
+
+async function countStatedIn(file, pattern) {
+ const text = await readFile(new URL(`../${file}`, import.meta.url), 'utf8');
+ const match = text.match(pattern);
+ assert.ok(match, `${file} no longer states the MCP tool count`);
+ const stated = match[1].toLowerCase();
+ return numberWords.get(stated) ?? Number(stated);
+}
+
+test('documented MCP tool counts match the protocol listing', async () => {
+ const listed = await listedToolCount();
+ const statements = {
+ 'docs/guide.md': /([\w-]+) tools for authoring/,
+ 'docs/mcp.md': /Lists all (\d+) tools/,
+ 'index.html': /(\d+) MCP tools/,
+ 'scripts/smoke-mcp.mjs': /listing\.tools\.length, (\d+)\)/,
+ };
+ for (const [file, pattern] of Object.entries(statements)) {
+ assert.equal(await countStatedIn(file, pattern), listed, `${file} states a different tool count than tools/list`);
+ }
+});