jenkins-cli-mcp 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,388 @@
1
+ Metadata-Version: 2.4
2
+ Name: jenkins-cli-mcp
3
+ Version: 0.3.1
4
+ Summary: Jenkins CLI + MCP server — build lifecycle, pipelines, logs, artifacts, queue, credentials, plugins, multi-context, node/user admin, and a native MCP server for AI agents
5
+ Author: Misha Lubich
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ml-lubich/jenkins-mcp
8
+ Project-URL: Repository, https://github.com/ml-lubich/jenkins-mcp
9
+ Keywords: jenkins,cli,mcp,devops,automation
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Build Tools
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: mcp<2,>=1.0.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
22
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
23
+ Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # jenkins-mcp
27
+
28
+ [![CI](https://github.com/ml-lubich/jenkins-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/ml-lubich/jenkins-mcp/actions/workflows/ci.yml)
29
+
30
+ A Jenkins CLI + MCP server — build lifecycle with exit codes, pipeline/stage
31
+ inspection, live logs, input steps, artifacts, queue management, credentials,
32
+ plugins, multi-context profiles, and node/user/git-tool administration, from
33
+ the terminal or from AI agents. Pure standard library (argparse + urllib +
34
+ json) — no extra runtime dependencies beyond the `mcp` package needed for
35
+ `serve`.
36
+
37
+ ```bash
38
+ jenkins-mcp status
39
+ jenkins-mcp job build my-pipeline --watch -p BRANCH=main
40
+ jenkins-mcp job log my-pipeline -f
41
+ jenkins-mcp pipeline info my-pipeline
42
+ jenkins-mcp doctor
43
+ jenkins-mcp serve
44
+ ```
45
+
46
+ ## Why jenkins-mcp
47
+
48
+ Compared to other Jenkins CLIs (e.g. `addozhang/jk`, the `jk` community
49
+ skill), `jenkins-mcp` is a superset: everything they do, plus Jenkins
50
+ administration and a native MCP server.
51
+
52
+ | Capability | jenkins-mcp | jk |
53
+ |---|---|---|
54
+ | Build lifecycle with `--watch` exit codes (0/1/2/3/4/10) | ✅ | ✅ |
55
+ | Live/follow console logs (`job log -f`) | ✅ | ✅ |
56
+ | Pipeline stage tree (`pipeline info`) | ✅ | ✅ |
57
+ | Pipeline input steps (`build input`) | ✅ | ✅ |
58
+ | Build artifacts list/download | ✅ | ✅ |
59
+ | Build queue list/cancel | ✅ | ✅ |
60
+ | Build rerun/replay with same parameters | ✅ | ✅ |
61
+ | `doctor` connectivity/auth/version checks | ✅ | ✅ |
62
+ | Fuzzy job name search | ✅ | ✅ |
63
+ | Multi-context / named profiles | ✅ | ✅ (URL-as-identity) |
64
+ | Machine-readable `-o json` output | ✅ | ✅ |
65
+ | **Node/agent management** (add/remove worker nodes) | ✅ | ❌ |
66
+ | **User account management** | ✅ | ❌ |
67
+ | **Credentials management** (create/list/delete) | ✅ | ❌ |
68
+ | **Plugin management** (list/install) | ✅ | ❌ |
69
+ | **Native MCP server** for AI agents (`jenkins-mcp serve`) | ✅ | ❌ |
70
+
71
+ `jk` is explicitly scoped to build/pipeline operations and does not manage
72
+ nodes, users, credentials, or plugins — `jenkins-mcp` covers both the
73
+ developer workflow and Jenkins administration, and exposes all of it as MCP
74
+ tools an AI agent can call directly.
75
+
76
+ ## Features
77
+ - **Build Lifecycle**: trigger, watch, cancel, and rerun builds with
78
+ shell-friendly exit codes; pass parameters with `-p KEY=VALUE`.
79
+ - **Pipeline Inspection**: stage-by-stage status/duration, and resolving
80
+ paused input steps.
81
+ - **Logs**: tail or live-follow (`-f`) a build's console output.
82
+ - **Artifacts**: list and download build artifacts, with glob filtering.
83
+ - **Queue Management**: list and cancel queued builds.
84
+ - **Credentials & Plugins**: manage the global credentials store and
85
+ installed plugins.
86
+ - **Multi-Context**: named connection profiles (`context add/use/list/current`),
87
+ selectable with `--context` or `$JENKINS_CONTEXT`.
88
+ - **Node Management**: Add, remove, and list worker nodes/agents.
89
+ - **Account Management**: Create and configure Jenkins user accounts.
90
+ - **Job Overview**: List jobs (with fuzzy `--search`) and their status.
91
+ - **Machine-Readable Output**: every command supports `-o json` (a dict
92
+ starting with `"schemaVersion": "1"`) for scripting.
93
+ - **CSRF Token / Crumb Handling**: Automatically acquires and attaches `Jenkins-Crumb` for Jenkins 2.x instances with security enabled.
94
+ - **Dual Mode**: Works as a standalone terminal CLI (`jenkins-mcp`) or as an MCP server for AI agents (`jenkins-mcp serve`).
95
+
96
+ ## Install
97
+
98
+ `jenkins-mcp` runs on **macOS, Linux, and Windows** — it's a pure-Python package,
99
+ so pip works the same everywhere:
100
+
101
+ ```bash
102
+ # macOS / Linux / Windows — pip
103
+ pip install jenkins-cli-mcp
104
+
105
+ # macOS / Linux / Windows — uv
106
+ uv tool install jenkins-cli-mcp
107
+ ```
108
+
109
+ Both install a `jenkins-mcp` command on your `PATH` (in PowerShell, cmd, or a
110
+ Unix shell alike).
111
+
112
+ From a clone, on any OS:
113
+
114
+ ```bash
115
+ git clone https://github.com/ml-lubich/jenkins-mcp.git
116
+ cd jenkins-mcp
117
+ uv tool install .
118
+ ```
119
+
120
+ ## Quickstart
121
+
122
+ ```bash
123
+ export JENKINS_URL="https://jenkins.example.com"
124
+ export JENKINS_USER="admin"
125
+ export JENKINS_PASSWORD="your-api-token"
126
+
127
+ jenkins-mcp status
128
+ ```
129
+
130
+ ## CLI Usage
131
+
132
+ ```bash
133
+ # Check status of all nodes
134
+ jenkins-mcp status
135
+
136
+ # Add a worker node
137
+ jenkins-mcp node add worker-01 --ip 192.0.2.10 --labels "linux worker"
138
+
139
+ # Remove a worker node
140
+ jenkins-mcp node remove worker-01
141
+
142
+ # Create a new user account
143
+ jenkins-mcp user create someuser 'a-strong-password' --email someuser@example.com
144
+
145
+ # List all jobs (fuzzy search by substring/subsequence)
146
+ jenkins-mcp jobs --search dep
147
+
148
+ # Run the MCP stdio server
149
+ jenkins-mcp serve
150
+ ```
151
+
152
+ For backward compatibility, connection flags can still be passed before the
153
+ command. They are hidden from root help; prefer contexts or environment
154
+ variables. Avoid `--password` because command arguments may be visible in shell
155
+ history and process listings. To read it from standard input instead:
156
+
157
+ ```bash
158
+ printf '%s\n' "$JENKINS_PASSWORD" | jenkins-mcp --url https://jenkins.example.com --user admin --password-stdin status
159
+ ```
160
+
161
+ Root help lists the command hierarchy, and groups such as `node` or `job`
162
+ show their subcommands when invoked without one. Use `-V` for the CLI version.
163
+ Commands support `-o json` for machine-readable output; `-j` is the concise
164
+ JSON option when placed before the command:
165
+
166
+ ```bash
167
+ jenkins-mcp -j jobs
168
+ # {"schemaVersion": "1", "jobs": [...]}
169
+ ```
170
+
171
+ ### Build lifecycle
172
+
173
+ ```bash
174
+ # Trigger a build and watch it; exit code mirrors the result
175
+ jenkins-mcp job build my-pipeline --watch
176
+ # exit 0=SUCCESS 1=FAILURE 2=UNSTABLE 3=ABORTED 4=paused-on-input 10=jenkins-mcp error
177
+
178
+ # With build parameters (repeatable -p)
179
+ jenkins-mcp job build my-pipeline --watch -p BRANCH=main -p DEPLOY=true
180
+
181
+ # Cancel a running build and wait for it to actually stop
182
+ jenkins-mcp build cancel my-pipeline --wait
183
+
184
+ # Re-run a job with the same parameters as its last build
185
+ jenkins-mcp job rerun my-pipeline --watch
186
+ ```
187
+
188
+ ### Pipeline stages & paused input steps
189
+
190
+ ```bash
191
+ jenkins-mcp pipeline info my-pipeline
192
+
193
+ # Resolve a paused "input" step (auto-detects the pending one)
194
+ jenkins-mcp build input my-pipeline proceed
195
+ jenkins-mcp build input my-pipeline abort --input-id Proceed
196
+ jenkins-mcp build input my-pipeline proceed -p CONFIRM=yes
197
+ ```
198
+
199
+ ### Logs
200
+
201
+ ```bash
202
+ # Last 100 lines
203
+ jenkins-mcp job log my-pipeline --tail 100
204
+
205
+ # Live-follow until the build finishes
206
+ jenkins-mcp job log my-pipeline -f
207
+ ```
208
+
209
+ ### Artifacts
210
+
211
+ ```bash
212
+ jenkins-mcp build artifacts my-pipeline
213
+ jenkins-mcp build download my-pipeline --pattern "*.jar" --out ./dist
214
+ ```
215
+
216
+ ### Queue
217
+
218
+ ```bash
219
+ jenkins-mcp queue list
220
+ jenkins-mcp queue cancel 42
221
+ ```
222
+
223
+ ### Doctor
224
+
225
+ ```bash
226
+ jenkins-mcp doctor
227
+ # [OK] reachable: https://jenkins.example.com
228
+ # [OK] auth: authenticated as admin
229
+ # [OK] version: 2.479.1
230
+ # [OK] crumb: <crumb value>
231
+ # exits 1 if any check fails
232
+ ```
233
+
234
+ ### Credentials
235
+
236
+ ```bash
237
+ jenkins-mcp credential list
238
+ printf '%s\n' "$DEPLOY_PASSWORD" | jenkins-mcp credential create deploy-key --kind userpass --username deployer --secret-stdin
239
+ printf '%s\n' "$CI_TOKEN" | jenkins-mcp credential create ci-token --kind secret-text --secret-stdin
240
+ jenkins-mcp credential delete deploy-key
241
+ ```
242
+
243
+ ### Plugins
244
+
245
+ ```bash
246
+ jenkins-mcp plugin list --search git
247
+ jenkins-mcp plugin list --updates
248
+ jenkins-mcp plugin install workflow-aggregator
249
+ ```
250
+
251
+ ### Multi-context (named profiles)
252
+
253
+ ```bash
254
+ jenkins-mcp context add prod --url https://jenkins.example.com --user admin --password 'token'
255
+ jenkins-mcp context use prod
256
+ jenkins-mcp context list
257
+ jenkins-mcp context current
258
+
259
+ # Use a context without making it the default
260
+ jenkins-mcp --context prod jobs
261
+ JENKINS_CONTEXT=prod jenkins-mcp jobs
262
+ ```
263
+
264
+ ## Configuration
265
+
266
+ `jenkins-mcp` never ships with credentials. It resolves connection settings in this
267
+ order, first match wins:
268
+
269
+ 1. Explicit CLI flags: `--url`, `--user`, `--password` (legacy; use `--password-stdin` to avoid argv exposure)
270
+ 2. Environment variables: `JENKINS_URL`, `JENKINS_USER`, `JENKINS_PASSWORD`
271
+ 3. A JSON config file at `~/.config/jenkins-mcp/config.json`
272
+
273
+ If no username/password is found by any of the above, the command exits with
274
+ a clear error instead of connecting anonymously.
275
+
276
+ ### Environment variables
277
+
278
+ ```bash
279
+ export JENKINS_URL="https://jenkins.example.com"
280
+ export JENKINS_USER="your-jenkins-username"
281
+ export JENKINS_PASSWORD="your-jenkins-api-token"
282
+ ```
283
+
284
+ ### Config file
285
+
286
+ Create `~/.config/jenkins-mcp/config.json`:
287
+
288
+ ```json
289
+ {
290
+ "url": "https://jenkins.example.com",
291
+ "username": "your-jenkins-username",
292
+ "password": "your-jenkins-api-token"
293
+ }
294
+ ```
295
+
296
+ Or define multiple named contexts (managed via `jenkins-mcp context add/use`):
297
+
298
+ ```json
299
+ {
300
+ "default_context": "prod",
301
+ "contexts": {
302
+ "prod": {
303
+ "url": "https://jenkins.example.com",
304
+ "username": "your-jenkins-username",
305
+ "password": "your-jenkins-api-token"
306
+ },
307
+ "staging": {
308
+ "url": "https://jenkins-staging.example.com",
309
+ "username": "your-jenkins-username",
310
+ "password": "a-different-token"
311
+ }
312
+ }
313
+ }
314
+ ```
315
+
316
+ ## Running as an MCP Server for AI Agents
317
+
318
+ `jenkins-mcp` ships a `serve` subcommand that runs the MCP stdio server:
319
+
320
+ ```bash
321
+ jenkins-mcp serve
322
+ ```
323
+
324
+ Register it with Claude Code:
325
+
326
+ ```bash
327
+ claude mcp add jenkins -- jenkins-mcp serve
328
+ ```
329
+
330
+ Exposed MCP Tools:
331
+ - `jenkins_get_status()`
332
+ - `jenkins_add_node(name, ip, labels, remote_fs)`
333
+ - `jenkins_remove_node(name)`
334
+ - `jenkins_create_user(username, password, email)`
335
+ - `jenkins_list_jobs()`
336
+ - `jenkins_use_jgit()`
337
+ - `jenkins_build_job(job, wait)`
338
+ - `jenkins_pipeline_info(job, build)`
339
+ - `jenkins_cancel_build(job, build)`
340
+ - `jenkins_build_log_tail(job, build, lines)`
341
+ - `jenkins_pending_input(job, build)`
342
+ - `jenkins_list_artifacts(job, build)`
343
+ - `jenkins_queue_list()`
344
+ - `jenkins_doctor()`
345
+ - `jenkins_list_credentials()`
346
+ - `jenkins_create_credential(id, kind, username, secret, description)`
347
+ - `jenkins_list_plugins(search)`
348
+ - `jenkins_install_plugin(name)`
349
+ - `jenkins_rerun_build(job, build)`
350
+
351
+ Every tool other than `jenkins_get_status`/`jenkins_add_node`/`jenkins_remove_node`/`jenkins_create_user`/`jenkins_list_jobs`/`jenkins_use_jgit`/`jenkins_build_job`
352
+ catches its own errors and returns `{"error": "..."}` instead of raising.
353
+
354
+ ## Security
355
+
356
+ Requests use HTTP Basic Auth, which sends `username:password` base64-encoded
357
+ on every request — base64 is trivially reversible, not encryption. Use an
358
+ `https://` Jenkins URL, or make sure the connection stays on a trusted
359
+ network, before sending real credentials.
360
+
361
+ Prefer a Jenkins **API token** over your account password: generate one under
362
+ your Jenkins user profile ("Configure" → "API Token") and set it as
363
+ `JENKINS_PASSWORD`. `jenkins-mcp` accepts an API token anywhere it accepts a
364
+ password, and tokens can be revoked independently of your login credentials.
365
+
366
+ ## Development
367
+
368
+ ```bash
369
+ git clone https://github.com/ml-lubich/jenkins-mcp.git
370
+ cd jenkins-mcp
371
+ python3 -m venv .venv
372
+ source .venv/bin/activate
373
+ pip install -e ".[dev]"
374
+ ```
375
+
376
+ ### Running Tests
377
+
378
+ ```bash
379
+ pytest -q
380
+ ```
381
+
382
+ The pytest configuration measures `jenkins_mcp` and fails the suite below 80%
383
+ aggregate line coverage. Tests should use fake Jenkins responses and isolated
384
+ configuration; they must not contact a live Jenkins server or use real credentials.
385
+
386
+ ## License
387
+
388
+ MIT
@@ -0,0 +1,10 @@
1
+ jenkins_cli_mcp-0.3.1.dist-info/licenses/LICENSE,sha256=f2Jg7siIJugKjulMOIw4zz439sRWntgKzpceB40HKUs,1069
2
+ jenkins_mcp/__init__.py,sha256=pD5RoSCzhrwZOwsidBGSFCiElhJCcygcHo-MxaNPNyc,70
3
+ jenkins_mcp/cli.py,sha256=rbiqX9mO5w6_U-Dg7Q0GlO1FTpMc9kISog7JZarVJLo,26994
4
+ jenkins_mcp/client.py,sha256=JbCLP_FNzNhrqC9RuQEf88HPg-W2ZWtAIloIDyfkMd0,31866
5
+ jenkins_mcp/mcp_server.py,sha256=sEivjdhN1wrrzNOCCGdKQObfw_RrwMEghZGnQpYNetU,5868
6
+ jenkins_cli_mcp-0.3.1.dist-info/METADATA,sha256=Yg7wKdWz5UNThLaQ609G8uvsBJl-Culco_Ru1zsFsrQ,12188
7
+ jenkins_cli_mcp-0.3.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ jenkins_cli_mcp-0.3.1.dist-info/entry_points.txt,sha256=X56cwNwFC7KidLjwp8nFAK9kuU_DIYp1Ole2XCOttfE,53
9
+ jenkins_cli_mcp-0.3.1.dist-info/top_level.txt,sha256=rdY7sMy3TI2YphJRL5OukJm4mw3-9WGizp4wDDT6cP8,12
10
+ jenkins_cli_mcp-0.3.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ jenkins-mcp = jenkins_mcp.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Misha Lubich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ jenkins_mcp
@@ -0,0 +1,5 @@
1
+ """
2
+ jenkins-mcp - Jenkins CLI + MCP server
3
+ """
4
+
5
+ __version__ = "0.3.1"