Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/mcp_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@
os.environ.setdefault("CHUK_LLM_OPENAI_TOOL_COMPATIBILITY", "true")
os.environ.setdefault("CHUK_LLM_UNIVERSAL_TOOLS", "true")

__version__ = "1.0.0"
from importlib.metadata import version as _pkg_version, PackageNotFoundError
try:
__version__ = _pkg_version("mcp-cli")
except PackageNotFoundError:
__version__ = "0.0.0-dev"
__all__ = ["__version__"]
7 changes: 3 additions & 4 deletions src/mcp_cli/apps/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@
DEFAULT_HTTP_REQUEST_TIMEOUT,
)

from mcp_cli.config import APP_VERSION

if TYPE_CHECKING:
from mcp_cli.tools.manager import ToolManager

logger = logging.getLogger(__name__)

# Version injected into the host page
_MCP_CLI_VERSION = "0.13"

# Strict regex for CSP source values — reject anything that could break out
# of an HTML attribute or inject additional directives.
_SAFE_CSP_SOURCE = re.compile(r"^[a-zA-Z0-9\-.:/*]+$")
Expand Down Expand Up @@ -288,7 +287,7 @@ async def _start_server(
tool_name=safe_tool_name,
port=app_info.port,
csp_attr=csp_attr,
mcp_cli_version=_MCP_CLI_VERSION,
mcp_cli_version=APP_VERSION,
init_timeout=DEFAULT_APP_INIT_TIMEOUT,
)
host_page_bytes = host_page.encode("utf-8")
Expand Down
17 changes: 16 additions & 1 deletion src/mcp_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
restore_terminal,
)
from chuk_term.ui.theme import set_theme
from mcp_cli.config import process_options
from mcp_cli.config import process_options, APP_VERSION
from mcp_cli.context import initialize_context

# ──────────────────────────────────────────────────────────────────────────────
Expand All @@ -55,12 +55,27 @@
app = typer.Typer(add_completion=False)


# ──────────────────────────────────────────────────────────────────────────────
# Version callback
# ──────────────────────────────────────────────────────────────────────────────
def _version_callback(value: bool) -> None:
if value:
typer.echo(f"mcp-cli {APP_VERSION}")
raise typer.Exit()


# ──────────────────────────────────────────────────────────────────────────────
# Default callback that handles no-subcommand case
# ──────────────────────────────────────────────────────────────────────────────
@app.callback(invoke_without_command=True)
def main_callback(
ctx: typer.Context,
version: bool = typer.Option(
None, "--version", "-V",
callback=_version_callback,
is_eager=True,
help="Show version and exit.",
),
config_file: str = typer.Option(
"server_config.json", help="Configuration file path"
),
Expand Down
Loading