Skip to content

Commit 6c00294

Browse files
committed
feat: add tomli dependency and dynamic version lookup from pyproject.toml for legacy project
1 parent 2d8e251 commit 6c00294

File tree

3 files changed

+466
-129
lines changed

3 files changed

+466
-129
lines changed

UnityMcpBridge/UnityMcpServer~/src/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ version = "4.1.1"
44
description = "MCP for Unity Server: A Unity package for Unity Editor integration via the Model Context Protocol (MCP)."
55
readme = "README.md"
66
requires-python = ">=3.10"
7-
dependencies = ["httpx>=0.27.2", "mcp[cli]>=1.15.0"]
7+
dependencies = [
8+
"httpx>=0.27.2",
9+
"mcp[cli]>=1.15.0",
10+
"tomli>=2.3.0",
11+
]
812

913
[build-system]
1014
requires = ["setuptools>=64.0.0", "wheel"]

UnityMcpBridge/UnityMcpServer~/src/telemetry.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,28 @@
2424
from urllib.parse import urlparse
2525
import uuid
2626

27+
import tomli
28+
2729
try:
2830
import httpx
2931
HAS_HTTPX = True
3032
except ImportError:
3133
httpx = None # type: ignore
3234
HAS_HTTPX = False
3335

36+
37+
def get_package_version() -> str:
38+
"""
39+
Open pyproject.toml and parse version
40+
We use the tomli library instead of tomllib to support Python 3.10
41+
"""
42+
with open("pyproject.toml", "rb") as f:
43+
data = tomli.load(f)
44+
return data["project"]["version"]
45+
46+
47+
MCP_VERSION = get_package_version()
48+
3449
logger = logging.getLogger("unity-mcp-telemetry")
3550

3651

@@ -328,7 +343,7 @@ def _send_telemetry(self, record: TelemetryRecord):
328343
"customer_uuid": record.customer_uuid,
329344
"session_id": record.session_id,
330345
"data": enriched_data,
331-
"version": "3.0.2", # Unity MCP version
346+
"version": MCP_VERSION,
332347
"platform": _platform,
333348
"source": _source,
334349
}

0 commit comments

Comments
 (0)