Skip to content

feat(mcp): add tunables and debug console tools (#466) - #707

Merged
houko merged 4 commits into
mainfrom
feat/mcp-tunables-console-466
Nov 24, 2026
Merged

houko merged 4 commits into
mainfrom
feat/mcp-tunables-console-466

Conversation

@houko

@houko houko commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add five MCP tools in packages/game/mcp/console.go wired through Config.Console, Config.ConsoleFunc and Bridge.SetConsole in packages/game/mcp/mcp.go:
    • game_tunables_list — deterministically lists registered debug.Console tunables (with optional prefix filter), type, current value, registration default, and numeric bounds.
    • game_tunable_get — reads one registered tunable's current value and metadata by name.
    • game_tunable_set — strictly type-checks and updates a registered tunable (float, int, bool or string), validates numeric ranges by default (or clamps when clamp: true), and returns both old_value and applied value.
    • game_console_commands_list — lists built-in and custom debug.Console commands with help text (with optional include_builtin).
    • game_console_exec — runs a console command string through debug.Console.Exec and returns {command, ok, output, lines, error}.
  • Add structured inspection and typed mutation methods (RegisterString, Tunables, Tunable, SetTunable, Commands) plus TunableInfo and CommandInfo to packages/game/debug with matching release-build stubs.
  • Add nsgotest + automation.Call tests (packages/game/mcp/console_test.go) verifying live tunable mutation affects simulation behavior, console command listing/execution, dynamic ConsoleFunc/SetConsole, and strict error handling.
  • Update docs/en/mcp.md and docs/zh/mcp.md, add changelog.d/mcp-tunables-console-466.md, and add .agents/notes/implemented/feature/2026-11-24-mcp-tunables-and-console.md.

Verification

  • git ls-files -z -- '*.go' | xargs -0 -r gofmt -l (empty)
  • (cd packages/game && env -u GOROOT go run ./cmd/gameschema -check)
  • (cd packages/game && env -u GOROOT go tool nsgo check -target macos,windows,linux,android,web)
  • (cd packages/game && env -u GOROOT go tool nsgo test ./mcp && env -u GOROOT go tool nsgo test ./debug && env -u GOROOT go tool nsgo test -run TestStabilityTable .)
  • (cd packages/game && env -u GOROOT go build -tags release ./debug ./mcp)
  • env -u GOROOT go run ./tools/changelog check
  • bun run verify-notes

Closes #466

@github-actions github-actions Bot added enhancement New feature or request size/XL documentation Improvements or additions to documentation pkg/debug area/agents conflict Conflicts with the target branch; resolve before merging labels Nov 24, 2026
RegisterString adds a persisted value kind, so the format section names it, its example carries a string tunable, and readTunables registers it so the example stays checked.
Console.SetTunable now takes a clamp flag and returns a TunableChange with the previous value and a snapshot taken under the same lock as the write, so game_tunable_set never clamps with bounds read before a tunable was re-registered. With clamp, an integer beyond int's range (such as 1e30) is clamped to the tunable's bound instead of failing with "overflows int". In release builds SetTunable returns an error rather than a nil error for a write that never happened.

mcp.TunableInfo is renamed TunableResult so it no longer shares a name with debug.TunableInfo. The acceptance test now attaches a game.Loop whose Update integrates the jump from the tunable pointers, starts the jump with game_console_exec and steps it with game_loop_step. New tests cover string tunables in SaveTunables/LoadTunables, a number refused for a string tunable with no other value applied, and clamping at int's limits.
@houko
houko force-pushed the feat/mcp-tunables-console-466 branch from a952974 to 94cdd36 Compare November 24, 2026 19:02
@houko
houko merged commit 1eaaa79 into main Nov 24, 2026
14 of 33 checks passed
@houko
houko deleted the feat/mcp-tunables-console-466 branch November 24, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents conflict Conflicts with the target branch; resolve before merging documentation Improvements or additions to documentation enhancement New feature or request pkg/debug pkg/game size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: tunables and console commands

1 participant