jenkins_version
Retrieve the Jenkins server version directly from the X-Jenkins response header.
Instructions
Return Jenkins version from the X-Jenkins response header.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/jenkins_mcp_server/tools.py:62-73 (handler)The jenkins_version tool handler: makes a GET request to 'api/json' and returns the Jenkins version from the X-Jenkins response header, along with the X-Jenkins-Session header.
def jenkins_version() -> dict[str, Any]: """Return Jenkins version from the X-Jenkins response header.""" def op() -> dict[str, Any]: with _client() as client: response = client.request("GET", "api/json", params={"tree": "mode"}) return { "version": response.headers.get("X-Jenkins"), "session": response.headers.get("X-Jenkins-Session"), } return _run(op) - src/jenkins_mcp_server/tools.py:55-57 (registration)Registration of jenkins_version via the @mcp.tool() decorator inside the register_tools function.
def register_tools(mcp: FastMCP) -> None: @mcp.tool() def jenkins_whoami() -> dict[str, Any]: - The _client() helper used by jenkins_version to create a JenkinsClient from environment variables.
def _client() -> JenkinsClient: return JenkinsClient.from_env() def _get_json(path: str, params: dict[str, Any] | None = None) -> Any: with _client() as client: return client.get_json(path, params=params) - The _run() helper used to execute the tool's operation and wrap results in a standardized response.
def _run(fn): try: return _ok(fn()) except JenkinsMCPError as exc: return exc.to_dict() - The _ok() helper that wraps successful data into {'ok': True, 'data': data} format.
def _ok(data: Any) -> dict[str, Any]: return {"ok": True, "data": data} def _run(fn): try: return _ok(fn()) except JenkinsMCPError as exc: return exc.to_dict() def _client() -> JenkinsClient: return JenkinsClient.from_env()