check_update
Verifies if a new version of the JVLink server is available and checks for pending updates.
Instructions
サーバーの最新バージョンを確認する。アップデートがあるか確認します。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/jvlink_mcp_server/server.py:695-701 (handler)The MCP tool handler for 'check_update'. It calls check_for_updates() from updater module and returns the result dict or an error message if network fails.
@mcp.tool() def check_update() -> dict: """サーバーの最新バージョンを確認する。アップデートがあるか確認します。""" info = check_for_updates() if info is None: return {"error": "アップデートの確認に失敗しました。ネットワーク接続を確認してください。"} return info - src/jvlink_mcp_server/server.py:695-701 (registration)The tool is registered as an MCP tool via the @mcp.tool() decorator on line 695.
@mcp.tool() def check_update() -> dict: """サーバーの最新バージョンを確認する。アップデートがあるか確認します。""" info = check_for_updates() if info is None: return {"error": "アップデートの確認に失敗しました。ネットワーク接続を確認してください。"} return info - The core helper function check_for_updates() that queries the GitHub API for the latest release, compares versions, and returns update info.
def check_for_updates() -> Optional[dict]: """Check GitHub for latest release. Returns dict with latest_version, current_version, update_available, html_url or None on failure. """ import urllib.request import urllib.error current = get_current_version() # Try releases/latest first try: url = f"{GITHUB_API_URL}/releases/latest" req = urllib.request.Request( url, headers={"Accept": "application/vnd.github.v3+json", "User-Agent": GITHUB_REPO}, ) with urllib.request.urlopen(req, timeout=10) as resp: data = json.loads(resp.read().decode("utf-8")) latest = data.get("tag_name", "unknown") return { "latest_version": latest, "current_version": current, "update_available": _version_newer(latest, current), "html_url": data.get("html_url", ""), "release_name": data.get("name", ""), "body": data.get("body", ""), } except urllib.error.HTTPError as e: if e.code != 404: logger.debug("GitHub API error: %s", e.code) return None except Exception as e: logger.debug("Failed to check releases: %s", e) return None # Fallback: check tags try: url = f"{GITHUB_API_URL}/tags?per_page=1" req = urllib.request.Request( url, headers={"Accept": "application/vnd.github.v3+json", "User-Agent": GITHUB_REPO}, ) with urllib.request.urlopen(req, timeout=10) as resp: data = json.loads(resp.read().decode("utf-8")) if data: latest = data[0].get("name", "unknown") return { "latest_version": latest, "current_version": current, "update_available": _version_newer(latest, current), "html_url": f"https://github.com/{GITHUB_OWNER}/{GITHUB_REPO}/releases", "release_name": "", "body": "", } except Exception as e: logger.debug("Failed to check tags: %s", e) return None - Helper function get_current_version() retrieves the current version via git describe --tags or pyproject.toml.
def get_current_version() -> str: """Get current version from git tag or pyproject.toml.""" try: result = subprocess.run( ["git", "describe", "--tags", "--abbrev=0"], capture_output=True, text=True, cwd=str(PROJECT_ROOT), timeout=5, ) if result.returncode == 0: return result.stdout.strip() - src/jvlink_mcp_server/server.py:47-47 (registration)The import statement that brings check_for_updates into server.py where the tool is defined.
from .updater import check_for_updates, perform_update, startup_update_check