@rishibhushan/jenkins-mcp-server 1.0.6 ā 1.1.0
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.
- package/README.md +584 -18
- package/package.json +1 -1
- package/requirements.txt +1 -0
- package/src/jenkins_mcp_server/__init__.py +19 -11
- package/src/jenkins_mcp_server/cache.py +310 -0
- package/src/jenkins_mcp_server/config.py +54 -1
- package/src/jenkins_mcp_server/jenkins_client.py +69 -80
- package/src/jenkins_mcp_server/metrics.py +358 -0
- package/src/jenkins_mcp_server/server.py +1015 -108
package/README.md
CHANGED
|
@@ -4,8 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
Designed to work seamlessly with automation clients such as:
|
|
6
6
|
- š„ļø **VS Code MCP** - Direct integration with Claude in VS Code
|
|
7
|
+
- š„ļø **Claude Desktop** - AI-powered Jenkins automation
|
|
7
8
|
- š **Any MCP-compatible client** - Universal compatibility
|
|
8
9
|
|
|
10
|
+
## ⨠What's New in v1.1.0
|
|
11
|
+
|
|
12
|
+
### š Performance Enhancements
|
|
13
|
+
- ā” **10x faster** - Client connection caching for repeated operations
|
|
14
|
+
- š **Smart caching** - Job list caching with 30-60s TTL (5-10x improvement)
|
|
15
|
+
- šÆ **Optimized queries** - Reduced API calls by 33-83%
|
|
16
|
+
|
|
17
|
+
### š”ļø Reliability Improvements
|
|
18
|
+
- ā
**86% validation coverage** - Input validation on 18/21 tools
|
|
19
|
+
- ā±ļø **Configurable timeouts** - No more hanging API calls
|
|
20
|
+
- š¬ **Better error messages** - Clear troubleshooting steps
|
|
21
|
+
- š„ **Health check tool** - Instant diagnostics
|
|
22
|
+
|
|
23
|
+
### šļø Advanced Features
|
|
24
|
+
- š¦ **Batch operations** - Trigger up to 20 builds at once
|
|
25
|
+
- š **Metrics & telemetry** - Track tool usage and performance
|
|
26
|
+
- šļø **Cache management** - Monitor and control caching
|
|
27
|
+
- š **Console improvements** - Line-based truncation with tail mode
|
|
28
|
+
- šØ **Structured logging** - Better debugging with JSON logs
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
9
32
|
## ⨠About codebase
|
|
10
33
|
|
|
11
34
|
- ā
**Codebase** - cleaner, more maintainable
|
|
@@ -14,6 +37,8 @@ Designed to work seamlessly with automation clients such as:
|
|
|
14
37
|
- ā
**Cross-platform** - Seamless support for Windows, macOS, and Linux
|
|
15
38
|
- ā
**Logging** - Professional logging with `--verbose` flag
|
|
16
39
|
- ā
**Dependency management** - Automatic detection and installation
|
|
40
|
+
- ā
**Performance** - 10x faster with intelligent caching and optimization
|
|
41
|
+
- ā
**Reliability** - Comprehensive input validation and error handling
|
|
17
42
|
|
|
18
43
|
---
|
|
19
44
|
|
|
@@ -25,25 +50,26 @@ This project includes:
|
|
|
25
50
|
- š Automatic virtual environment creation + dependency installation
|
|
26
51
|
- š Corporate proxy/certificate auto-detection support
|
|
27
52
|
- šŖ Windows, macOS, and Linux support
|
|
28
|
-
- š ļø **
|
|
53
|
+
- š ļø **26 Jenkins management tools** (upgraded from 20!)
|
|
29
54
|
|
|
30
55
|
### š§© Build Operations
|
|
31
56
|
| Tool Name | Description | Required Fields | Optional Fields |
|
|
32
57
|
|---|---|---|---|
|
|
33
58
|
| `trigger-build` | Trigger a Jenkins job build with optional parameters | `job_name` | `parameters` |
|
|
34
59
|
| `stop-build` | Stop a running Jenkins build | `job_name`, `build_number` | *(none)* |
|
|
60
|
+
| `trigger-multiple-builds` | **NEW!** Trigger builds for multiple jobs at once | `job_names` | `parameters`, `wait_for_start` |
|
|
35
61
|
|
|
36
62
|
### š Job Information
|
|
37
63
|
| Tool Name | Description | Required Fields | Optional Fields |
|
|
38
64
|
|---|---|---|---|
|
|
39
|
-
| `list-jobs` | List all Jenkins jobs with optional filtering | *(none)* | `filter` |
|
|
40
|
-
| `get-job-details` | Get detailed information about a Jenkins job | `job_name` |
|
|
65
|
+
| `list-jobs` | List all Jenkins jobs with optional filtering **and caching** | *(none)* | `filter`, `use_cache` |
|
|
66
|
+
| `get-job-details` | Get detailed information about a Jenkins job | `job_name` | `max_recent_builds` |
|
|
41
67
|
|
|
42
68
|
### š ļø Build Information
|
|
43
69
|
| Tool Name | Description | Required Fields | Optional Fields |
|
|
44
70
|
|---|---|---|---|
|
|
45
71
|
| `get-build-info` | Get information about a specific build | `job_name`, `build_number` | *(none)* |
|
|
46
|
-
| `get-build-console` | Get console output
|
|
72
|
+
| `get-build-console` | Get console output with **smart truncation** | `job_name`, `build_number` | `max_lines`, `tail_only` |
|
|
47
73
|
| `get-last-build-number` | Get the last build number for a job | `job_name` | *(none)* |
|
|
48
74
|
| `get-last-build-timestamp` | Get the timestamp of the last build | `job_name` | *(none)* |
|
|
49
75
|
|
|
@@ -70,6 +96,17 @@ This project includes:
|
|
|
70
96
|
| `get-queue-info` | Get Jenkins build queue info | *(none)* | *(none)* |
|
|
71
97
|
| `list-nodes` | List all Jenkins nodes | *(none)* | *(none)* |
|
|
72
98
|
| `get-node-info` | Get information about a Jenkins node | `node_name` | *(none)* |
|
|
99
|
+
| `health-check` | **NEW!** Run diagnostics on Jenkins connection | *(none)* | *(none)* |
|
|
100
|
+
|
|
101
|
+
### š Monitoring & Management
|
|
102
|
+
| Tool Name | Description | Required Fields | Optional Fields |
|
|
103
|
+
|---|---|---|---|
|
|
104
|
+
| `get-cache-stats` | **NEW!** Get cache statistics and information | *(none)* | *(none)* |
|
|
105
|
+
| `clear-cache` | **NEW!** Clear all cached data | *(none)* | *(none)* |
|
|
106
|
+
| `get-metrics` | **NEW!** Get usage metrics and performance stats | *(none)* | `tool_name` |
|
|
107
|
+
| `configure-webhook` | **NEW!** Configure webhook notifications | `job_name`, `webhook_url`, `events` | *(none)* |
|
|
108
|
+
|
|
109
|
+
For detailed technical documentation, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
|
|
73
110
|
|
|
74
111
|
---
|
|
75
112
|
|
|
@@ -161,12 +198,7 @@ Add to your VS Code `settings.json`:
|
|
|
161
198
|
|
|
162
199
|
### Option 2: Environment File (.env)
|
|
163
200
|
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
cp .env.template .env
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
In the `.env` file in your project directory:
|
|
201
|
+
Create a file `.env` in your local:
|
|
170
202
|
|
|
171
203
|
```bash
|
|
172
204
|
JENKINS_URL=http://jenkins.example.com:8080
|
|
@@ -214,7 +246,11 @@ Settings are loaded in this order (later overrides earlier):
|
|
|
214
246
|
|
|
215
247
|
### Option 1: Using npx (No Installation Required)
|
|
216
248
|
```bash
|
|
249
|
+
# if .env file is located in the current directory
|
|
217
250
|
npx @rishibhushan/jenkins-mcp-server --env-file .env
|
|
251
|
+
|
|
252
|
+
# OR if .env file is located in /path/to/.env
|
|
253
|
+
npx @rishibhushan/jenkins-mcp-server --env-file /path/to/.env
|
|
218
254
|
```
|
|
219
255
|
|
|
220
256
|
### Option 2: Global Installation
|
|
@@ -231,10 +267,6 @@ jenkins-mcp-server --env-file .env
|
|
|
231
267
|
npx github:rishibhushan/jenkins_mcp_server --env-file .env
|
|
232
268
|
```
|
|
233
269
|
|
|
234
|
-
[//]: # ([](https://www.npmjs.com/package/@rishibhushan/jenkins-mcp-server))
|
|
235
|
-
|
|
236
|
-
[//]: # ([](https://www.npmjs.com/package/@rishibhushan/jenkins-mcp-server))
|
|
237
|
-
|
|
238
270
|
---
|
|
239
271
|
|
|
240
272
|
This automatically:
|
|
@@ -471,13 +503,15 @@ if result['build_number']:
|
|
|
471
503
|
|
|
472
504
|
## š§ Troubleshooting
|
|
473
505
|
|
|
474
|
-
###
|
|
506
|
+
### Common Issues
|
|
507
|
+
|
|
508
|
+
#### Python Not Found
|
|
475
509
|
```
|
|
476
510
|
Error: Python 3 is required but not found.
|
|
477
511
|
```
|
|
478
512
|
**Solution**: Install Python 3.8+ from https://www.python.org/downloads/
|
|
479
513
|
|
|
480
|
-
|
|
514
|
+
#### Configuration Issues
|
|
481
515
|
```
|
|
482
516
|
ERROR: Jenkins configuration is incomplete!
|
|
483
517
|
```
|
|
@@ -495,7 +529,7 @@ env | grep JENKINS
|
|
|
495
529
|
cat ~/.config/Code/User/settings.json | grep jenkins
|
|
496
530
|
```
|
|
497
531
|
|
|
498
|
-
|
|
532
|
+
#### Connection Failed
|
|
499
533
|
```
|
|
500
534
|
Failed to connect to Jenkins at http://localhost:8080
|
|
501
535
|
```
|
|
@@ -505,7 +539,7 @@ Failed to connect to Jenkins at http://localhost:8080
|
|
|
505
539
|
3. Verify URL is correct (include port if needed)
|
|
506
540
|
4. Test authentication credentials
|
|
507
541
|
|
|
508
|
-
|
|
542
|
+
#### Dependency Installation Failed
|
|
509
543
|
```
|
|
510
544
|
Failed to install dependencies
|
|
511
545
|
```
|
|
@@ -514,6 +548,538 @@ Failed to install dependencies
|
|
|
514
548
|
2. If behind a proxy, set `HTTP_PROXY` and `HTTPS_PROXY` environment variables
|
|
515
549
|
3. Try manual installation: `.venv/bin/pip install -r requirements.txt`
|
|
516
550
|
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
### šØ VPN & Corporate Network Issues
|
|
554
|
+
|
|
555
|
+
If you're experiencing timeout issues with Claude Desktop or other MCP clients when using a VPN or corporate network, this section provides step-by-step solutions.
|
|
556
|
+
|
|
557
|
+
#### Symptom: Request Timeout After 60 Seconds
|
|
558
|
+
|
|
559
|
+
**Error in logs:**
|
|
560
|
+
```
|
|
561
|
+
McpError: MCP error -32001: Request timed out
|
|
562
|
+
Server transport closed unexpectedly
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
**Root Cause**: The Python process spawned by `npx` may not properly inherit VPN network routing, causing it to fail when connecting to internal Jenkins servers.
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
### Solution 1: Bypass Proxy for PyPI (For Dependency Installation Issues)
|
|
570
|
+
|
|
571
|
+
If you're getting proxy errors during dependency installation:
|
|
572
|
+
|
|
573
|
+
**Add to your `claude_desktop_config.json`:**
|
|
574
|
+
```json
|
|
575
|
+
{
|
|
576
|
+
"mcpServers": {
|
|
577
|
+
"jenkins": {
|
|
578
|
+
"command": "npx",
|
|
579
|
+
"args": [
|
|
580
|
+
"@rishibhushan/jenkins-mcp-server",
|
|
581
|
+
"--env-file",
|
|
582
|
+
"/path/to/.env"
|
|
583
|
+
],
|
|
584
|
+
"env": {
|
|
585
|
+
"NO_PROXY": "pypi.org,pypi.python.org,files.pythonhosted.org",
|
|
586
|
+
"PIP_NO_PROXY": "pypi.org,pypi.python.org,files.pythonhosted.org"
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
### Solution 2: Use Direct Python Execution (Recommended for VPN)
|
|
596
|
+
|
|
597
|
+
This bypasses the `npx` wrapper entirely and uses Python directly, which properly inherits your system's network routing.
|
|
598
|
+
|
|
599
|
+
#### Step 1: Locate the Installed Package
|
|
600
|
+
|
|
601
|
+
**For macOS/Linux:**
|
|
602
|
+
```bash
|
|
603
|
+
# Find the npx cache directory
|
|
604
|
+
PACKAGE_DIR=$(find ~/.npm/_npx -name "jenkins-mcp-server" -type d 2>/dev/null | head -1)
|
|
605
|
+
echo $PACKAGE_DIR
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
**For Windows (PowerShell):**
|
|
609
|
+
```powershell
|
|
610
|
+
# Find the npx cache directory
|
|
611
|
+
$PACKAGE_DIR = Get-ChildItem -Path "$env:LOCALAPPDATA\npm-cache\_npx" -Recurse -Directory -Filter "jenkins-mcp-server" | Select-Object -First 1 -ExpandProperty FullName
|
|
612
|
+
Write-Host $PACKAGE_DIR
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
The output will be something like:
|
|
616
|
+
- **macOS/Linux**: `/Users/username/.npm/_npx/<hash>/node_modules/@rishibhushan/jenkins-mcp-server`
|
|
617
|
+
- **Windows**: `C:\Users\username\AppData\Local\npm-cache\_npx\<hash>\node_modules\@rishibhushan\jenkins-mcp-server`
|
|
618
|
+
|
|
619
|
+
#### Step 2: Update Claude Desktop Configuration
|
|
620
|
+
|
|
621
|
+
Replace `<PACKAGE_DIR>` with the path from Step 1:
|
|
622
|
+
|
|
623
|
+
**macOS/Linux:**
|
|
624
|
+
```json
|
|
625
|
+
{
|
|
626
|
+
"mcpServers": {
|
|
627
|
+
"jenkins": {
|
|
628
|
+
"command": "<PACKAGE_DIR>/.venv/bin/python",
|
|
629
|
+
"args": [
|
|
630
|
+
"-m",
|
|
631
|
+
"jenkins_mcp_server",
|
|
632
|
+
"--env-file",
|
|
633
|
+
"/path/to/your/.env"
|
|
634
|
+
],
|
|
635
|
+
"env": {
|
|
636
|
+
"PYTHONPATH": "<PACKAGE_DIR>/src"
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
**Windows:**
|
|
644
|
+
```json
|
|
645
|
+
{
|
|
646
|
+
"mcpServers": {
|
|
647
|
+
"jenkins": {
|
|
648
|
+
"command": "<PACKAGE_DIR>\\.venv\\Scripts\\python.exe",
|
|
649
|
+
"args": [
|
|
650
|
+
"-m",
|
|
651
|
+
"jenkins_mcp_server",
|
|
652
|
+
"--env-file",
|
|
653
|
+
"C:\\path\\to\\your\\.env"
|
|
654
|
+
],
|
|
655
|
+
"env": {
|
|
656
|
+
"PYTHONPATH": "<PACKAGE_DIR>\\src"
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
#### Step 3: Example Configuration
|
|
664
|
+
|
|
665
|
+
**Complete example for macOS:**
|
|
666
|
+
```json
|
|
667
|
+
{
|
|
668
|
+
"mcpServers": {
|
|
669
|
+
"jenkins": {
|
|
670
|
+
"command": "/Users/username/.npm/_npx/a88b5f55f40c4229/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python",
|
|
671
|
+
"args": [
|
|
672
|
+
"-m",
|
|
673
|
+
"jenkins_mcp_server",
|
|
674
|
+
"--env-file",
|
|
675
|
+
"/Users/username/projects/jenkins_mcp_server/.env"
|
|
676
|
+
],
|
|
677
|
+
"env": {
|
|
678
|
+
"PYTHONPATH": "/Users/username/.npm/_npx/a88b5f55f40c4229/node_modules/@rishibhushan/jenkins-mcp-server/src"
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
#### Step 4: Restart Claude Desktop
|
|
686
|
+
|
|
687
|
+
1. **Connect to your VPN first**
|
|
688
|
+
2. Quit Claude Desktop completely
|
|
689
|
+
3. Start Claude Desktop
|
|
690
|
+
4. Check the MCP server connection in settings
|
|
691
|
+
|
|
692
|
+
---
|
|
693
|
+
|
|
694
|
+
### Solution 3: Use Local Git Clone (Best for Development)
|
|
695
|
+
|
|
696
|
+
If you're developing or frequently updating, use a local clone:
|
|
697
|
+
|
|
698
|
+
#### Step 1: Clone and Setup
|
|
699
|
+
```bash
|
|
700
|
+
# Clone the repository
|
|
701
|
+
git clone https://github.com/rishibhushan/jenkins_mcp_server.git
|
|
702
|
+
cd jenkins_mcp_server
|
|
703
|
+
|
|
704
|
+
# Create virtual environment and install dependencies
|
|
705
|
+
python3 -m venv .venv
|
|
706
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
707
|
+
pip install -r requirements.txt
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
#### Step 2: Configure Claude Desktop
|
|
711
|
+
|
|
712
|
+
**macOS/Linux:**
|
|
713
|
+
```json
|
|
714
|
+
{
|
|
715
|
+
"mcpServers": {
|
|
716
|
+
"jenkins": {
|
|
717
|
+
"command": "/path/to/jenkins_mcp_server/.venv/bin/python",
|
|
718
|
+
"args": [
|
|
719
|
+
"-m",
|
|
720
|
+
"jenkins_mcp_server",
|
|
721
|
+
"--env-file",
|
|
722
|
+
"/path/to/jenkins_mcp_server/.env"
|
|
723
|
+
],
|
|
724
|
+
"env": {
|
|
725
|
+
"PYTHONPATH": "/path/to/jenkins_mcp_server/src"
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
**Windows:**
|
|
733
|
+
```json
|
|
734
|
+
{
|
|
735
|
+
"mcpServers": {
|
|
736
|
+
"jenkins": {
|
|
737
|
+
"command": "C:\\path\\to\\jenkins_mcp_server\\.venv\\Scripts\\python.exe",
|
|
738
|
+
"args": [
|
|
739
|
+
"-m",
|
|
740
|
+
"jenkins_mcp_server",
|
|
741
|
+
"--env-file",
|
|
742
|
+
"C:\\path\\to\\jenkins_mcp_server\\.env"
|
|
743
|
+
],
|
|
744
|
+
"env": {
|
|
745
|
+
"PYTHONPATH": "C:\\path\\to\\jenkins_mcp_server\\src"
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
```
|
|
751
|
+
---
|
|
752
|
+
|
|
753
|
+
### Solution 4: Use Global Installation with Direct Python Path
|
|
754
|
+
|
|
755
|
+
If you prefer to use global installation but still face VPN/timeout issues, you can combine both approaches.
|
|
756
|
+
|
|
757
|
+
#### Step 1: Install Globally
|
|
758
|
+
|
|
759
|
+
**Disconnect from VPN first** (to avoid proxy issues during installation):
|
|
760
|
+
```bash
|
|
761
|
+
# Install globally
|
|
762
|
+
npm install -g @rishibhushan/jenkins-mcp-server
|
|
763
|
+
|
|
764
|
+
# Verify installation
|
|
765
|
+
jenkins-mcp-server --version
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
#### Step 2: Locate Global Installation Directory
|
|
769
|
+
|
|
770
|
+
**For macOS/Linux:**
|
|
771
|
+
```bash
|
|
772
|
+
# Find the global npm directory
|
|
773
|
+
npm root -g
|
|
774
|
+
|
|
775
|
+
# This typically returns something like:
|
|
776
|
+
# /usr/local/lib/node_modules
|
|
777
|
+
# or
|
|
778
|
+
# /Users/username/.npm-global/lib/node_modules
|
|
779
|
+
|
|
780
|
+
# Your package will be at:
|
|
781
|
+
# <npm-root>/@rishibhushan/jenkins-mcp-server
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
**For Windows (PowerShell):**
|
|
785
|
+
```powershell
|
|
786
|
+
# Find the global npm directory
|
|
787
|
+
npm root -g
|
|
788
|
+
|
|
789
|
+
# This typically returns something like:
|
|
790
|
+
# C:\Users\username\AppData\Roaming\npm\node_modules
|
|
791
|
+
|
|
792
|
+
# Your package will be at:
|
|
793
|
+
# <npm-root>\@rishibhushan\jenkins-mcp-server
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
#### Step 3: Find the Python Path
|
|
797
|
+
|
|
798
|
+
Once you know the installation directory:
|
|
799
|
+
|
|
800
|
+
**macOS/Linux:**
|
|
801
|
+
```bash
|
|
802
|
+
# If npm root -g shows: /usr/local/lib/node_modules
|
|
803
|
+
# Your Python path will be:
|
|
804
|
+
/usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python
|
|
805
|
+
|
|
806
|
+
# Verify it exists:
|
|
807
|
+
ls -la /usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
**Windows:**
|
|
811
|
+
```powershell
|
|
812
|
+
# If npm root -g shows: C:\Users\username\AppData\Roaming\npm\node_modules
|
|
813
|
+
# Your Python path will be:
|
|
814
|
+
C:\Users\username\AppData\Roaming\npm\node_modules\@rishibhushan\jenkins-mcp-server\.venv\Scripts\python.exe
|
|
815
|
+
|
|
816
|
+
# Verify it exists:
|
|
817
|
+
Test-Path "C:\Users\username\AppData\Roaming\npm\node_modules\@rishibhushan\jenkins-mcp-server\.venv\Scripts\python.exe"
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
#### Step 4: Configure Your MCP Client
|
|
821
|
+
|
|
822
|
+
**For Claude Desktop (macOS/Linux):**
|
|
823
|
+
```json
|
|
824
|
+
{
|
|
825
|
+
"mcpServers": {
|
|
826
|
+
"jenkins": {
|
|
827
|
+
"command": "/usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python",
|
|
828
|
+
"args": [
|
|
829
|
+
"-m",
|
|
830
|
+
"jenkins_mcp_server",
|
|
831
|
+
"--env-file",
|
|
832
|
+
"/path/to/your/.env"
|
|
833
|
+
],
|
|
834
|
+
"env": {
|
|
835
|
+
"PYTHONPATH": "/usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/src"
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
**For Claude Desktop (Windows):**
|
|
843
|
+
```json
|
|
844
|
+
{
|
|
845
|
+
"mcpServers": {
|
|
846
|
+
"jenkins": {
|
|
847
|
+
"command": "C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\@rishibhushan\\jenkins-mcp-server\\.venv\\Scripts\\python.exe",
|
|
848
|
+
"args": [
|
|
849
|
+
"-m",
|
|
850
|
+
"jenkins_mcp_server",
|
|
851
|
+
"--env-file",
|
|
852
|
+
"C:\\path\\to\\your\\.env"
|
|
853
|
+
],
|
|
854
|
+
"env": {
|
|
855
|
+
"PYTHONPATH": "C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\@rishibhushan\\jenkins-mcp-server\\src"
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
**For Other MCP Clients:**
|
|
863
|
+
|
|
864
|
+
Use the same pattern - replace the `command` with the direct Python path and set the `PYTHONPATH` environment variable.
|
|
865
|
+
|
|
866
|
+
#### Step 5: Test and Use
|
|
867
|
+
|
|
868
|
+
1. **Connect to your VPN**
|
|
869
|
+
2. **Restart your MCP client** (Claude Desktop, VS Code, etc.)
|
|
870
|
+
3. **Verify the connection** works
|
|
871
|
+
|
|
872
|
+
#### Why This Solution Works
|
|
873
|
+
|
|
874
|
+
- ā
**Persistent installation** - No need to download on each use
|
|
875
|
+
- ā
**Proper network routing** - Python process inherits VPN routing
|
|
876
|
+
- ā
**Works across sessions** - Survives VPN connect/disconnect cycles
|
|
877
|
+
- ā
**Easy updates** - Just run `npm update -g @rishibhushan/jenkins-mcp-server`
|
|
878
|
+
- ā
**Universal** - Works with any MCP client (Claude, VS Code, etc.)
|
|
879
|
+
|
|
880
|
+
#### Quick Reference Commands
|
|
881
|
+
```bash
|
|
882
|
+
# Find your global installation
|
|
883
|
+
npm root -g
|
|
884
|
+
|
|
885
|
+
# Update global installation
|
|
886
|
+
npm update -g @rishibhushan/jenkins-mcp-server
|
|
887
|
+
|
|
888
|
+
# Uninstall if needed
|
|
889
|
+
npm uninstall -g @rishibhushan/jenkins-mcp-server
|
|
890
|
+
|
|
891
|
+
# Test the Python path works
|
|
892
|
+
/path/to/global/installation/.venv/bin/python -m jenkins_mcp_server --help
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
---
|
|
896
|
+
|
|
897
|
+
### š§Ŗ Testing Your Connection
|
|
898
|
+
|
|
899
|
+
Before configuring MCP clients, test your Jenkins connection manually:
|
|
900
|
+
|
|
901
|
+
#### Create a Test Script
|
|
902
|
+
|
|
903
|
+
Save this as `test_jenkins_connection.py`:
|
|
904
|
+
|
|
905
|
+
```python
|
|
906
|
+
#!/usr/bin/env python3
|
|
907
|
+
"""
|
|
908
|
+
Test Jenkins connectivity for MCP server troubleshooting
|
|
909
|
+
"""
|
|
910
|
+
import os
|
|
911
|
+
import sys
|
|
912
|
+
import time
|
|
913
|
+
import requests
|
|
914
|
+
from dotenv import load_dotenv
|
|
915
|
+
|
|
916
|
+
def test_connection():
|
|
917
|
+
# Load environment
|
|
918
|
+
env_file = '/path/to/your/.env' # Update this path
|
|
919
|
+
print(f"Loading environment from: {env_file}")
|
|
920
|
+
load_dotenv(env_file)
|
|
921
|
+
|
|
922
|
+
url = os.getenv('JENKINS_URL')
|
|
923
|
+
username = os.getenv('JENKINS_USERNAME')
|
|
924
|
+
token = os.getenv('JENKINS_TOKEN')
|
|
925
|
+
|
|
926
|
+
print(f"\nJenkins Configuration:")
|
|
927
|
+
print(f" URL: {url}")
|
|
928
|
+
print(f" Username: {username}")
|
|
929
|
+
print(f" Token: {'***' if token else 'NOT SET'}")
|
|
930
|
+
|
|
931
|
+
# Test 1: DNS Resolution
|
|
932
|
+
print(f"\n[Test 1] Testing DNS resolution...")
|
|
933
|
+
import socket
|
|
934
|
+
try:
|
|
935
|
+
hostname = url.split('://')[1].split(':')[0]
|
|
936
|
+
ip = socket.gethostbyname(hostname)
|
|
937
|
+
print(f" ā DNS resolved: {hostname} -> {ip}")
|
|
938
|
+
except Exception as e:
|
|
939
|
+
print(f" ā DNS resolution failed: {e}")
|
|
940
|
+
return False
|
|
941
|
+
|
|
942
|
+
# Test 2: Basic connectivity
|
|
943
|
+
print(f"\n[Test 2] Testing basic HTTP connectivity...")
|
|
944
|
+
try:
|
|
945
|
+
start = time.time()
|
|
946
|
+
response = requests.get(f"{url}/api/json", timeout=5)
|
|
947
|
+
elapsed = time.time() - start
|
|
948
|
+
print(f" ā Connection successful (no auth): {response.status_code} in {elapsed:.2f}s")
|
|
949
|
+
except requests.exceptions.Timeout:
|
|
950
|
+
print(f" ā Connection timed out after 5 seconds")
|
|
951
|
+
return False
|
|
952
|
+
except Exception as e:
|
|
953
|
+
print(f" ā Connection failed: {e}")
|
|
954
|
+
return False
|
|
955
|
+
|
|
956
|
+
# Test 3: Authenticated request
|
|
957
|
+
print(f"\n[Test 3] Testing authenticated request...")
|
|
958
|
+
try:
|
|
959
|
+
start = time.time()
|
|
960
|
+
response = requests.get(
|
|
961
|
+
f"{url}/api/json",
|
|
962
|
+
auth=(username, token),
|
|
963
|
+
timeout=10
|
|
964
|
+
)
|
|
965
|
+
elapsed = time.time() - start
|
|
966
|
+
print(f" ā Authenticated request: {response.status_code} in {elapsed:.2f}s")
|
|
967
|
+
|
|
968
|
+
if response.status_code == 200:
|
|
969
|
+
data = response.json()
|
|
970
|
+
print(f" ā Jenkins version: {data.get('version', 'unknown')}")
|
|
971
|
+
print(f" ā Number of jobs: {len(data.get('jobs', []))}")
|
|
972
|
+
elif response.status_code == 401:
|
|
973
|
+
print(f" ā Authentication failed - check username/token")
|
|
974
|
+
return False
|
|
975
|
+
elif response.status_code == 403:
|
|
976
|
+
print(f" ā Access forbidden - check permissions")
|
|
977
|
+
return False
|
|
978
|
+
except Exception as e:
|
|
979
|
+
print(f" ā Authenticated request failed: {e}")
|
|
980
|
+
return False
|
|
981
|
+
|
|
982
|
+
# Test 4: python-jenkins library
|
|
983
|
+
print(f"\n[Test 4] Testing python-jenkins library...")
|
|
984
|
+
try:
|
|
985
|
+
import jenkins
|
|
986
|
+
start = time.time()
|
|
987
|
+
server = jenkins.Jenkins(url, username=username, password=token)
|
|
988
|
+
user = server.get_whoami()
|
|
989
|
+
elapsed = time.time() - start
|
|
990
|
+
print(f" ā python-jenkins connection: {user['fullName']} in {elapsed:.2f}s")
|
|
991
|
+
except Exception as e:
|
|
992
|
+
print(f" ā python-jenkins failed: {e}")
|
|
993
|
+
return False
|
|
994
|
+
|
|
995
|
+
print(f"\nā All tests passed! Jenkins MCP Server should work.")
|
|
996
|
+
return True
|
|
997
|
+
|
|
998
|
+
if __name__ == "__main__":
|
|
999
|
+
print("=" * 60)
|
|
1000
|
+
print("Jenkins MCP Server - Connection Diagnostic")
|
|
1001
|
+
print("=" * 60)
|
|
1002
|
+
|
|
1003
|
+
success = test_connection()
|
|
1004
|
+
sys.exit(0 if success else 1)
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
#### Run the Test
|
|
1008
|
+
|
|
1009
|
+
```bash
|
|
1010
|
+
# Connect to VPN first
|
|
1011
|
+
# Then run:
|
|
1012
|
+
cd /path/to/jenkins_mcp_server
|
|
1013
|
+
source .venv/bin/activate
|
|
1014
|
+
python test_jenkins_connection.py
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
**Expected output if everything works:**
|
|
1018
|
+
```
|
|
1019
|
+
============================================================
|
|
1020
|
+
Jenkins MCP Server - Connection Diagnostic
|
|
1021
|
+
============================================================
|
|
1022
|
+
|
|
1023
|
+
[Test 1] Testing DNS resolution...
|
|
1024
|
+
ā DNS resolved: jenkins.example.com -> 10.0.0.1
|
|
1025
|
+
|
|
1026
|
+
[Test 2] Testing basic HTTP connectivity...
|
|
1027
|
+
ā Connection successful (no auth): 200 in 0.45s
|
|
1028
|
+
|
|
1029
|
+
[Test 3] Testing authenticated request...
|
|
1030
|
+
ā Authenticated request: 200 in 0.52s
|
|
1031
|
+
ā Jenkins version: 2.401.3
|
|
1032
|
+
ā Number of jobs: 42
|
|
1033
|
+
|
|
1034
|
+
[Test 4] Testing python-jenkins library...
|
|
1035
|
+
ā python-jenkins connection: John Doe in 0.38s
|
|
1036
|
+
|
|
1037
|
+
ā All tests passed! Jenkins MCP Server should work.
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
If all tests pass but MCP still fails, use Solution 2 (Direct Python Execution).
|
|
1041
|
+
|
|
1042
|
+
---
|
|
1043
|
+
|
|
1044
|
+
### š Still Having Issues?
|
|
1045
|
+
|
|
1046
|
+
If you're still experiencing problems after trying the solutions above:
|
|
1047
|
+
|
|
1048
|
+
1. **Check Claude Desktop logs:**
|
|
1049
|
+
- **macOS**: `~/Library/Logs/Claude/mcp-server-jenkins.log`
|
|
1050
|
+
- **Windows**: `%APPDATA%\Claude\logs\mcp-server-jenkins.log`
|
|
1051
|
+
- **Linux**: `~/.config/Claude/logs/mcp-server-jenkins.log`
|
|
1052
|
+
|
|
1053
|
+
2. **Enable verbose logging** by adding `--verbose` to args:
|
|
1054
|
+
```json
|
|
1055
|
+
"args": [
|
|
1056
|
+
"-m",
|
|
1057
|
+
"jenkins_mcp_server",
|
|
1058
|
+
"--env-file",
|
|
1059
|
+
"/path/to/.env",
|
|
1060
|
+
"--verbose"
|
|
1061
|
+
]
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
3. **Verify VPN is active** before starting Claude Desktop:
|
|
1065
|
+
```bash
|
|
1066
|
+
# Test if you can reach your Jenkins server
|
|
1067
|
+
curl -I http://your-jenkins-server:8080
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
4. **Check if other tools can reach Jenkins** while on VPN:
|
|
1071
|
+
- Try accessing Jenkins in your browser
|
|
1072
|
+
- Try `curl` from terminal
|
|
1073
|
+
- If both work but MCP doesn't, use Solution 2
|
|
1074
|
+
|
|
1075
|
+
5. **Open an issue** with:
|
|
1076
|
+
- Your operating system
|
|
1077
|
+
- Claude Desktop log file
|
|
1078
|
+
- Output of the connection test script
|
|
1079
|
+
- Your configuration (with credentials redacted)
|
|
1080
|
+
|
|
1081
|
+
---
|
|
1082
|
+
|
|
517
1083
|
### Enable Debug Logging
|
|
518
1084
|
|
|
519
1085
|
Run with verbose flag to see detailed logs:
|
package/package.json
CHANGED