get_all_plugins
Retrieve all installed Jenkins plugins along with their dependency information. Use the depth parameter to control the detail level.
Instructions
Get all installed plugins from Jenkins
Args: depth: The depth of the information to retrieve. Default is 2 (includes dependencies).
Returns: A list of all installed plugins
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| depth | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_jenkins/server/plugin.py:7-17 (handler)MCP tool handler for 'get_all_plugins'. Decorated with @mcp.tool(tags={'read'}), calls jenkins(ctx).get_plugins(depth=depth).
@mcp.tool(tags={'read'}) async def get_all_plugins(ctx: Context, depth: int = 2) -> list[dict]: """Get all installed plugins from Jenkins Args: depth: The depth of the information to retrieve. Default is 2 (includes dependencies). Returns: A list of all installed plugins """ return jenkins(ctx).get_plugins(depth=depth) - Jenkins client method get_plugins that performs the actual HTTP request to the Jenkins REST API. Calls PLUGIN_LIST endpoint with specified depth.
def get_plugins(self, *, depth: int = 0) -> list[dict]: """Get a list of all installed plugins. Args: depth: The depth of the information to retrieve. Returns: A list of plugin dictionaries. """ response = self.request('GET', rest_endpoint.PLUGIN_LIST(depth=depth)) return response.json().get('plugins', []) - REST endpoint definition: PLUGIN_LIST = RestEndpoint('pluginManager/api/json?depth={depth}').
PLUGIN_LIST = RestEndpoint('pluginManager/api/json?depth={depth}') - src/mcp_jenkins/server/__init__.py:30-34 (registration)Registration of the mcp server instance (JenkinsMCP) and import of plugin.py which triggers the @mcp.tool decorators.
mcp = JenkinsMCP('mcp-jenkins', lifespan=lifespan) # 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 creates/configures a Jenkins client instance from context, used by the handler.
def jenkins(ctx: Context) -> Jenkins: if ctx.request_context.lifespan_context.jenkins_session_singleton and getattr(ctx.session, 'jenkins', None): return ctx.session.jenkins jenkins_url = ctx.request_context.lifespan_context.jenkins_url jenkins_username = ctx.request_context.lifespan_context.jenkins_username jenkins_password = ctx.request_context.lifespan_context.jenkins_password jenkins_timeout = ctx.request_context.lifespan_context.jenkins_timeout jenkins_verify_ssl = ctx.request_context.lifespan_context.jenkins_verify_ssl try: requests = get_http_request() jenkins_url = getattr(requests.state, 'jenkins_url', None) or jenkins_url jenkins_username = getattr(requests.state, 'jenkins_username', None) or jenkins_username jenkins_password = getattr(requests.state, 'jenkins_password', None) or jenkins_password logger.debug(f'Retrieved Jenkins auth from request state - url: {jenkins_url}, username: {jenkins_username}') except RuntimeError as e: logger.debug(f'No HTTP request context available, falling back to environment variables: {e}') except Exception as e: # noqa: BLE001 logger.error( f'Unexpected error retrieving Jenkins auth from request, falling back to environment variables: {e}' ) if not all((jenkins_url, jenkins_username, jenkins_password)): msg = ( 'Jenkins authentication details are missing. ' 'Please provide them via x-jenkins-* headers ' 'or CLI arguments (--jenkins-url, --jenkins-username, --jenkins-password).' ) raise ValueError(msg) logger.info( f'Creating Jenkins client with url: ' f'{jenkins_url}, username: {jenkins_username}, timeout: {jenkins_timeout}, verify_ssl: {jenkins_verify_ssl}' ) ctx.session.jenkins = Jenkins( url=jenkins_url, username=jenkins_username, password=jenkins_password, timeout=jenkins_timeout, verify_ssl=jenkins_verify_ssl, ) return ctx.session.jenkins