Skip to main content
Glama
mdtahmidhossain

jenkins-http-mcp-server

jenkins_get_job

Retrieve a specific Jenkins job by its path using slash-separated names or a list of strings.

Instructions

Get one job by Jenkins job path. Nested paths use slash-separated names or a list.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jobYes
treeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the jenkins_get_job tool. It takes a job path (string or list of strings) and an optional tree parameter, builds the Jenkins API path via job_path(), and fetches JSON from the Jenkins API.
    @mcp.tool()
    def jenkins_get_job(job: str | list[str], tree: str | None = None) -> dict[str, Any]:
        """Get one job by Jenkins job path. Nested paths use slash-separated names or a list."""
        return _run(lambda: _get_json(job_path(job), params=_query(tree)))
  • All tool registrations happen inside register_tools() which is called from __main__.py. The @mcp.tool() decorator on line 114 registers jenkins_get_job with the FastMCP server.
    def register_tools(mcp: FastMCP) -> None:
        @mcp.tool()
        def jenkins_whoami() -> dict[str, Any]:
            """Return the authenticated Jenkins identity from /whoAmI/api/json."""
            return _run(lambda: _get_json("whoAmI"))
    
        @mcp.tool()
        def jenkins_version() -> dict[str, Any]:
            """Return Jenkins version from the X-Jenkins response header."""
    
            def op() -> dict[str, Any]:
                with _client() as client:
                    response = client.request("GET", "api/json", params={"tree": "mode"})
                    return {
                        "version": response.headers.get("X-Jenkins"),
                        "session": response.headers.get("X-Jenkins-Session"),
                    }
    
            return _run(op)
    
        @mcp.tool()
        def jenkins_health() -> dict[str, Any]:
            """Return a small health snapshot from top-level Jenkins JSON and version headers."""
    
            def op() -> dict[str, Any]:
                with _client() as client:
                    response = client.request(
                        "GET",
                        "api/json",
                        params={
                            "tree": (
                                "mode,nodeDescription,nodeName,numExecutors,quietingDown,useCrumbs"
                            )
                        },
                    )
                    payload = response.json()
                    payload["version"] = response.headers.get("X-Jenkins")
                    return payload
    
            return _run(op)
    
        @mcp.tool()
        def jenkins_get_json(path: str, query: dict[str, str | int] | None = None) -> dict[str, Any]:
            """GET a relative Jenkins JSON API path. Rejects external URLs and traversal."""
    
            def op() -> Any:
                relative = append_api_json(normalize_relative_path(path))
                return _get_json(relative, params=query)
    
            return _run(op)
    
        @mcp.tool()
        def jenkins_list_jobs(
            tree: str = "jobs[name,fullName,url,color,_class]",
            depth: int | None = None,
        ) -> dict[str, Any]:
            """List jobs visible to the Jenkins user."""
            return _run(lambda: _get_json("api/json", params=_query(tree, depth)))
    
        @mcp.tool()
        def jenkins_get_job(job: str | list[str], tree: str | None = None) -> dict[str, Any]:
            """Get one job by Jenkins job path. Nested paths use slash-separated names or a list."""
            return _run(lambda: _get_json(job_path(job), params=_query(tree)))
  • The input schema is defined by the function signature: 'job: str | list[str]' (required) and 'tree: str | None = None' (optional). The output is dict[str, Any] wrapped in {'ok': True, 'data': ...} via _run().
    @mcp.tool()
    def jenkins_get_job(job: str | list[str], tree: str | None = None) -> dict[str, Any]:
        """Get one job by Jenkins job path. Nested paths use slash-separated names or a list."""
        return _run(lambda: _get_json(job_path(job), params=_query(tree)))
  • The job_path() helper function converts a job path (string or list) into a Jenkins API URL path with proper encoding and 'job' segments.
    def job_path(job: str | list[str]) -> str:
        pieces = [piece for piece in job.split("/") if piece] if isinstance(job, str) else job
        if not pieces:
            raise PathValidationError("job must include at least one path segment")
    
        encoded: list[str] = []
        for piece in pieces:
            if not piece or piece in {".", ".."} or "/" in piece:
                raise PathValidationError("job path segments must be non-empty names")
            encoded.extend(["job", quote(piece, safe="")])
        return "/".join(encoded)
  • The _get_json() helper is called by the handler under the hood via the get_json() method on JenkinsClient. It performs the HTTP GET to the Jenkins API and returns parsed JSON.
    def get_json(self, path: str, params: Mapping[str, Any] | None = None) -> Json:
        response = self.request("GET", append_api_json(path), params=params)
        try:
            payload = response.json()
        except json.JSONDecodeError as exc:
            raise JenkinsHTTPError(
                response.status_code,
                "GET",
                normalize_relative_path(path),
                "Response was not JSON",
                _body_snippet(response),
            ) from exc
        return payload
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only explains path formatting but omits behavioral traits like authentication requirements, error handling, side effects, or response details. For a read-only retrieval tool, more transparency is needed.

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

Conciseness5/5

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

The description is two concise sentences with no unnecessary words. It front-loads the core purpose and immediately provides the key usage detail about nested paths.

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

Completeness2/5

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

Given the minimal parameter documentation and lack of explanation for the 'tree' parameter or return value format, the description is incomplete. Even though an output schema exists, the description should provide more context for a retrieval tool with an optional filter parameter.

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 value to the 'job' parameter by explaining it can be a slash-separated string or a list of path components, which is not in the schema. However, it fails to explain the 'tree' parameter at all, and schema coverage is 0%, so the description only partially compensates.

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

Purpose5/5

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

The description clearly states the tool retrieves a single job by Jenkins job path, using 'Get one job' which specifies both verb and resource. The mention of nested paths using slash-separated names or a list adds precision and differentiates from sibling tools like jenkins_list_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 for retrieving a single job, but does not explicitly state when to use this tool versus alternatives, nor does it provide when-not-to-use conditions or list sibling tools for comparison.

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/mdtahmidhossain/jenkins-http-mcp-server'

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