File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""github-codemunch-mcp - Token-efficient MCP server for GitHub source code exploration."""
22
3- __version__ = "0.1.0"
3+ from importlib .metadata import PackageNotFoundError , version
4+
5+ try :
6+ __version__ = version ("jcodemunch-mcp" )
7+ except PackageNotFoundError :
8+ __version__ = "unknown"
Original file line number Diff line number Diff line change 1111from mcp .server import Server
1212from mcp .types import Tool , TextContent
1313
14+ from . import __version__
1415from .tools .index_repo import index_repo
1516from .tools .index_folder import index_folder
1617from .tools .list_repos import list_repos
@@ -387,6 +388,12 @@ def main(argv: Optional[list[str]] = None):
387388 prog = "jcodemunch-mcp" ,
388389 description = "Run the jCodeMunch MCP stdio server." ,
389390 )
391+ parser .add_argument (
392+ "-V" ,
393+ "--version" ,
394+ action = "version" ,
395+ version = f"%(prog)s { __version__ } " ,
396+ )
390397 parser .add_argument (
391398 "--log-level" ,
392399 default = os .environ .get ("JCODEMUNCH_LOG_LEVEL" , "WARNING" ),
Original file line number Diff line number Diff line change @@ -14,3 +14,13 @@ def test_main_help_exits_without_starting_server(capsys):
1414 out = capsys .readouterr ().out
1515 assert "jcodemunch-mcp" in out
1616 assert "Run the jCodeMunch MCP stdio server" in out
17+
18+
19+ def test_main_version_exits_with_version (capsys ):
20+ """`--version` should print package version and exit cleanly."""
21+ with pytest .raises (SystemExit ) as exc :
22+ main (["--version" ])
23+
24+ assert exc .value .code == 0
25+ out = capsys .readouterr ().out .strip ()
26+ assert out .startswith ("jcodemunch-mcp " )
You can’t perform that action at this time.
0 commit comments