get_view
Retrieve a Jenkins view by its path, returning jobs and nested sub-views for hierarchical navigation.
Instructions
Get a Jenkins view by path, returning its jobs and/or nested sub-views.
Views can be nested up to multiple levels deep. Use "/" to separate levels in the path. If the view contains sub-views instead of jobs, the response will include their names so you can drill down further.
Args: view_path: View path using "/" to separate levels. Examples: "All", "frontend", "frontend/nightly". Spaces and special characters in view names are handled automatically. depth: Depth of detail to retrieve for each job. Default is 0.
Returns: A dict with the view's name, jobs list, and/or nested views.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| view_path | Yes | ||
| depth | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_jenkins/server/view.py:17-34 (handler)The tool handler function for 'get_view'. It is an async function decorated with @mcp.tool(tags=['read']) that takes ctx, view_path, and depth parameters, and delegates to the Jenkins REST client.
@mcp.tool(tags=['read']) async def get_view(ctx: Context, view_path: str, depth: int = 0) -> dict: """Get a Jenkins view by path, returning its jobs and/or nested sub-views. Views can be nested up to multiple levels deep. Use "/" to separate levels in the path. If the view contains sub-views instead of jobs, the response will include their names so you can drill down further. Args: view_path: View path using "/" to separate levels. Examples: "All", "frontend", "frontend/nightly". Spaces and special characters in view names are handled automatically. depth: Depth of detail to retrieve for each job. Default is 0. Returns: A dict with the view's name, jobs list, and/or nested views. """ return jenkins(ctx).get_view(view_path=view_path, depth=depth) - The REST endpoint definition for VIEW: '{view_path}/api/json?depth={depth}', which is constructed dynamically with view_path and depth parameters.
VIEW = RestEndpoint('{view_path}/api/json?depth={depth}') - src/mcp_jenkins/server/view.py:17-34 (registration)Tool registration via the @mcp.tool(tags=['read']) decorator on the get_view async function. The 'view' module is imported in server/__init__.py line 34 to register all tools.
@mcp.tool(tags=['read']) async def get_view(ctx: Context, view_path: str, depth: int = 0) -> dict: """Get a Jenkins view by path, returning its jobs and/or nested sub-views. Views can be nested up to multiple levels deep. Use "/" to separate levels in the path. If the view contains sub-views instead of jobs, the response will include their names so you can drill down further. Args: view_path: View path using "/" to separate levels. Examples: "All", "frontend", "frontend/nightly". Spaces and special characters in view names are handled automatically. depth: Depth of detail to retrieve for each job. Default is 0. Returns: A dict with the view's name, jobs list, and/or nested views. """ return jenkins(ctx).get_view(view_path=view_path, depth=depth) - Helper method _build_view_path that converts a slash-separated view path (e.g., 'frontend/nightly') into the Jenkins URL path format (e.g., 'view/frontend/view/nightly').
def _build_view_path(self, view_path: str) -> str: """Build a Jenkins view URL path from a slash-separated view path. Args: view_path: Slash-separated view path (e.g. "frontend/nightly"). Returns: The Jenkins URL path segment (e.g. "view/frontend/view/nightly"). """ from urllib.parse import quote parts = [quote(p.strip(), safe='') for p in view_path.split('/') if p.strip()] return '/'.join(f'view/{p}' for p in parts) - The Jenkins REST client get_view method that constructs the URL path via _build_view_path, makes an HTTP GET request using the VIEW endpoint, and returns the JSON response.
def get_view(self, *, view_path: str, depth: int = 0) -> dict: """Get a specific view by path. Supports nested views using slash-separated paths (e.g. "All", "frontend/nightly", "frontend/nightly/nightly linux"). Args: view_path: Slash-separated view path. depth: The depth of the information to retrieve. Returns: A dictionary with the view's name, jobs, and/or nested views. """ url_path = self._build_view_path(view_path) response = self.request('GET', rest_endpoint.VIEW(view_path=url_path, depth=depth)) return response.json()