@purplesquirrel/ibmz-mcp-server 1.0.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.
@@ -0,0 +1,21 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 10
8
+ labels:
9
+ - "dependencies"
10
+ commit-message:
11
+ prefix: "chore(deps)"
12
+
13
+ - package-ecosystem: "github-actions"
14
+ directory: "/"
15
+ schedule:
16
+ interval: "weekly"
17
+ labels:
18
+ - "dependencies"
19
+ - "github-actions"
20
+ commit-message:
21
+ prefix: "chore(ci)"
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [18.x, 20.x]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Run linter
30
+ run: npm run lint --if-present
31
+
32
+ - name: Run tests
33
+ run: npm test --if-present
34
+
35
+ - name: Build
36
+ run: npm run build --if-present
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Purple Squirrel Media
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.
package/README.md ADDED
@@ -0,0 +1,217 @@
1
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
+ [![MCP](https://img.shields.io/badge/MCP-Server-blue)](https://modelcontextprotocol.io)
3
+ [![IBM Z](https://img.shields.io/badge/IBM-Z_Mainframe-052FAD)](https://www.ibm.com/z)
4
+ [![CI](https://github.com/PurpleSquirrelMedia/ibmz-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/PurpleSquirrelMedia/ibmz-mcp-server/actions/workflows/ci.yml)
5
+
6
+ # IBM Z MCP Server
7
+
8
+ MCP server for IBM Z mainframe integration with Claude Code. Provides access to enterprise-grade security and mainframe capabilities.
9
+
10
+ ## Features
11
+
12
+ - **Key Protect** - HSM-backed key management (FIPS 140-2 Level 3)
13
+ - **z/OS Connect** - REST APIs to mainframe programs (CICS, IMS, batch)
14
+
15
+ ## Available Tools
16
+
17
+ ### Key Protect (HSM Key Management)
18
+
19
+ | Tool | Description |
20
+ |------|-------------|
21
+ | `key_protect_list_keys` | List encryption keys in Key Protect |
22
+ | `key_protect_create_key` | Create root or standard keys |
23
+ | `key_protect_get_key` | Get key details and metadata |
24
+ | `key_protect_wrap_key` | Wrap (encrypt) DEKs with a root key |
25
+ | `key_protect_unwrap_key` | Unwrap (decrypt) wrapped DEKs |
26
+ | `key_protect_rotate_key` | Rotate a root key |
27
+ | `key_protect_delete_key` | Delete a key (irreversible) |
28
+ | `key_protect_get_key_policies` | Get key policies |
29
+
30
+ ### z/OS Connect (Mainframe Integration)
31
+
32
+ | Tool | Description |
33
+ |------|-------------|
34
+ | `zos_connect_list_services` | List available mainframe services |
35
+ | `zos_connect_get_service` | Get service details and OpenAPI spec |
36
+ | `zos_connect_call_service` | Call a mainframe service via REST |
37
+ | `zos_connect_list_apis` | List API requester configurations |
38
+ | `zos_connect_health` | Check z/OS Connect server health |
39
+
40
+ ## Setup
41
+
42
+ ### 1. Install Dependencies
43
+
44
+ ```bash
45
+ cd ~/ibmz-mcp-server
46
+ npm install
47
+ ```
48
+
49
+ ### 2. Configure Environment
50
+
51
+ **For Key Protect:**
52
+ ```bash
53
+ IBM_CLOUD_API_KEY=your-ibm-cloud-api-key
54
+ KEY_PROTECT_INSTANCE_ID=your-key-protect-instance-id
55
+ KEY_PROTECT_URL=https://us-south.kms.cloud.ibm.com
56
+ ```
57
+
58
+ **For z/OS Connect (requires mainframe access):**
59
+ ```bash
60
+ ZOS_CONNECT_URL=https://your-mainframe:9443/zosConnect
61
+ ZOS_CONNECT_USERNAME=your-username
62
+ ZOS_CONNECT_PASSWORD=your-password
63
+ ```
64
+
65
+ ### 3. Add to Claude Code
66
+
67
+ Add to `~/.claude.json`:
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "ibmz": {
73
+ "type": "stdio",
74
+ "command": "node",
75
+ "args": ["/Users/matthewkarsten/ibmz-mcp-server/index.js"],
76
+ "env": {
77
+ "IBM_CLOUD_API_KEY": "your-api-key",
78
+ "KEY_PROTECT_INSTANCE_ID": "your-instance-id"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ ## Architecture
86
+
87
+ ```
88
+ Claude Code (Opus 4.5)
89
+
90
+ └──▶ IBM Z MCP Server
91
+
92
+ ├──▶ Key Protect (HSM)
93
+ │ │
94
+ │ └── FIPS 140-2 Level 3 HSM
95
+
96
+ └──▶ z/OS Connect
97
+
98
+ ├── CICS Transactions
99
+ ├── IMS Programs
100
+ └── Batch Jobs
101
+ ```
102
+
103
+ ## Key Concepts
104
+
105
+ ### Envelope Encryption with Key Protect
106
+
107
+ Key Protect enables envelope encryption:
108
+
109
+ 1. **Root Keys (KEK)** - Stored in HSM, never leave the hardware
110
+ 2. **Data Encryption Keys (DEK)** - Wrapped by root keys
111
+ 3. **Wrap/Unwrap** - Operations to protect DEKs
112
+
113
+ ```
114
+ Data → Encrypt with DEK → Ciphertext
115
+ DEK → Wrap with KEK → Wrapped DEK (stored alongside ciphertext)
116
+ ```
117
+
118
+ ### z/OS Connect Integration
119
+
120
+ z/OS Connect provides REST APIs to mainframe programs:
121
+
122
+ - **CICS** - Online transaction processing
123
+ - **IMS** - Hierarchical database and transactions
124
+ - **Batch** - Scheduled batch processing
125
+ - **Db2** - Relational database access
126
+
127
+ JSON payloads are automatically mapped to COBOL copybooks.
128
+
129
+ ## Use Cases
130
+
131
+ ### Enterprise Key Management
132
+ - Manage encryption keys for cloud workloads
133
+ - Bring Your Own Key (BYOK) to IBM Cloud services
134
+ - Key rotation for compliance
135
+ - Envelope encryption for data at rest
136
+
137
+ ### Mainframe Modernization
138
+ - Expose COBOL programs as REST APIs
139
+ - Integrate mainframe data with cloud applications
140
+ - AI-powered mainframe operations via Claude
141
+ - Modernize without rewriting legacy code
142
+
143
+ ## IBM Cloud Resources
144
+
145
+ This MCP server can use:
146
+ - **Service**: Key Protect
147
+ - **Plan**: Tiered (first 20 keys free)
148
+ - **Region**: us-south
149
+
150
+ For z/OS Connect, you need:
151
+ - IBM mainframe with z/OS
152
+ - z/OS Connect EE installed
153
+ - Network access from your machine
154
+
155
+ ## Demo Scripts
156
+
157
+ Run these demos to test the integration:
158
+
159
+ ```bash
160
+ # Set environment
161
+ export IBM_CLOUD_API_KEY="your-key"
162
+ export KEY_PROTECT_INSTANCE_ID="your-instance-id"
163
+
164
+ # Full 5-service pipeline (NLU → watsonx → Key Protect → Cloudant → TTS)
165
+ node demo-full-stack.js
166
+
167
+ # End-to-end workflow (NLU → Key Protect → Cloudant)
168
+ node demo-e2e-workflow.js
169
+
170
+ # Test envelope encryption (HSM wrap/unwrap)
171
+ node test-envelope-encryption.js
172
+
173
+ # Watson services suite test
174
+ node demo-watson-suite.js
175
+ ```
176
+
177
+ ### Integration Status (Verified Dec 15, 2025)
178
+
179
+ | Service | Feature | Status |
180
+ |---------|---------|--------|
181
+ | Key Protect | List Keys | ✅ Working |
182
+ | Key Protect | Create Key | ✅ Working |
183
+ | Key Protect | Wrap DEK | ✅ Working |
184
+ | Key Protect | Unwrap DEK | ✅ Working |
185
+ | Key Protect | Rotate Key | ✅ Working |
186
+ | watsonx.ai | List Models | ✅ Working |
187
+ | Watson NLU | Sentiment/Entities | ✅ Working |
188
+ | Watson TTS | Voice Synthesis | ✅ Working |
189
+ | Cloudant | Document Storage | ✅ Working |
190
+
191
+ ## Files
192
+
193
+ ```
194
+ ibmz-mcp-server/
195
+ ├── index.js # MCP server implementation
196
+ ├── package.json # Dependencies
197
+ ├── docs/ # GitHub Pages documentation
198
+ │ ├── index.html # Main documentation
199
+ │ └── specs.html # Technical specifications
200
+ ├── demo-full-stack.js # Full 5-service pipeline
201
+ ├── demo-e2e-workflow.js # NLU → Key Protect → Cloudant
202
+ ├── demo-watson-suite.js # All Watson services test
203
+ ├── test-envelope-encryption.js # HSM wrap/unwrap test
204
+ └── README.md # This file
205
+ ```
206
+
207
+ ## Related MCP Servers
208
+
209
+ - [watsonx-mcp-server](https://github.com/PurpleSquirrelMedia/watsonx-mcp-server) - Foundation models (Granite, Llama, Mistral)
210
+
211
+ ## Author
212
+
213
+ Matthew Karsten
214
+
215
+ ## License
216
+
217
+ MIT
@@ -0,0 +1,241 @@
1
+ # Troubleshooting Guide
2
+
3
+ Common issues and solutions for the IBM Z MCP Server.
4
+
5
+ ## Key Protect Issues
6
+
7
+ ### `401 Unauthorized`
8
+
9
+ **Cause**: Invalid or expired IBM Cloud API key.
10
+
11
+ **Solutions**:
12
+ 1. Generate a new API key in IBM Cloud console
13
+ 2. Verify key has Key Protect service access
14
+ 3. Check IAM permissions include "Key Protect Reader" or higher
15
+
16
+ ### `403 Forbidden - Insufficient permissions`
17
+
18
+ **Cause**: API key lacks required Key Protect permissions.
19
+
20
+ **Solutions**:
21
+ 1. In IBM Cloud IAM, assign one of these roles:
22
+ - **Reader**: List and view keys
23
+ - **Writer**: Create, wrap, unwrap keys
24
+ - **Manager**: Full access including delete and rotate
25
+ 2. Wait 5 minutes for IAM changes to propagate
26
+
27
+ ### `Key not found`
28
+
29
+ **Cause**: Key ID doesn't exist or wrong instance.
30
+
31
+ **Solutions**:
32
+ 1. Verify `KEY_PROTECT_INSTANCE_ID` is correct
33
+ 2. Use `key_protect_list_keys` to see available keys
34
+ 3. Check you're using the key ID, not the key name
35
+
36
+ ### `Instance not found`
37
+
38
+ **Cause**: Invalid Key Protect instance ID.
39
+
40
+ **Solution**:
41
+ 1. Go to IBM Cloud > Resource List > Key Protect
42
+ 2. Click your instance
43
+ 3. Copy the GUID from the URL: `https://cloud.ibm.com/services/kms/KEY_PROTECT_INSTANCE_ID`
44
+
45
+ ### `Wrap/Unwrap failed`
46
+
47
+ **Cause**: Using wrong key type or invalid ciphertext.
48
+
49
+ **Solutions**:
50
+ 1. Only **root keys** can wrap/unwrap (not standard keys)
51
+ 2. For unwrap, use the exact ciphertext returned by wrap
52
+ 3. Check key hasn't been rotated (re-wrap with new version)
53
+
54
+ ### `Key rotation failed`
55
+
56
+ **Cause**: Can't rotate standard keys or key is disabled.
57
+
58
+ **Solutions**:
59
+ 1. Only root keys support rotation
60
+ 2. Check key state is "Active"
61
+ 3. Verify Manager role permissions
62
+
63
+ ## z/OS Connect Issues
64
+
65
+ ### `Connection refused`
66
+
67
+ **Cause**: z/OS Connect server not reachable.
68
+
69
+ **Solutions**:
70
+ 1. Verify `ZOS_CONNECT_URL` format: `https://host:port/zosConnect`
71
+ 2. Check firewall allows connection to mainframe
72
+ 3. Confirm z/OS Connect EE is running:
73
+ ```bash
74
+ # On z/OS
75
+ /D A,ZCON*
76
+ ```
77
+ 4. Test with curl:
78
+ ```bash
79
+ curl -k -u user:pass https://your-mainframe:9443/zosConnect/services
80
+ ```
81
+
82
+ ### `401 Unauthorized` (z/OS)
83
+
84
+ **Cause**: Invalid mainframe credentials.
85
+
86
+ **Solutions**:
87
+ 1. Verify `ZOS_CONNECT_USERNAME` and `ZOS_CONNECT_PASSWORD`
88
+ 2. Check RACF/ACF2/TSS password hasn't expired
89
+ 3. Ensure user ID has access to z/OS Connect resources
90
+
91
+ ### `Service not found`
92
+
93
+ **Cause**: Service not deployed or wrong name.
94
+
95
+ **Solutions**:
96
+ 1. Use `zos_connect_list_services` to see available services
97
+ 2. Check service is deployed in z/OS Connect
98
+ 3. Service names are case-sensitive
99
+
100
+ ### `500 Internal Server Error`
101
+
102
+ **Cause**: Mainframe program failed.
103
+
104
+ **Solutions**:
105
+ 1. Check z/OS Connect server logs
106
+ 2. Verify CICS region/IMS system is active
107
+ 3. Review COBOL program for ABEND codes
108
+ 4. Check input data matches copybook format
109
+
110
+ ### `CICS transaction failed`
111
+
112
+ **Cause**: Transaction abend or timeout.
113
+
114
+ **Solutions**:
115
+ 1. Check CICS logs for abend code (e.g., ASRA, AICA)
116
+ 2. Increase transaction timeout if needed
117
+ 3. Verify CICS region resources (files, queues)
118
+ 4. Check transaction is installed and enabled
119
+
120
+ ### `JSON mapping error`
121
+
122
+ **Cause**: JSON doesn't match COBOL copybook.
123
+
124
+ **Solutions**:
125
+ 1. Review the service's OpenAPI specification
126
+ 2. Match field names exactly (case-sensitive)
127
+ 3. Use correct data types (string for PIC X, number for PIC 9)
128
+ 4. Check field lengths don't exceed copybook definitions
129
+
130
+ ## Configuration Issues
131
+
132
+ ### `Missing environment variable`
133
+
134
+ **Cause**: Required env var not set.
135
+
136
+ **Required for Key Protect**:
137
+ ```bash
138
+ export IBM_CLOUD_API_KEY="your-key"
139
+ export KEY_PROTECT_INSTANCE_ID="your-instance-id"
140
+ export KEY_PROTECT_URL="https://us-south.kms.cloud.ibm.com"
141
+ ```
142
+
143
+ **Required for z/OS Connect**:
144
+ ```bash
145
+ export ZOS_CONNECT_URL="https://host:port/zosConnect"
146
+ export ZOS_CONNECT_USERNAME="user"
147
+ export ZOS_CONNECT_PASSWORD="password"
148
+ ```
149
+
150
+ ### `Invalid region URL`
151
+
152
+ **Key Protect regions**:
153
+ ```bash
154
+ # US South (Dallas)
155
+ KEY_PROTECT_URL=https://us-south.kms.cloud.ibm.com
156
+
157
+ # US East (Washington DC)
158
+ KEY_PROTECT_URL=https://us-east.kms.cloud.ibm.com
159
+
160
+ # EU Germany (Frankfurt)
161
+ KEY_PROTECT_URL=https://eu-de.kms.cloud.ibm.com
162
+
163
+ # EU Great Britain (London)
164
+ KEY_PROTECT_URL=https://eu-gb.kms.cloud.ibm.com
165
+
166
+ # Asia Pacific (Tokyo)
167
+ KEY_PROTECT_URL=https://jp-tok.kms.cloud.ibm.com
168
+
169
+ # Asia Pacific (Sydney)
170
+ KEY_PROTECT_URL=https://au-syd.kms.cloud.ibm.com
171
+ ```
172
+
173
+ ## MCP Server Issues
174
+
175
+ ### Server not appearing in Claude Code
176
+
177
+ **Solutions**:
178
+ 1. Verify `~/.claude.json` syntax is valid JSON
179
+ 2. Check path to `index.js` is correct
180
+ 3. Restart Claude Code after config changes
181
+ 4. Test server directly: `node /path/to/index.js`
182
+
183
+ ### `Cannot find module` errors
184
+
185
+ **Solution**:
186
+ ```bash
187
+ cd ~/ibmz-mcp-server
188
+ npm install
189
+ ```
190
+
191
+ ### SSL certificate errors
192
+
193
+ **Cause**: Self-signed cert on z/OS Connect.
194
+
195
+ **Solutions**:
196
+ 1. Add CA certificate to Node.js:
197
+ ```bash
198
+ export NODE_EXTRA_CA_CERTS=/path/to/cert.pem
199
+ ```
200
+ 2. Or disable verification (development only):
201
+ ```bash
202
+ export NODE_TLS_REJECT_UNAUTHORIZED=0
203
+ ```
204
+
205
+ ## Debugging
206
+
207
+ ### Enable verbose logging
208
+
209
+ ```bash
210
+ # Run server directly to see errors
211
+ DEBUG=* node /path/to/ibmz-mcp-server/index.js
212
+ ```
213
+
214
+ ### Test Key Protect connection
215
+
216
+ ```bash
217
+ # Get IAM token
218
+ TOKEN=$(curl -s -X POST "https://iam.cloud.ibm.com/identity/token" \
219
+ -H "Content-Type: application/x-www-form-urlencoded" \
220
+ -d "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBM_CLOUD_API_KEY" \
221
+ | jq -r '.access_token')
222
+
223
+ # List keys
224
+ curl -s "https://us-south.kms.cloud.ibm.com/api/v2/keys" \
225
+ -H "Authorization: Bearer $TOKEN" \
226
+ -H "Bluemix-Instance: $KEY_PROTECT_INSTANCE_ID"
227
+ ```
228
+
229
+ ### Test z/OS Connect
230
+
231
+ ```bash
232
+ curl -k -u $ZOS_CONNECT_USERNAME:$ZOS_CONNECT_PASSWORD \
233
+ "$ZOS_CONNECT_URL/services"
234
+ ```
235
+
236
+ ## Getting Help
237
+
238
+ - [Key Protect Documentation](https://cloud.ibm.com/docs/key-protect)
239
+ - [z/OS Connect Documentation](https://www.ibm.com/docs/en/zosconnect)
240
+ - [IBM Cloud Status](https://cloud.ibm.com/status)
241
+ - [GitHub Issues](https://github.com/PurpleSquirrelMedia/ibmz-mcp-server/issues)