jenkins_list_jobs
Retrieve a list of Jenkins jobs with customizable details using tree and depth parameters.
Instructions
List jobs visible to the Jenkins user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tree | No | jobs[name,fullName,url,color,_class] | |
| depth | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/jenkins_mcp_server/tools.py:106-112 (handler)The jenkins_list_jobs tool handler function. It accepts optional 'tree' and 'depth' parameters, fetches JSON from the Jenkins API's 'api/json' endpoint, and returns the result.
@mcp.tool() def jenkins_list_jobs( tree: str = "jobs[name,fullName,url,color,_class]", depth: int | None = None, ) -> dict[str, Any]: """List jobs visible to the Jenkins user.""" return _run(lambda: _get_json("api/json", params=_query(tree, depth))) - src/jenkins_mcp_server/tools.py:56-56 (registration)The tool is registered via the @mcp.tool() decorator on line 106 within the register_tools function (which starts at line 55). The decorator registers jenkins_list_jobs as an MCP tool.
@mcp.tool() - jenkins_list_jobs is listed in the READ_ONLY_TOOLS constant, marking it as a read-only (non-destructive) tool.
READ_ONLY_TOOLS = [ "jenkins_whoami", "jenkins_version", "jenkins_health", "jenkins_get_json", "jenkins_list_jobs", "jenkins_get_job", "jenkins_get_job_config", "jenkins_list_builds", "jenkins_get_build", "jenkins_get_build_log", "jenkins_get_build_artifacts", "jenkins_get_test_report", "jenkins_list_queue", "jenkins_get_queue_item", "jenkins_list_views", "jenkins_get_view", "jenkins_list_nodes", "jenkins_get_node", "jenkins_list_plugins", ] - The _query helper function used by jenkins_list_jobs to build query parameters with 'tree' and 'depth'.
def _query(tree: str | None = None, depth: int | None = None) -> dict[str, Any]: params: dict[str, Any] = {} if tree: params["tree"] = tree if depth is not None: params["depth"] = depth return params - The _get_json helper function used by jenkins_list_jobs to make the actual HTTP GET request to the Jenkins API.
def _get_json(path: str, params: dict[str, Any] | None = None) -> Any: with _client() as client: return client.get_json(path, params=params)