Skip to content

Add foundational MCP unit test suite - #11643

Open
kitsupanic wants to merge 1 commit into
Facepunch:masterfrom
kitsupanic:mcp-tests
Open

Add foundational MCP unit test suite#11643
kitsupanic wants to merge 1 commit into
Facepunch:masterfrom
kitsupanic:mcp-tests

Conversation

@kitsupanic

Copy link
Copy Markdown

Summary

Foundational unit test suite for the MCP layer, 43 tests, no production changes.

Motivation & Context

Per #11641: tool schemas and binding behaviour are permanent public API for MCP clients and nothing would catch a regression. The harness was already wired (all test tiers reference Sandbox.Tools, InternalsVisibleTo already granted).

Fixes: #11641

Implementation Details

Tests live in Sandbox.Test.Engine (which builds EditorTypeLibrary and supports headless Scenes). A fixture [McpToolset] declared in the test assembly is what the suite exercises, keeping it independent of real editor tools. MainThread.Queue runs inline on a main-marked thread so full ToolRegistry.Invoke round-trips run synchronously.

Areas covered:

  • ToolRegistry schema generation (comma-string vector rule, optional-by-default params, Range→min/max, readOnlyHint)
  • Argument binding (unknown-arg suggestions, case-insensitivity, range clamping, json-in-string unwrapping)
  • McpResult serialization including GameObjectRef/ComponentRef collapse against a headless scene
  • Registry surface (toolset naming, duplicate-name skip)

Verified locally — 43/43 new tests pass and the full Sandbox.Test.Engine run (TestCategory!=LiveBackend, same filter CI uses) passes 1760/1760 with the suite present.

Honest limitation — addon-side scene tools remain untestable headless (SceneEditorSession's ctor creates a Qt dock), per the note in #11641.

Screenshots / Videos (if applicable)

None — this is a unit test suite.

Checklist

  • Code follows existing style and conventions
  • No unnecessary formatting or unrelated changes
  • Public APIs are documented (if applicable)
  • Unit tests added where applicable and all passing
  • I'm okay with this PR being rejected or requested to change 🙂

43 tests in Sandbox.Test.Engine covering ToolRegistry schema generation
(comma-string vector rule, optional-by-default params, Range to min/max,
readOnlyHint), argument binding (unknown-arg suggestions, case-insensitivity,
range clamping, json-in-string unwrapping), McpResult serialization including
GameObjectRef/ComponentRef collapse against a headless scene, and registry
surface (toolset naming, duplicate-name skip). Fixture toolset declared in
the test assembly; no production changes.
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.

Proposal: unit tests for the MCP layer (ToolRegistry schema/binding, McpResult)

1 participant