Repository navigation
fix(cli): return JSON-RPC errors instead of crashing on malformed input - #366
Merged
Merged
Conversation
- Use cliArgs for strict flag parsing (mistyped flags now fail with usage) - Reject non-object JSON-RPC messages with -32600 (scalar, null, array) - Wrap handle() in try/catch to return -32603 on internal errors - Clamp search_assets limit to documented 1..100 range - Extract line handling to processLine() for testability Fixes TMHSDigital#341
TMHSDigital
added a commit
that referenced
this pull request
Dec 4, 2026
Resolves the overlap with #366 in site/cli/mcp.mjs and applies the review changes for both: - mcp.mjs main(argv) parses the argv it is given in strict mode, so `fgda mcp --data x` works and a mistyped flag stops with the usage line. - The line handler is the exported replyTo(), with tests for bad JSON, non-object messages, a throwing tool call and the 1 to 100 limit (#341). - The run guard in fgda.mjs and mcp.mjs compares real paths, so the CLI runs through the symlink npm makes for a package bin. Without this the npx command these docs give did nothing on Linux and macOS (#334). - Restores the indentation of one line touched in #363. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Owner
|
Merged in 84c9d56, thanks. Three changes on our side while landing it with #364: the line handler is now the exported replyTo(), with tests for bad JSON, non-object messages, a throwing tool call and the limit clamp; main() parses the argv it is given, so it also works when started as |
This was referenced Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #341 - MCP server now returns JSON-RPC errors instead of crashing on malformed input.
Changes
Strict flag parsing: Uses (Node's parseArgs in strict mode) so mistyped flags (e.g. ) fail with exit code 2 and a usage message instead of being silently ignored.
Non-object message rejection: The line handler now validates that the parsed JSON is a plain object. Scalars (, ), arrays (JSON-RPC batch), and other non-objects get a reply and the server keeps running.
Internal error handling: is wrapped in try/catch. Any exception (e.g. a throwing tool call) produces a reply instead of crashing the server process.
Limit clamping: parameter is clamped to the documented 1..100 range.
Testability: Line processing extracted to for easier testing.
Testing
All existing tests pass (
checks.test ok: 277 assertions across 34 checks
lib.test ok: 1882 assertions in 79 sections,
lint ok: 73 scripts parse, no unused imports
checks.test ok: 277 assertions across 34 checks
lib.test ok: 1882 assertions in 79 sections
validate ok: 467 entries, 467 ids, 9 stacks, no broken links
coverage:
2d 72
3d 80
animation 18
audio 43
characters 31
environment 20
fonts 25
shaders-vfx 18
tools 140
video 20
license_spdx 346/467 (74.1%)
publisher 384/467 (82.2%)
55 of 284 tags (19%) are used by one entry: 10x10, 12x12, 8-directional, alicevision, amiga, anim-graph, architecture, asset-browser, atmosphere, auto-rig, autotile, bake-out, canvas-item, clothing, color-clash, cooking, cozy, crouch-slide, exr, farming, fingers, flowmaps, foley, game-sfx, gameplay-programming, gta-format, importer, kinect, kufi, latent-actions, lidar-derived, low-vision, milky-way, multilingual, multithreading, mvs, naskh, netherlands, nintendo-64, pan-cjk, pets, power-tools, rpg-maker, save-system, sentinel, skybox, soft-body, spatial, splitter, steamworks, substance, threejs, ui-strings, vi-like, vintage
check-added ok: 467 entries, no added date later than its first commit
Built 467 entries → site/dist (399 active, 423 commercial-ok, 21 per-file)
Prerendered 464 entry rows into index.html; wrote 467 entry pages, 9 stack pages, 10 category pages, 6 alternatives pages, 15 guide pages, sitemap.xml, robots.txt, 404.html, freshness/index.html
389 of 1649 output files changed; 2.8s). Manual verification:
All CI checks pass (
lint ok: 73 scripts parse, no unused imports
checks.test ok: 277 assertions across 34 checks
lib.test ok: 1882 assertions in 79 sections
validate ok: 467 entries, 467 ids, 9 stacks, no broken links
coverage:
2d 72
3d 80
animation 18
audio 43
characters 31
environment 20
fonts 25
shaders-vfx 18
tools 140
video 20
license_spdx 346/467 (74.1%)
publisher 384/467 (82.2%)
55 of 284 tags (19%) are used by one entry: 10x10, 12x12, 8-directional, alicevision, amiga, anim-graph, architecture, asset-browser, atmosphere, auto-rig, autotile, bake-out, canvas-item, clothing, color-clash, cooking, cozy, crouch-slide, exr, farming, fingers, flowmaps, foley, game-sfx, gameplay-programming, gta-format, importer, kinect, kufi, latent-actions, lidar-derived, low-vision, milky-way, multilingual, multithreading, mvs, naskh, netherlands, nintendo-64, pan-cjk, pets, power-tools, rpg-maker, save-system, sentinel, skybox, soft-body, spatial, splitter, steamworks, substance, threejs, ui-strings, vi-like, vintage
check-added ok: 467 entries, no added date later than its first commit
Built 467 entries → site/dist (399 active, 423 commercial-ok, 21 per-file)
Prerendered 464 entry rows into index.html; wrote 467 entry pages, 9 stack pages, 10 category pages, 6 alternatives pages, 15 guide pages, sitemap.xml, robots.txt, 404.html, freshness/index.html
389 of 1649 output files changed; 2.8s).
AI note
This patch was written with AI assistance; every check listed above was run in the environment where the patch was built.
Fixes #341