mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
fix(mcp): report package version in standalone mcp/ server too
semantica/mcp_server/__init__.py was fixed to stop hardcoding 0.4.0, but the separate top-level mcp/ package (run via `python -m mcp.server`, documented in mcp/__init__.py as a supported way to configure Claude Desktop/Windsurf/etc. from a source checkout) still hardcoded 0.4.0 in three places: mcp/__init__.py, mcp/server.py, and mcp/resources/registry.py. Reuses semantica.__version__ directly, matching the pattern just adopted in semantica/mcp_server/__init__.py, so both implementations stay in sync with the package version going forward.
This commit is contained in:
+6
-2
@@ -21,7 +21,11 @@ Configure in Claude Desktop, Windsurf, Cline, Continue, VS Code:
|
||||
}
|
||||
"""
|
||||
|
||||
# `semantica.__version__` is the authoritative package version — see
|
||||
# semantica/mcp_server/__init__.py for why it is used directly rather than
|
||||
# importlib.metadata.version("semantica").
|
||||
from semantica import __version__
|
||||
|
||||
from .server import SemanticaMCPServer, main
|
||||
|
||||
__all__ = ["SemanticaMCPServer", "main"]
|
||||
__version__ = "0.4.0"
|
||||
__all__ = ["SemanticaMCPServer", "main", "__version__"]
|
||||
|
||||
@@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
|
||||
from mcp import __version__
|
||||
from mcp.session import get_graph
|
||||
|
||||
log = logging.getLogger("semantica.mcp.resources")
|
||||
@@ -60,7 +61,7 @@ def _read_decisions_list(uri: str) -> dict:
|
||||
|
||||
def _read_schema_info(uri: str) -> dict:
|
||||
info = {
|
||||
"version": "0.4.0",
|
||||
"version": __version__,
|
||||
"node_types": [
|
||||
"Entity", "decision", "Decision", "Event", "Concept",
|
||||
"Person", "Organisation", "Location",
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ import logging
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
from mcp import __version__
|
||||
from mcp.resources import RESOURCE_DEFINITIONS, handle_resource_read
|
||||
from mcp.tools import TOOL_DEFINITIONS
|
||||
|
||||
@@ -63,7 +64,7 @@ def _handle_initialize(req_id: Any, params: dict) -> dict:
|
||||
},
|
||||
"serverInfo": {
|
||||
"name": "semantica-mcp",
|
||||
"version": "0.4.0",
|
||||
"version": __version__,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Regression tests for version reporting in the top-level `mcp` package
|
||||
(issue #863).
|
||||
|
||||
Covers the same stale-version bug as `test_mcp_server_version.py` for the
|
||||
standalone `mcp/` server (run via `python -m mcp.server`), which is a
|
||||
separate implementation from `semantica.mcp_server` and was not covered
|
||||
by that fix. `semantica.__version__` is the authoritative package
|
||||
version (see semantica/mcp_server/__init__.py), so all three surfaces
|
||||
are asserted against it directly.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
import mcp
|
||||
import semantica
|
||||
from mcp.resources.registry import _read_schema_info
|
||||
from mcp.server import _handle_initialize
|
||||
|
||||
_EXPECTED = semantica.__version__
|
||||
|
||||
|
||||
class TestMCPPackageVersion(unittest.TestCase):
|
||||
def test_package_version_matches_authoritative_source(self):
|
||||
self.assertEqual(mcp.__version__, _EXPECTED)
|
||||
|
||||
def test_package_version_is_not_stale_literal(self):
|
||||
self.assertNotEqual(mcp.__version__, "0.4.0")
|
||||
|
||||
def test_initialize_server_info_version_matches_package(self):
|
||||
response = _handle_initialize(1, {})
|
||||
self.assertEqual(response["result"]["serverInfo"]["version"], _EXPECTED)
|
||||
|
||||
def test_initialize_server_info_version_is_not_stale_literal(self):
|
||||
response = _handle_initialize(1, {})
|
||||
self.assertNotEqual(response["result"]["serverInfo"]["version"], "0.4.0")
|
||||
|
||||
def test_schema_info_resource_version_matches_package(self):
|
||||
resource = _read_schema_info("semantica://schema/info")
|
||||
info = json.loads(resource["text"])
|
||||
self.assertEqual(info["version"], _EXPECTED)
|
||||
|
||||
def test_schema_info_resource_version_is_not_stale_literal(self):
|
||||
resource = _read_schema_info("semantica://schema/info")
|
||||
info = json.loads(resource["text"])
|
||||
self.assertNotEqual(info["version"], "0.4.0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user