Commit Graph

595 Commits (e617753b4e657d42a0e3a502e56e7c6bbdf3bb66)

Author SHA1 Message Date
dsarno bce6afaf24
Merge branch 'CoplayDev:main' into main 2025-09-29 20:01:54 -07:00
GitHub Actions 048b1252de chore: bump version to 4.1.0 2025-09-27 17:53:28 +00:00
Marcus Sanatan 5acf10769e
Standardize how we define MCP tools (#292)
* refactor: migrate command routing to use CommandRegistry lookup instead of switch statement

* style: improve code formatting and indentation consistency

* refactor: clean up imports and type hints across tool modules

* Revert "feat: Implement Asset Store Compliance for Unity MCP Bridge"

This reverts commit 2fca7fc3da.

* Revert "feat(asset-store): implement post-installation prompt system for Asset Store compliance"

This reverts commit ab25a71bc5.

* chore: upgrade mcp[cli] dependency from 1.4.1 to 1.15.0

* style: fix formatting and whitespace in Python server files

* Remove description, probably a Python versionn change

* feat: add type hints and parameter descriptions to Unity MCP tools

* docs: improve shader management tool parameter descriptions and types

* refactor: add type annotations and improve documentation for script management tools

* refactor: improve type annotations and documentation in manage_scene tool

* refactor: add type annotations and improve parameter descriptions across MCP tools

* feat: add explicit name parameters to all MCP tool decorators

* refactor: remove unused Unity connection instance in manage_asset_tools

* chore: update type hints in manage_editor function parameters for better clarity

* feat: make name and path parameters optional for scene management operations

* refactor: remove unused get_unity_connection import from manage_asset.py

* chore: rename Operation parameter annotation to Operations for consistency

* feat: add logging to MCP clients for tool actions across MCP server components

* chore: add FastMCP type hint to register_all_tools parameter

* style: reformat docstring in apply_text_edits tool to use multiline string syntax

* refactor: update type hints from Dict/List/Tuple/Optional to modern Python syntax

* refactor: clean up imports and add type annotations to script editing tools

* refactor: update type hints to use | None syntax for optional parameters

* Minor fixes

* docs: improve tool descriptions with clearer action explanations

* refactor: remove legacy update action migration code from manage_script.py

* style: replace em dashes with regular hyphens in tool descriptions [skip ci]

* refactor: convert manage_script_capabilities docstring to multiline format [skip ci]
2025-09-27 13:53:10 -04:00
Marcus Sanatan af4ddf1dd6 Revert "chore: bump version to 4.1.0"
This reverts commit e76a7565e8.
2025-09-27 13:51:27 -04:00
GitHub Actions e76a7565e8 chore: bump version to 4.1.0 2025-09-27 17:50:17 +00:00
Marcus Sanatan f50acf46b3
Revert asset store changes (#291)
* Revert "feat: Implement Asset Store Compliance for Unity MCP Bridge"

This reverts commit 2fca7fc3da.

* Revert "feat(asset-store): implement post-installation prompt system for Asset Store compliance"

This reverts commit ab25a71bc5.
2025-09-26 20:36:50 -04:00
GitHub Actions e3cc99c3ab chore: bump version to 4.0.0 2025-09-26 23:32:09 +00:00
Marcus Sanatan ac4eae926e
Open and close prefabs in the stage view + create them (#283)
* refactor: remove unused UnityEngine references from menu item classes

* Add new tools to manage a prefab, particularly, making them staged.

This might be enough, but it's possible we may have to extract some logic from ManageGameObject

* feat: add AssetPathUtility for asset path normalization and update references in ManageAsset and ManagePrefabs

* feat: add prefab management tools and register them with the MCP server

* feat: update prefab management commands to use 'prefabPath' and add 'create_from_gameobject' action

* fix: update parameter references to 'prefabPath' in ManagePrefabs and manage_prefabs tools

* fix: clarify error message for missing 'prefabPath' in create_from_gameobject command

* fix: ensure pull request triggers for unity tests workflow

* Revert "fix: ensure pull request triggers for unity tests workflow"

This reverts commit 10bfe54b5b7f3c449852b1bf1bb72f498289a1a0.

* Remove delayed execution of executing menu item, fixing #279
This brings the Unity window into focus but that seems to be a better UX for devs.
Also streamline manage_menu_item tool info, as FastMCP recommends

* docs: clarify menu item tool description with guidance to use list action first

* feat: add version update for server_version.txt in bump-version workflow

* fix: simplify error message for failed menu item execution
2025-09-26 19:28:56 -04:00
Marcus Sanatan 549ac1eb0c
Add Codex to autoconfig options (#288)
* feat: add Codex CLI client support with config.toml handling

* feat: add config helpers for managing Codex and MCP server configurations

* feat: add TOML array parsing support for multi-line and trailing comma formats

* fix: handle TOML inline comments in section headers during parsing

* fix: strip TOML comments before processing section headers

* fix: improve JSON parsing to handle escaped single quotes in config strings

* Use Tommy for TOML parsing

It's a single file and OSS, easy to integrate into Unity

* fix: patched Tommy’s literal-string handling so doubled single quotes inside literal strings are treated as embedded apostrophes instead of prematurely ending the value

* Don't overwrite MCP configs while testing

Seeing random JSON in my codex config was pretty annoying

* PR Feedback

* Keep Tommy compatible with Unity 2021

* Re-include Tommy's license

Probably a good habit to keep all 3rd party licenses and copyrights, even if they're also MIT licenses
2025-09-26 18:05:30 -04:00
许兴逸 da91f256a2
Replace command dispatcher with CommandRegistry, allow to add custom command handlers. (#261)
* Replace hard coded command dispatcher to command registry

* Bug fixed.

* bug fixed.

* bug fixed.

* Bug fixed.

* Fix tests.
2025-09-26 18:05:17 -04:00
Shutong Wu b57a3b8500
Change package requisite for Code Validation
Updated package installation instructions for NuGet to avoid compilation issue.
2025-09-24 00:24:01 -04:00
Shutong Wu 91849c7aa4 1 2025-09-23 14:45:26 -04:00
Shutong Wu df919e4812 Add Language: zh 中文 2025-09-23 14:41:29 -04:00
Justin Barnett 2fca7fc3da feat: Implement Asset Store Compliance for Unity MCP Bridge 2025-09-23 07:06:29 -04:00
Justin Barnett ab25a71bc5 feat(asset-store): implement post-installation prompt system for Asset Store compliance
Add comprehensive dependency detection system with cross-platform support:
- DependencyManager: Main orchestrator for dependency validation
- SetupWizard: Auto-trigger logic with InitializeOnLoad
- SetupWizardWindow: Complete EditorWindow implementation
- Platform detectors: Windows, macOS, Linux specific detection
- InstallationOrchestrator: Guided installation workflow

Asset Store compliance features:
- No bundled Python interpreter or UV package manager
- User-guided installation process with platform-specific instructions
- Clean package structure without large binary dependencies
- Fallback modes for incomplete installations
- Clear error messages with actionable guidance

Integration:
- Maintains backward compatibility with existing functionality
- Integrates with existing ServerInstaller and MCP infrastructure
- Adds menu items for manual setup wizard access and dependency checking
- Comprehensive error handling and user guidance
2025-09-23 06:51:48 -04:00
Alex Bagnolini 6e72b33309
Specify version for Microsoft.CodeAnalysis.CSharp package (#278) 2025-09-19 09:29:37 -04:00
Shutong Wu 94ad8dea50
Update Windows installation command for Astral UV
Current Windows command does not work on some machines such like mine. Copy and paste the command from Astral website to ensure the installation process go smoothly.
2025-09-17 23:50:15 -04:00
Jos Van der westhuizen 0c7945b36a add github repo stats 2025-09-14 11:30:24 -07:00
Jos Van der westhuizen 80b51f3e6a change telemetry endpoint to prod 2025-09-14 11:22:17 -07:00
David Sarno a940741bf1 CI: revert unity-tests.yml to upstream/main version 2025-09-12 11:33:53 -07:00
David Sarno 692d7199cb CI: Unity tests use serial/license again (restore UNITY_LICENSE) 2025-09-12 11:12:15 -07:00
David Sarno 8ee1f50001 CI: Unity tests use EBL only (drop UNITY_LICENSE) 2025-09-12 11:07:44 -07:00
David Sarno ee5db9285e CI: update unity-tests workflow 2025-09-12 11:03:18 -07:00
Marcus Sanatan b5e0446348
Allow the LLMs to read menu items, not just execute them (#263)
* Move the current test to a Tools folder

* feat: add env object and disabled flag handling for MCP client configuration

* Format manual config specially for Windsurf and Kiro

* refactor: extract config JSON building logic into dedicated ConfigJsonBuilder class

* refactor: extract unity node population logic into centralized helper method

* refactor: only add env property to config for Windsurf and Kiro clients

If it ain't broke with the other clients, don't fix...

* fix: write UTF-8 without BOM encoding for config files to avoid Windows compatibility issues

* fix: enforce UTF-8 encoding without BOM when writing files to disk

* refactor: replace execute_menu_item with enhanced manage_menu_item tool supporting list/exists/refresh

* Update meta files for older Unity versions

* test: add unit tests for menu item management and execution

* feat: add tips for paths, script compilation, and menu item usage in asset creation strategy

* Use McpLog functionality instead of Unity's Debug

* Add telemetry

* Annotate parameters

More info to LLMs + better validation

* Remove the refresh command

It's only ever useful in the context of listing menu items

* Updated meta files since running in Unity 2021

* Slightly better README

* fix: rename server-version.txt to server_version.txt and update menu item description
2025-09-12 11:19:58 -04:00
GitHub Actions 2a992117e2 chore: bump version to 3.4.0 2025-09-10 20:03:48 +00:00
dsarno 23fbdc81e3 chore(server): bump server_version.txt to 3.3.2 2025-09-10 13:03:01 -07:00
dsarno fe962114b9
Merge pull request #264 from CoplayDev/feat/telemetry
Added optional telemetry
2025-09-10 13:00:01 -07:00
dsarno 283597dc24 fix(startup): capture exception message before deferred telemetry lambda 2025-09-10 12:58:09 -07:00
dsarno 33979d348b telemetry: use Cloud Run default, reject localhost overrides, add startup diagnostics, and normalize logging
- config: point telemetry_endpoint to Cloud Run default

- telemetry: log effective endpoint/timeout; reject localhost endpoints

- server: telemetry logger at normal level with rotating file; default timeout=5s when unset
2025-09-10 11:57:43 -07:00
David Sarno 9b5488dcaf telemetry_decorator: guard record_tool_usage and milestone emits (sync/async) 2025-09-10 09:38:53 -07:00
David Sarno 9f7308b4c2 mcp-unity: telemetry fire-and-forget; safer sender reg; defer startup/conn telemetry; writer IO logs; manage_scene tolerant params; test worker wake 2025-09-10 09:24:09 -07:00
David Sarno 89714d022c telemetry: record sub_action for tool executions; decorator extracts 'action'; add tests for keyword/positional extraction 2025-09-10 08:52:38 -07:00
David Sarno 2fd74f5dab manage_scene: tolerant params + optional buildIndex; add writer IO logs; keep direct write path 2025-09-10 08:23:25 -07:00
David Sarno 397ba32a99 telemetry: fire-and-forget queue; remove context propagation; reduce timeouts; fix milestone lock reentrancy 2025-09-10 07:50:05 -07:00
David Sarno 46df7250b5 attempted ManageScene debugging for hang 2025-09-09 19:26:17 -07:00
David Sarno c1bde804d4 telemetry: main-thread routing + timeout for manage_scene; stderr + rotating file logs; Cloud Run endpoint in config; minor robustness in scene tool 2025-09-09 18:46:42 -07:00
David Sarno 1e003748d8 telemetry: bounded queue + single worker; INFO-level send logs; endpoint to Cloud Run; add unit test for backpressure 2025-09-09 18:45:09 -07:00
David Sarno bd55a56d1c MCP server: hardened startup + telemetry queue
- Logging to stderr with force; quiet httpx/urllib3
- Async lifespan fix; defer telemetry in first second
- Bounded telemetry queue with single worker
- Reduce initial Unity connect timeout to 1s
- Keep server_version in file
2025-09-09 12:14:00 -07:00
dsarno 9d17061452
Add Windows legacy server cleanup for %LOCALAPPDATA%\Programs\UnityMCP\UnityMcpServer (#272)
- Detect and clean up legacy server installations in LocalApplicationData
- Prevents accumulation of old server copies during package updates
- Improves cleanup of Windows-specific legacy installation paths
2025-09-09 10:18:22 -07:00
David Sarno ba45051a40 fix she descrip 2025-09-08 21:37:06 -07:00
David Sarno 2e907f189e tests: disable telemetry during pytest via conftest; lock milestone saves 2025-09-08 20:55:00 -07:00
David Sarno 2abca24e9d telemetry: pluggable Unity sender; add MCP_DISABLE_TELEMETRY; server reads version file; locks for milestones 2025-09-08 20:45:45 -07:00
David Sarno f6a5568865 telemetry: prefer config with env override; validate scheme; robust load\n\n- TelemetryConfig reads config.telemetry_enabled/endpoint, env can override\n- Validate endpoint scheme; revalidate on send\n- Split UUID/milestones load error handling\n- Add tests for config precedence, scheme validation, UUID preservation\n- validate_script: optional include_diagnostics with documented behavior 2025-09-08 20:37:38 -07:00
David Sarno 7f0527f708 chore: apply CodeRabbit suggestions
- README path separators (todo in separate doc commit)
- manage_gameobject: pop prefabFolder not prefab_folder
- execute_menu_item: make sync to avoid blocking event loop
- telemetry: validate endpoint scheme (allow http/https only) and re-validate at send time
2025-09-08 20:25:07 -07:00
David Sarno 979757e38a tests green: align SDK outputs + harden inputs\n\n- find_in_file: start/end positions with 1-based exclusive endCol\n- read_resource: metadata-only default + lengthBytes; selection returns text\n- read_console: strip stacktrace when include_stacktrace=false\n- validate_script: summary counts; get_sha: minimal fields\n- silence stdout in test_telemetry helper 2025-09-08 20:14:49 -07:00
David Sarno bbe4b07558 feat: improve telemetry and parameter validation
- Add server-side integer coercion for numeric parameters in all tools
- Fix parameter type validation issues (read_resource, find_in_file, read_console, manage_scene, manage_asset)
- Add proper tool descriptions with ctx parameter documentation
- Fix Context type annotations (use Context instead of Any for ctx)
- All tools now accept flexible numeric inputs (strings, floats) and coerce to integers
- Telemetry system working with all tool_execution events captured in BigQuery
- Remove invalid parameter type warnings from client-side validation
2025-09-08 20:06:04 -07:00
David Sarno f127024d01 telemetry: enable tool_execution across tools via strict, async-aware decorator; add endpoint env override + urllib fallback; enrich OS fields; fix TelemetryHelper invocation 2025-09-08 16:39:47 -07:00
David Sarno 81dcd69722 Merge commit '3e83f993bfe632034bf7302d4319e3cd16353eb8' into feat/telemetry
* commit '3e83f993bfe632034bf7302d4319e3cd16353eb8':
  Improved ci prompt testing suite (#270)
  chore: bump version to 3.3.2
  Fix: Unity Editor reload crash + debug-noise reduction (#266)
  Revise README for improved clarity and organization
  docs: install uv via official installer (curl/winget)
  Update README.md
  docs: fix Windows uv path to use WinGet shim, keep macOS AppSupport symlink path
  docs: update README.md with improved installation paths, documentation, and logo
  fix: Update README installation paths to match ServerInstaller.cs
2025-09-08 10:11:46 -07:00
dsarno 3e83f993bf
Improved ci prompt testing suite (#270)
* CI: streamline Unity licensing (ULF/EBL); drop cache mounts & EBL-in-container; NL suite: clarify T-E/T-J, anchor positions, EOF brace targeting, SHA preconditions

* CI: support both ULF + EBL; validate ULF before -manualLicenseFile; robust readiness wait; use game-ci @v2 actions

* CI: activate EBL via container using UNITY_IMAGE; fix readiness regex grouping

* CI: minimal patch — guard manualLicenseFile by ulf.ok, expand error patterns, keep return-license @v2 for linter

* CI: harden ULF staging (printf+chmod); pass ULF_OK via env; use manual_args array for -manualLicenseFile

* CI: assert EBL activation writes entitlement to host mount; fail fast if missing

* CI: use heredoc in wait step to avoid nested-quote issues; remove redundant EBL artifact copy; drop job-level if and unused UNITY_VERSION

* CI: harden wait step (container status check, broader ready patterns, longer timeout); make license return non-blocking

* CI: wait step — confirm bridge readiness via status JSON (unity_port) + host socket probe

* CI: YAML-safe readiness fallback (grep/sed unity_port + bash TCP probe); workflow_dispatch trigger + ASCII step names

* CI: refine license error pattern to ignore benign LicensingClient channel startup; only match true activation/return failures

* Improve Unity bridge wait logic in CI workflow

- Increase timeout from 600s to 900s for Unity startup
- Add 'bound' to readiness pattern to catch more bridge signals
- Refine error detection to focus only on license failures
- Remove non-license error patterns that could cause false failures
- Improve error reporting with descriptive messages
- Fix regex escaping for unity port parsing
- Fix case sensitivity in sed commands

* Add comprehensive Unity workflow improvements

- Add project warm-up step to pre-import Library before bridge startup
- Expand license mounts to capture full Unity config and local-share directories
- Update bridge container to use expanded directory mounts instead of narrow license paths
- Provide ULF licenses in both legacy and standard local-share paths
- Improve EBL activation to capture complete Unity authentication context
- Update verification logic to check full config directories for entitlements

These changes eliminate cold import delays during bridge startup and provide
Unity with all necessary authentication data, reducing edge cases and improving
overall workflow reliability.

* Refine Unity workflow licensing and permissions

- Make EBL verification conditional on ULF presence to allow ULF-only runs
- Remove read-only mounts from warm-up container for Unity user directories
- Align secrets gate with actual licensing requirements (remove UNITY_SERIAL only)
- Keep return-license action at v2 (latest available version)

These changes prevent workflow failures when EBL has issues but ULF is valid,
allow Unity to write preferences during warm-up, and ensure secrets detection
matches the actual licensing logic used by the workflow steps.

* fix workflow YAML parse

* Normalize NL/T JUnit names and robust summary

* Fix Python import syntax in workflow debug step

* Improve prompt clarity for XML test fragment format

- Add detailed XML format requirements with exact specifications
- Emphasize NO prologue, epilogue, code fences, or extra characters
- Add specific instructions for T-D and T-J tests to write fragments immediately
- Include exact XML template and TESTID requirements
- Should fix T-D and T-J test failures in CI by ensuring proper fragment format

* Fix problematic regex substitution in test name canonicalization

- Replace unsafe regex substitution that could create malformed names
- New approach: preserve correctly formatted names, extract titles safely
- Prevents edge cases where double processing could corrupt test names
- Uses proper em dash (—) separator consistently
- More robust handling of various input formats

* CI: NL/T hardening — enforce filename-derived IDs, robust backfill, single-testcase guard; tighten prompt emissions; disallow Bash

* fix: keep file ID when canonicalizing test names

* CI: move Unity Pro license return to teardown after stopping Unity; keep placeholder at original site

* CI: remove revert helper & baseline snapshot; stop creating scripts dir; prompt: standardize T-B validation to level=standard

* CI: remove mini workflow and obsolete NL prompts; redact email in all Unity log dumps

* NL/T prompt: enforce allowed ops, require per-test fragment emission (incl. failures), add T-F..T-J XML templates

* NL suite: enforce strict NL-4 emission; remove brittle relabeling; keep canonicalization + backfill

* NL/T: minimize transcript; tighten NL-4 console reads; add final errors scan in T-J

* ci: add local validate-nlt-coverage helper

* CI: add staged report fragment promotion step (reports/_staging -> reports/) to support multi-edit reporting

* CI: add staged report fragment promotion step (reports/_staging -> reports/) to support multi-edit reporting

* CI: minor polish and guardrails; keep staged reports promotion and placeholder detection

* read_console: default count=50; normalize types str->list; tolerate legacy payload shapes

* read_console: harden response parsing for legacy shapes (data as list, tuple entries)

* Docs: refresh CI workflow and prompts (remove mini suite refs; per-test emissions, staging, guard)

* CI: move T coverage check after staged promotion; accept _staging as present; dedupe promotion step

* CI: make T retry conditional on explicit coverage probe (not failure()); respect _staging in probe
2025-09-07 15:47:56 -07:00
GitHub Actions e219080576 chore: bump version to 3.3.2 2025-09-06 18:00:57 +00:00