Skip to main content
Glama
xhuaustc

Jenkins MCP Tool

search_jobs_by_scenario

Find Jenkins jobs by scenario name or index to retrieve job information for specific automation workflows.

Instructions

Get the specified Jenkins job directly by scenario.

Args:
    scenario: Scenario name or index

Returns:
    List of job info matching the scenario

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scenarioYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'search_jobs_by_scenario'. This decorated function serves as the entry point for the tool, delegating the core logic to ScenarioManager.
    @mcp.tool()
    def search_jobs_by_scenario(scenario: str) -> List[JobInfo]:
        """Get the specified Jenkins job directly by scenario.
    
        Args:
            scenario: Scenario name or index
    
        Returns:
            List of job info matching the scenario
        """
        return ScenarioManager.search_jobs_by_scenario(scenario)
  • Core helper function implementing the search logic: resolves scenario from config, fetches job info via JenkinsAPIClient, and enriches with scenario metadata.
    def search_jobs_by_scenario(scenario: str) -> List[JobInfo]:
        """Get the specified Jenkins job directly by scenario.
    
        Args:
            scenario: Scenario name or index
    
        Returns:
            List of job info matching the scenario
    
        Raises:
            JenkinsConfigurationError: Scenario configuration error
            JenkinsError: API request failed
        """
        scenario_mapping = get_scenario_mapping()
    
        # Parse scenario name
        resolved_scenario = ScenarioManager._resolve_scenario_name(
            scenario, scenario_mapping
        )
    
        if resolved_scenario not in scenario_mapping:
            available_scenarios = ", ".join(scenario_mapping.keys())
            raise JenkinsConfigurationError(
                f"Unknown scenario '{scenario}'. Available scenarios: {available_scenarios}"
            )
    
        config = scenario_mapping[resolved_scenario]
        server_name = config["server"]
        job_path = config["job_path"].strip("/")
    
        logger.info(
            f"Searching jobs for scenario '{resolved_scenario}' on server '{server_name}'"
        )
    
        try:
            # Use Jenkins API client to get job info
            client = JenkinsAPIClient(server_name)
            job_info = client.get_job_info(job_path)
    
            # Add scenario-related info
            job_info["scenario"] = resolved_scenario
            job_info["scenario_match"] = True
    
            return [job_info]
    
        except Exception as e:
            logger.error(f"Failed to get job for scenario '{resolved_scenario}': {e}")
            if "404" in str(e) or "not found" in str(e).lower():
                raise JenkinsConfigurationError(
                    f"Job path '{job_path}' for scenario '{resolved_scenario}' not found on server '{server_name}'"
                ) from e
            else:
                raise JenkinsError(
                    f"Failed to get job for scenario '{resolved_scenario}': {e}"
                ) from e
  • Tool registration via @mcp.tool() decorator in the MCP tools module.
    @mcp.tool()
    def search_jobs_by_scenario(scenario: str) -> List[JobInfo]:
        """Get the specified Jenkins job directly by scenario.
    
        Args:
            scenario: Scenario name or index
    
        Returns:
            List of job info matching the scenario
        """
        return ScenarioManager.search_jobs_by_scenario(scenario)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that it returns a 'List of job info matching the scenario,' which gives some output context, but lacks details on permissions, rate limits, error handling, or whether it's a read-only operation. For a tool with no annotations, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the main purpose stated first, followed by brief sections for Args and Returns. It avoids unnecessary details, but the structure could be slightly more polished (e.g., using bullet points). Overall, it's efficient with minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity, no annotations, and an output schema present, the description is partially complete. It covers the basic purpose and parameter semantics but lacks behavioral context and detailed usage guidelines. The output schema likely handles return values, so the description doesn't need to explain those, but it should address other gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaning by explaining that 'scenario' is a 'Scenario name or index,' which clarifies beyond the schema's generic 'string' type. However, with 0% schema description coverage and only one parameter, it compensates somewhat but doesn't provide examples, format details, or constraints, leaving room for improvement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the specified Jenkins job directly by scenario.' It specifies the verb ('Get') and resource ('Jenkins job'), and distinguishes it from the sibling 'search_jobs' by focusing on scenario-based retrieval. However, it doesn't fully differentiate from 'get_scenario_list' which might list scenarios rather than jobs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying 'by scenario,' suggesting it should be used when you have a scenario name or index. It doesn't explicitly state when to use this tool versus alternatives like 'search_jobs' or 'get_scenario_list,' nor does it provide exclusions or prerequisites, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xhuaustc/jenkins-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server