Commit f2c57ca
authored
Add testing and move menu items to resources (#316)
* deps: add tomli>=2.3.0 dependency to UnityMcpServer package
* feat: dynamically fetch package version from pyproject.toml for telemetry
* Add pydantic
* feat: add resource registry for MCP resource auto-discovery
* feat: add telemetry decorator for tracking MCP resource usage
* feat: add auto-discovery and registration system for MCP resources
* feat: add resource registration to MCP server initialization
* feat: add MCPResponse model class for standardized API responses
* refactor: replace Debug.Log calls with McpLog wrapper for consistent logging
* feat: add test discovery endpoints for Unity Test Framework integration
We haven't connected them as yet, still thinking about how to do this neatly
* Fix server setup
* refactor: reduce log verbosity by changing individual resource/tool registration logs to debug level
* chore: bump mcp[cli] dependency from 1.15.0 to 1.17.0
* refactor: remove Context parameter and add uri keyword argument in resource decorator
The Context parameter doesn't work on our version of FastMCP
* chore: upgrade Python base image to 3.13 and simplify Dockerfile setup
* fix: apply telemetry decorator before mcp.tool to ensure proper wrapping order
* fix: swap order of telemetry and resource decorators to properly wrap handlers
* fix: update log prefixes for consistency in logging methods
* Fix compile errors
* feat: extend command registry to support both tools and resources
* Run get tests as a coroutine because it doesn't return results immediately
This works but it spams logs like crazy, maybe there's a better/simpler way
* refactor: migrate from coroutines to async/await for test retrieval and command execution
* feat: add optional error field to MCPResponse model
* Increased timeout because loading tests can take some time
* Make message optional so error responses that only have success and error don't cause Pydantic errors
* Set max_retries to 5
This connection module needs a lookover. The retries should be an exponential backoff and we could structure why it's failing so much
* Use pydantic model to structure the error output
* fix: initialize data field in GetTestsResponse to avoid potential errors
* Don't return path parameter
* feat: add Unity test runner execution with structured results and Python bindings
* refactor: simplify GetTests by removing mode filtering and related parsing logic
* refactor: move test runner functionality into dedicated service interface
* feat: add resource retrieval telemetry tracking with new record type and helper function
* fix: convert tool functions to async and await ctx.info calls
* refactor: reorganize menu item functionality into separate execute and get commands
An MCP resource for retrieval, and a simple command to execute. Because it's a resource, it's easier for the user to see what's in the menu items
* refactor: rename manage_menu_item to execute_menu_item and update tool examples to use async/await
We'll eventually put a section for resources
* Revert "fix: convert tool functions to async and await ctx.info calls"
This reverts commit 012ea6b.
* fix: replace tomllib with tomli for Python 3.10 compatibility in telemetry module
* Remove confusing comment
* refactor: improve error handling and simplify test retrieval logic in GetTests commands
* No cache by default
* docs: remove redundant comment for HandleCommand method in ExecuteMenuItem1 parent 5ad5b4a commit f2c57ca
File tree
54 files changed
+2052
-546
lines changed- MCPForUnity
- Editor
- Helpers
- Resources
- MenuItems
- Tests
- Services
- Tools
- MenuItems
- UnityMcpServer~/src
- registry
- resources
- tools
- TestProjects/UnityMCPTests/Assets/Tests/EditMode
- Resources
- Tools
- MenuItems
- docs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
54 files changed
+2052
-546
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
22 | 41 | | |
23 | 42 | | |
24 | 43 | | |
| |||
28 | 47 | | |
29 | 48 | | |
30 | 49 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
| |||
45 | 57 | | |
46 | 58 | | |
47 | 59 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 60 | + | |
52 | 61 | | |
53 | 62 | | |
54 | 63 | | |
| |||
96 | 105 | | |
97 | 106 | | |
98 | 107 | | |
99 | | - | |
| 108 | + | |
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
| |||
297 | 306 | | |
298 | 307 | | |
299 | 308 | | |
300 | | - | |
| 309 | + | |
301 | 310 | | |
302 | 311 | | |
303 | 312 | | |
| |||
383 | 392 | | |
384 | 393 | | |
385 | 394 | | |
386 | | - | |
| 395 | + | |
387 | 396 | | |
388 | 397 | | |
389 | 398 | | |
| |||
403 | 412 | | |
404 | 413 | | |
405 | 414 | | |
406 | | - | |
| 415 | + | |
407 | 416 | | |
408 | 417 | | |
409 | 418 | | |
| |||
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
440 | | - | |
| 449 | + | |
441 | 450 | | |
442 | 451 | | |
443 | 452 | | |
| |||
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
468 | | - | |
| 477 | + | |
469 | 478 | | |
470 | 479 | | |
471 | 480 | | |
| |||
504 | 513 | | |
505 | 514 | | |
506 | 515 | | |
507 | | - | |
| 516 | + | |
508 | 517 | | |
509 | 518 | | |
510 | 519 | | |
| |||
524 | 533 | | |
525 | 534 | | |
526 | 535 | | |
527 | | - | |
| 536 | + | |
528 | 537 | | |
529 | 538 | | |
530 | 539 | | |
| |||
544 | 553 | | |
545 | 554 | | |
546 | 555 | | |
547 | | - | |
| 556 | + | |
548 | 557 | | |
549 | 558 | | |
550 | 559 | | |
551 | | - | |
| 560 | + | |
552 | 561 | | |
553 | 562 | | |
554 | 563 | | |
| |||
564 | 573 | | |
565 | 574 | | |
566 | 575 | | |
567 | | - | |
| 576 | + | |
568 | 577 | | |
569 | 578 | | |
570 | 579 | | |
| |||
585 | 594 | | |
586 | 595 | | |
587 | 596 | | |
588 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
589 | 603 | | |
590 | 604 | | |
591 | 605 | | |
| |||
623 | 637 | | |
624 | 638 | | |
625 | 639 | | |
626 | | - | |
| 640 | + | |
627 | 641 | | |
628 | 642 | | |
629 | 643 | | |
| |||
662 | 676 | | |
663 | 677 | | |
664 | 678 | | |
665 | | - | |
| 679 | + | |
666 | 680 | | |
667 | 681 | | |
668 | 682 | | |
669 | | - | |
| 683 | + | |
670 | 684 | | |
671 | 685 | | |
672 | 686 | | |
| |||
817 | 831 | | |
818 | 832 | | |
819 | 833 | | |
820 | | - | |
| 834 | + | |
821 | 835 | | |
822 | 836 | | |
823 | | - | |
824 | | - | |
825 | | - | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
826 | 845 | | |
827 | 846 | | |
828 | 847 | | |
829 | 848 | | |
830 | 849 | | |
831 | | - | |
832 | | - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
833 | 853 | | |
834 | 854 | | |
835 | 855 | | |
| |||
894 | 914 | | |
895 | 915 | | |
896 | 916 | | |
897 | | - | |
898 | | - | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
899 | 947 | | |
900 | 948 | | |
901 | 949 | | |
902 | 950 | | |
903 | | - | |
| 951 | + | |
904 | 952 | | |
905 | 953 | | |
906 | 954 | | |
| |||
915 | 963 | | |
916 | 964 | | |
917 | 965 | | |
918 | | - | |
| 966 | + | |
919 | 967 | | |
920 | 968 | | |
921 | 969 | | |
| |||
1051 | 1099 | | |
1052 | 1100 | | |
1053 | 1101 | | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
| 1102 | + | |
1057 | 1103 | | |
1058 | 1104 | | |
1059 | 1105 | | |
| |||
1074 | 1120 | | |
1075 | 1121 | | |
1076 | 1122 | | |
1077 | | - | |
| 1123 | + | |
1078 | 1124 | | |
1079 | 1125 | | |
1080 | 1126 | | |
1081 | | - | |
| 1127 | + | |
1082 | 1128 | | |
1083 | 1129 | | |
1084 | 1130 | | |
| |||
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments