Skip to content

Commit 13bb092

Browse files
Refactor CLI entry point to dedicated module
Moved the command line interface logic from src/stata_mcp/__init__.py to src/stata_mcp/cli/_cli.py and updated pyproject.toml to reference the new entry point. Added authors metadata to pyproject.toml and created src/stata_mcp/cli/__init__.py to expose the CLI main function. Co-Authored-By: StataMCP-Team <[email protected]>
1 parent 8d7e7ec commit 13bb092

File tree

4 files changed

+75
-59
lines changed

4 files changed

+75
-59
lines changed

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "stata-mcp"
33
version = "1.6.1"
44
description = "Let LLM help you achieve your regression analysis with Stata"
55
readme = "README.md"
6+
authors = [
7+
{ name = "SongTan", email = "[email protected]" }
8+
]
69
requires-python = ">=3.11"
710
license = {text = "Apache-2.0"}
811
dependencies = [
@@ -15,7 +18,7 @@ dependencies = [
1518
]
1619

1720
[project.scripts]
18-
stata-mcp = "stata_mcp:main"
21+
stata-mcp = "stata_mcp.cli:main"
1922
webui = "stata_mcp.webui:main"
2023

2124
[build-system]

src/stata_mcp/__init__.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -689,63 +689,5 @@ def stata_do(dofile_path: str,
689689
}
690690

691691

692-
def main() -> None:
693-
"""Entry point for the command line interface."""
694-
parser = argparse.ArgumentParser(
695-
prog="stata-mcp",
696-
description="Stata-MCP command line interface",
697-
add_help=True)
698-
parser.add_argument(
699-
"-v",
700-
"--version",
701-
action="version",
702-
version=f"Stata-MCP version is {__version__}",
703-
help="show version information",
704-
)
705-
parser.add_argument(
706-
"--usable",
707-
action="store_true",
708-
help="check whether Stata-MCP could be used on this computer",
709-
)
710-
parser.add_argument(
711-
"--install",
712-
action="store_true",
713-
help="install Stata-MCP to Claude Desktop")
714-
parser.add_argument(
715-
"--webui",
716-
action="store_true",
717-
help="launch the configuration web UI",
718-
)
719-
720-
# mcp.run
721-
parser.add_argument(
722-
"-t",
723-
"--transport",
724-
choices=["stdio", "sse", "http", "streamable-http"],
725-
default=None,
726-
help="mcp server transport method (default: stdio)",
727-
)
728-
args = parser.parse_args()
729-
730-
if args.usable:
731-
sys.exit(usable())
732-
elif args.install:
733-
Installer(sys_os=sys.platform).install()
734-
elif args.webui:
735-
from .webui import main as webui_main
736-
webui_main()
737-
else:
738-
print("Starting Stata-MCP...")
739-
740-
# Use stdio if there is no transport argument
741-
transport = args.transport or "stdio"
742-
if transport == "http":
743-
transport = (
744-
"streamable-http" # Default to streamable-http for HTTP transport
745-
)
746-
mcp.run(transport=transport)
747-
748-
749692
if __name__ == "__main__":
750693
print(f"Hello Stata-MCP@version{__version__}")
751-
main()

src/stata_mcp/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from _cli import main as main

src/stata_mcp/cli/_cli.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (C) 2025 - Present Sepine Tam, Inc. All Rights Reserved
5+
#
6+
# @Author : Sepine Tam (谭淞)
7+
8+
# @File : _cli.py
9+
10+
import argparse
11+
import sys
12+
13+
from .. import Installer, __version__, mcp, usable
14+
15+
16+
def main() -> None:
17+
"""Entry point for the command line interface."""
18+
parser = argparse.ArgumentParser(
19+
prog="stata-mcp",
20+
description="Stata-MCP command line interface",
21+
add_help=True)
22+
parser.add_argument(
23+
"-v",
24+
"--version",
25+
action="version",
26+
version=f"Stata-MCP version is {__version__}",
27+
help="show version information",
28+
)
29+
parser.add_argument(
30+
"--usable",
31+
action="store_true",
32+
help="check whether Stata-MCP could be used on this computer",
33+
)
34+
parser.add_argument(
35+
"--install",
36+
action="store_true",
37+
help="install Stata-MCP to Claude Desktop")
38+
parser.add_argument(
39+
"--webui",
40+
action="store_true",
41+
help="launch the configuration web UI",
42+
)
43+
44+
# mcp.run
45+
parser.add_argument(
46+
"-t",
47+
"--transport",
48+
choices=["stdio", "sse", "http", "streamable-http"],
49+
default=None,
50+
help="mcp server transport method (default: stdio)",
51+
)
52+
args = parser.parse_args()
53+
54+
if args.usable:
55+
sys.exit(usable())
56+
elif args.install:
57+
Installer(sys_os=sys.platform).install()
58+
elif args.webui:
59+
from ..webui import main as webui_main
60+
webui_main()
61+
else:
62+
print("Starting Stata-MCP...")
63+
64+
# Use stdio if there is no transport argument
65+
transport = args.transport or "stdio"
66+
if transport == "http":
67+
transport = (
68+
"streamable-http" # Default to streamable-http for HTTP transport
69+
)
70+
mcp.run(transport=transport)

0 commit comments

Comments
 (0)