Skip to main content
Glama
xhuaustc

Jenkins MCP Tool

search_jobs

Find Jenkins jobs on a specific server using keywords to locate relevant CI/CD pipelines and automation workflows.

Instructions

Search Jenkins jobs on the specified server.

Note: For deployment tasks, it is recommended to use get_scenario_list() and search_jobs_by_scenario().

Args:
    server_name: Jenkins server name
    keyword: Search keyword

Returns:
    List of matching jobs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_nameYes
keywordYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'search_jobs', decorated with @mcp.tool(). It takes server_name and keyword, creates a JenkinsAPIClient instance, and delegates to its search_jobs method to perform the search.
    @mcp.tool()
    def search_jobs(server_name: str, keyword: str) -> List[JobInfo]:
        """Search Jenkins jobs on the specified server.
    
        Note: For deployment tasks, it is recommended to use get_scenario_list() and search_jobs_by_scenario().
    
        Args:
            server_name: Jenkins server name
            keyword: Search keyword
    
        Returns:
            List of matching jobs
        """
        client = JenkinsAPIClient(server_name)
        return client.search_jobs(keyword)
  • Core implementation of search_jobs in JenkinsAPIClient class. Fetches the jobs tree from Jenkins API (up to 4 nested levels), recursively collects all jobs, filters those matching the keyword in name or fullName (case-insensitive), retrieves detailed JobInfo for matches using get_job_info, and returns the list.
    def search_jobs(self, keyword: str) -> List[JobInfo]:
        """Search jobs.
    
        Args:
            keyword: Search keyword
    
        Returns:
            List of matching jobs
    
        Raises:
            JenkinsError: API request failed
        """
        api_url = (
            f"{self._client.base_url}/api/json?tree=jobs[name,url,fullName,"
            "jobs[name,url,fullName,jobs[name,url,fullName,jobs[name,url,fullName]]]]"
        )
    
        response = self._make_request("GET", api_url)
        response.raise_for_status()
    
        data = response.json()
        all_jobs = self._collect_all_jobs(data.get("jobs", []))
    
        # Filter matching jobs
        matching_jobs = []
        for job in all_jobs:
            if (
                keyword.lower() in job["name"].lower()
                or keyword.lower() in job.get("fullName", "").lower()
            ):
                job_info = self.get_job_info(job["fullName"])
                matching_jobs.append(job_info)
    
        return matching_jobs
  • Recursive private helper method used by search_jobs to flatten nested job structures from the Jenkins API response into a flat list containing name, fullName, and url for each job.
    def _collect_all_jobs(
        self, jobs: List[Dict[str, Any]], parent: str = ""
    ) -> List[Dict[str, Any]]:
        """Recursively collect all jobs.
    
        Args:
            jobs: List of jobs
            parent: Parent job path
    
        Returns:
            Flattened job list
        """
        result = []
        for job in jobs:
            name = job.get("fullName") or (
                f"{parent}/{job['name']}" if parent else job["name"]
            )
            result.append(
                {
                    "name": job["name"],
                    "fullName": name,
                    "url": job["url"],
                }
            )
    
            if "jobs" in job and job["jobs"]:
                result.extend(self._collect_all_jobs(job["jobs"], name))
    
        return result
  • TypedDict schema defining the structure of JobInfo objects returned by search_jobs.
    class JobInfo(TypedDict):
        """Job info."""
    
        name: str
        fullName: str
        url: str
        description: Optional[str]
        buildable: bool
        color: str
        is_parameterized: bool
        last_build_number: Optional[int]
        last_build_url: Optional[str]
Behavior3/5

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

With no annotations provided, the description carries full burden. It states this is a search operation but doesn't disclose behavioral traits like authentication requirements, rate limits, pagination behavior, or what 'matching jobs' means in practice. The description is adequate but lacks rich behavioral context.

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 well-structured with clear sections (purpose, note, args, returns) and uses only essential sentences. The note about deployment tasks earns its place by providing valuable guidance. Slightly longer than minimal but appropriately so.

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

Completeness4/5

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

Given the tool has an output schema (so return values are documented elsewhere), 2 parameters with 0% schema coverage, and no annotations, the description provides good coverage: clear purpose, parameter explanations, usage guidance, and return type indication. It could benefit from more behavioral context but is reasonably complete.

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

Parameters4/5

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

With 0% schema description coverage, the description compensates by explaining both parameters: server_name specifies which Jenkins server, and keyword is the search term. This adds meaningful context beyond the bare schema, though it doesn't provide format examples or constraints.

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 searches Jenkins jobs on a specified server, providing a specific verb (search) and resource (Jenkins jobs). It distinguishes from some siblings like get_build_log or trigger_build, but doesn't explicitly differentiate from search_jobs_by_scenario beyond the note about deployment tasks.

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

Usage Guidelines4/5

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

The description provides explicit guidance with a note recommending alternative tools (get_scenario_list and search_jobs_by_scenario) for deployment tasks. This gives clear context for when to consider alternatives, though it doesn't specify when NOT to use this tool or compare it to all siblings.

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