get_all_views
Retrieve all top-level Jenkins views with their names and URLs.
Instructions
Get all top-level views from Jenkins.
Returns: A list of views with their name and URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_jenkins/server/view.py:7-14 (handler)Handler function for the get_all_views tool. Decorated with @mcp.tool, calls jenkins(ctx).get_views() to fetch all top-level views.
@mcp.tool(tags=['read']) async def get_all_views(ctx: Context) -> list[dict]: """Get all top-level views from Jenkins. Returns: A list of views with their name and URL. """ return jenkins(ctx).get_views() - Helper method on the Jenkins class that executes the actual REST API call using the VIEWS endpoint.
def get_views(self) -> list[dict]: """Get all top-level views from Jenkins. Returns: A list of dictionaries with 'name' and 'url' for each view. """ response = self.request('GET', rest_endpoint.VIEWS) return response.json().get('views', []) - Defines the REST API endpoint for fetching top-level views (api/json?tree=views[name,url]).
VIEWS = RestEndpoint('api/json?tree=views[name,url]') - src/mcp_jenkins/server/__init__.py:32-34 (registration)Registration: imports the view module (which includes get_all_views) to trigger the @mcp.tool decorator registration.
# Import tool modules to register them with the MCP server # This must happen after mcp is created so the @mcp.tool() decorators can reference it from mcp_jenkins.server import build, item, node, plugin, queue, view # noqa: F401, E402 - The jenkins() helper function that resolves the Jenkins client instance from the request context, used by the handler.
) def jenkins(ctx: Context) -> Jenkins: