Skip to content

Cut the tool descriptions by 45% and add a token-saving README tip - #18

Open
asbis wants to merge 2 commits into
claude/issues-13-14from
claude/lean-tool-descriptions
Open

asbis wants to merge 2 commits into
claude/issues-13-14from
claude/lean-tool-descriptions

Conversation

@asbis

@asbis asbis commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Stacked on #16 (part of the unreleased 1.30.1). Follows up on the token discussion in #13 and #16.

Why

Claude Code loads MCP tools on demand. Codex, Cursor and Mistral Vibe put the whole tools/list in context at the start of every session, whether or not it does any CAD. ShapeItUp's was 49 KB, about 12k tokens.

What changed

tools/list: 49,150 → 27,016 characters (−45%, ~12.3k → ~7k tokens).

before after
Tool descriptions (source) 16,834 chars 6,377
Parameter descriptions (source) 21,478 chars 8,272
Largest tool (render_preview) 5,091 chars 2,503

How the descriptions were rewritten:

  • Every description now covers what the tool does, when to pick it over a sibling, its defaults, and its traps (mutually exclusive params, workingDir for ./ imports, expectedContacts, persist precedence, the MuJoCo opt-in).
  • Removed: implementation history and internals (bundle cache, tessellation, sanitizer notes), and one path-resolution paragraph that was repeated in twelve places.
  • Applied by source span from a TypeScript-parser extraction. Only the 137 description strings changed (29 tools + 108 params); no schema, name or handler did, and a round-trip check confirmed every string landed where intended.

Descriptions that contradicted the code:

  • render_preview: cameraAngle arrays and grid promised a multi-angle collage. The handler uses them only for the summary text; every render is the 4-pane view.
  • export_shape's openIn said it needs VS Code. It uses the server's own app detection.
  • preview_shape's inline claimed to match render_preview's default. They're opposite (true vs false).
  • check_collisions pointed at get_api_reference('verification'), which doesn't exist.

Nothing is clipped any more. Three descriptions were over the sanitizer's 1,000-character limit and lost their endings for every client: preview_shape, check_collisions and run_simulation. The last one lost the paragraph on its MuJoCo engine.

New tests in schema-sanitizer.test.ts, using the real tools/list handler:

  • the total stays under 30,000 characters;
  • no description is clipped.

Both fail on the previous descriptions (expected 49150 to be less than 30000; ['preview_shape', 'run_simulation', 'check_collisions']).

README: "Fewer tools, fewer tokens". It shows how to switch off the 14 tools most sessions never call (~2.8k tokens):

  • Vibe: top-level disabled_tools with shapeitup_* names, placed above [[mcp_servers]], with a note on why not enabled_tools.
  • Codex: per-server disabled_tools.
  • Cursor: per-tool switches in Settings → MCP.

The npm README links to it.

Test plan

  • pnpm lint, pnpm build, pnpm test: 65 files, 1233 tests
  • Re-extracted every description after the rewrite: all 137 match the intended text
  • New budget and no-clipping tests fail on the old tools.ts and pass on the new one
  • Built server end to end (isolated HOME): Manifold threads render, open_viewer serves assets, a Rapier simulation runs
  • Codex disabled_tools placement and naming checked against OpenAI's MCP docs; Vibe's against its README

🤖 Generated with Claude Code

Codex, Cursor and Mistral Vibe load the whole tools/list at the start
of every session. It was 49 KB (~12k tokens); it is now 27 KB (~7k).
Each tool and parameter description keeps what it does, when to use
it and its defaults. Gone: history, internals, and one path-resolution
paragraph repeated twelve times. Rewritten by source span from a
TypeScript-parser extraction, so only description strings changed.

Fixes descriptions that contradicted the code: render_preview's
cameraAngle/grid (every render is the 4-pane view), export_shape's
openIn (works without VS Code), preview_shape's inline default, and
check_collisions' pointer to a category that doesn't exist. Nothing is
clipped by the sanitizer's 1,000-char limit any more; three were,
run_simulation's MuJoCo paragraph among them.

Tests keep tools/list under 30,000 chars and fail if the sanitizer ever
has to clip a description (both fail on the previous descriptions).

README: "Fewer tools, fewer tokens" shows disabled_tools for Vibe and
Codex, and Cursor's per-tool switches, for the 14 tools most sessions
never call (~2.8k tokens).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
shapeitup-landing Ready Ready Preview Oct 13, 2026 9:19pm UTC

martinrieder added a commit to martinrieder/ShapeItUp that referenced this pull request Oct 14, 2026
CONTRIBUTING.md's 'Adding a New MCP Tool' checklist requires a new tool
to be documented in getApiReference() — verify_design was registered
without its entry. This adds a 'verification' category covering the
acceptance-gate toolset:

- verify_design as the anchor: the one-call battery (render, collisions,
  simulation, export), skip flags, the render-failure short-circuit
- the surrounding gates: check_collisions (exact intersect vs the
  battery's AABB prefilter), sweep_check, run_simulation's author-
  declared assertions, validate_joints, describe_geometry/
  preview_finder
- the author-declared vs tool-driven distinction: expectedContacts and
  sim.assertions travel with the design file; call-time args merge with
  file-declared rules

Also updates the category listing in get_api_reference's no-arg response.

Conflict analysis vs open upstream PRs: PR asbis#16's tools.ts hunks touch
executeWithPersistedParams, registrations, and the examples category
content — not the category list or the refs map. PR asbis#18 edits only
description strings in registrations that predate verify_design. Both
trial-merge cleanly. The SKILL.md table row (the other checklist item)
is deliberately NOT done: PR asbis#16 deletes the entire tool table, so the
correct post-asbis#16 contribution is a prose line in its verification
cluster, not a row that would conflict.

Tests: 2 new (category exists, documents the gate toolset and the
author-declared concept). Suite 1264 total; pnpm lint and pnpm build
clean.

Co-authored-by: martinrieder <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 0cbf95f8 Deployed Oct 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant