Skip to content

Commit 2cf6608

Browse files
sakurachanclaude
andcommitted
Fix send_command return type annotation to include MCPResponse
The send_command method can return either dict[str, Any] or MCPResponse, but the return type annotation only declared dict[str, Any]. This causes type-checking inconsistencies when the method returns MCPResponse on line 279-284 (when Unity is reloading). Changes: - Update return type from `-> dict[str, Any]` to `-> dict[str, Any] | MCPResponse` - Applied to both Server/ and MCPForUnity/ versions - Ensures static type checkers recognize MCPResponse as valid return value Addresses CodeRabbit feedback: - #360 (comment) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 448be09 commit 2cf6608

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

MCPForUnity/UnityMcpServer~/src/unity_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def receive_full_response(self, sock, buffer_size=config.buffer_size) -> bytes:
225225
logger.error(f"Error during receive: {str(e)}")
226226
raise
227227

228-
def send_command(self, command_type: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
228+
def send_command(self, command_type: str, params: dict[str, Any] | None = None) -> dict[str, Any] | MCPResponse:
229229
"""Send a command with retry/backoff and port rediscovery. Pings only when requested."""
230230
# Defensive guard: catch empty/placeholder invocations early
231231
if not command_type:

Server/unity_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def receive_full_response(self, sock, buffer_size=config.buffer_size) -> bytes:
225225
logger.error(f"Error during receive: {str(e)}")
226226
raise
227227

228-
def send_command(self, command_type: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
228+
def send_command(self, command_type: str, params: dict[str, Any] | None = None) -> dict[str, Any] | MCPResponse:
229229
"""Send a command with retry/backoff and port rediscovery. Pings only when requested."""
230230
# Defensive guard: catch empty/placeholder invocations early
231231
if not command_type:

0 commit comments

Comments
 (0)