Skip to content

Commit 5017241

Browse files
authored
feat: CLI - agentstack self version should show remote server version when connected (#1728)
* docs: better description of connectors Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com> * feat: fetch server version in the CLI Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com> * feat: add active server to version command Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com> --------- Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com> Signed-off-by: Tomáš Weiss <tomas.weiss2@gmail.com>
1 parent ec30624 commit 5017241

4 files changed

Lines changed: 29 additions & 26 deletions

File tree

apps/agentstack-cli/src/agentstack_cli/api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2025 © BeeAI a Series of LF Projects, LLC
22
# SPDX-License-Identifier: Apache-2.0
33
import json
4+
import logging
45
import re
56
import urllib
67
import urllib.parse
@@ -12,6 +13,7 @@
1213

1314
import httpx
1415
import openai
16+
import pydantic
1517
from a2a.client import A2AClientHTTPError, Client, ClientConfig, ClientFactory
1618
from a2a.types import AgentCard
1719
from httpx import HTTPStatusError
@@ -20,6 +22,8 @@
2022
from agentstack_cli import configuration
2123
from agentstack_cli.configuration import Configuration
2224

25+
logger = logging.getLogger(__name__)
26+
2327
config = Configuration()
2428

2529
API_BASE_URL = "api/v1/"
@@ -102,6 +106,26 @@ async def api_stream(
102106
yield jsonlib.loads(re.sub("^data:", "", line).strip())
103107

104108

109+
async def fetch_server_version() -> str | None:
110+
"""Fetch server version from OpenAPI schema."""
111+
112+
class OpenAPIInfo(pydantic.BaseModel):
113+
version: str
114+
115+
class OpenAPISchema(pydantic.BaseModel):
116+
info: OpenAPIInfo
117+
118+
try:
119+
response = await api_request("GET", "openapi.json", use_auth=False)
120+
if not response:
121+
return None
122+
schema = OpenAPISchema.model_validate(response)
123+
return schema.info.version
124+
except Exception as e:
125+
logger.warning("Failed to fetch server version: %s", e)
126+
return None
127+
128+
105129
@asynccontextmanager
106130
async def a2a_client(agent_card: AgentCard, use_auth: bool = True) -> AsyncIterator[Client]:
107131
try:

apps/agentstack-cli/src/agentstack_cli/commands/platform/base_driver.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from textwrap import dedent
1111

1212
import anyio
13-
import pydantic
1413
import yaml
1514
from tenacity import AsyncRetrying, stop_after_attempt
1615

@@ -193,27 +192,3 @@ async def deploy(
193192
["k3s", "kubectl", "rollout", "restart", "deployment"],
194193
"Restarting deployments to load imported images",
195194
)
196-
197-
async def version(self) -> str | None:
198-
if (await self.status()) != "running":
199-
return None
200-
HelmStatus = typing.TypedDict("HelmStatus", {"status": str, "app_version": str})
201-
helm_status = pydantic.TypeAdapter(list[HelmStatus]).validate_json(
202-
(
203-
await self.run_in_vm(
204-
[
205-
"/usr/local/bin/helm",
206-
"--kubeconfig=/etc/rancher/k3s/k3s.yaml",
207-
"ls",
208-
"--namespace=default",
209-
"--filter=^agentstack$",
210-
"-o",
211-
"json",
212-
],
213-
"Getting Agent Stack platform version",
214-
)
215-
).stdout
216-
)
217-
if helm_status[0]["status"] != "deployed":
218-
return None
219-
return helm_status[0]["app_version"]

apps/agentstack-cli/src/agentstack_cli/commands/self.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from InquirerPy import inquirer
1616

1717
import agentstack_cli.commands.platform
18+
from agentstack_cli.api import fetch_server_version
1819
from agentstack_cli.async_typer import AsyncTyper
1920
from agentstack_cli.commands.model import setup as model_setup
2021
from agentstack_cli.configuration import Configuration
@@ -46,7 +47,8 @@ async def version(
4647
"""Print version of the Agent Stack CLI."""
4748
with verbosity(verbose=verbose):
4849
cli_version = importlib.metadata.version("agentstack-cli")
49-
platform_version = await agentstack_cli.commands.platform.get_driver().version()
50+
platform_version = await fetch_server_version()
51+
active_server = configuration.auth_manager.active_server
5052

5153
latest_cli_version: str | None = None
5254
with console.status("Checking for newer version...", spinner="dots"):
@@ -64,6 +66,7 @@ async def version(
6466
console.print(
6567
f"agentstack-platform version: [bold]{platform_version.replace('-', '') if platform_version is not None else 'not running'}[/bold]"
6668
)
69+
console.print(f" agentstack server: [bold]{active_server if active_server else 'none'}[/bold]")
6770
console.print()
6871

6972
if latest_cli_version and packaging.version.parse(latest_cli_version) > packaging.version.parse(cli_version):

docs/development/agent-integration/mcp.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ description: "Learn how Agent Stack helps with authentication when using MCP."
77

88
A connector is an MCP endpoint exposed by the Agent Stack that forwards MCP requests to a remote MCP server, acting as a proxy and handling authentication.
99

10+
1011
It allows users to set up a connection to a third-party service (like GitHub, Box etc.) and then exposes a local MCP server that can be consumed by agents. This architecture eliminates the need for user authentication in your agent code. The connector handles authentication with the third-party service on behalf of the authenticated user, and the MCP interface is properly scoped to that user's permissions and data.
1112

1213
Users can work with connectors in two ways via the Agent Stack UI:

0 commit comments

Comments
 (0)