code-engine-mcp-server 1.0.4 β†’ 1.0.7

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.
@@ -1,220 +1,315 @@
1
- # Quick Setup Instructions for Bob/Cline
1
+ # Setup Instructions for MCP Clients
2
2
 
3
- Follow these steps to enable Bob to understand Docker and Code Engine commands.
3
+ Follow these steps to connect any AI assistant to IBM Code Engine and Docker/Podman via the MCP server.
4
4
 
5
- > **VS Code + Copilot (no Cline):** If you use GitHub Copilot’s built-in MCP support in VS Code **1.101+** and want the published server via `npx` without editing `mcp.json`, use the optional **IBM Code Engine MCP** extension instead. See [vscode-extension/README.md](../vscode-extension/README.md) and the **Configuration** section in the [main README](../README.md).
5
+ ---
6
6
 
7
- ## Step 1: Verify the Build
7
+ ## πŸ”‘ Step 1: Get an IBM Cloud API key
8
8
 
9
- The MCP server has been built successfully. Verify it exists:
9
+ All Code Engine and ICR operations require an IBM Cloud API key.
10
+
11
+ 1. Go to **[IBM Cloud IAM β†’ API keys](https://cloud.ibm.com/iam/apikeys)**
12
+ 2. Click **Create an IBM Cloud API key**
13
+ 3. Give it a name (e.g. `code-engine-mcp`) and copy the value β€” you won't see it again
14
+
15
+ Keep it in a password manager. You'll use it in one of the options below.
16
+
17
+ ---
18
+
19
+ ## πŸ” Step 2: Decide how to store the API key
20
+
21
+ Never paste your API key directly into a file you might commit to git. Three options are available β€” choose one and use it consistently across all client configs below.
22
+
23
+ ### Option A β€” Shell environment variable (most secure, recommended)
24
+
25
+ Copy the template and fill in your key:
10
26
 
11
27
  ```bash
12
- ls -la /Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js
28
+ # from the repo root
29
+ cp .env.example .env # .env is already in .gitignore
30
+ ```
31
+
32
+ Edit `.env`:
33
+ ```
34
+ IBMCLOUD_API_KEY=your-ibm-cloud-api-key-here
35
+ ```
36
+
37
+ Load it into your current shell (or add the `export` line to `~/.zshrc` / `~/.bash_profile` for permanence):
38
+
39
+ ```bash
40
+ source .env
41
+ # or permanently:
42
+ echo 'export IBMCLOUD_API_KEY="your-key"' >> ~/.zshrc
43
+ ```
44
+
45
+ In any MCP config file, reference it without embedding the value:
46
+ ```json
47
+ "IBMCLOUD_API_KEY": "${env:IBMCLOUD_API_KEY}"
48
+ ```
49
+
50
+ > `${env:VARIABLE}` is VS Code's input-substitution syntax β€” it reads the value from your shell environment when the server starts. The key never appears in the config file.
51
+
52
+ ---
53
+
54
+ ### Option B β€” VS Code input variable (prompted on connect)
55
+
56
+ VS Code can ask you for the key each time it starts the MCP server. Good for shared or public machines.
57
+
58
+ Add an `inputs` block at the top level of your `mcp.json` (or `.vscode/mcp.json`):
59
+
60
+ ```json
61
+ {
62
+ "inputs": [
63
+ {
64
+ "id": "ibmcloud-api-key",
65
+ "type": "promptString",
66
+ "description": "IBM Cloud API key",
67
+ "password": true
68
+ }
69
+ ],
70
+ "servers": {
71
+ "code-engine": {
72
+ "type": "stdio",
73
+ "command": "npx",
74
+ "args": ["-y", "code-engine-mcp-server@latest"],
75
+ "env": {
76
+ "IBMCLOUD_API_KEY": "${input:ibmcloud-api-key}",
77
+ "IBMCLOUD_REGION": "us-south"
78
+ }
79
+ }
80
+ }
81
+ }
13
82
  ```
14
83
 
15
- You should see the compiled JavaScript file.
84
+ VS Code shows a masked password prompt when the server starts. The key is never written to disk.
85
+
86
+ ---
16
87
 
17
- ## Step 2: Configure Cline in VSCode
88
+ ### Option C β€” Inline value (simplest, least secure)
18
89
 
19
- 1. **Open VSCode Settings**
20
- - Press `Cmd + ,` (Mac) or `Ctrl + ,` (Windows/Linux)
21
- - Or go to: Code β†’ Settings β†’ Settings
90
+ Paste the key directly into the config. Only do this on a personal machine and make sure the file is in `.gitignore`.
22
91
 
23
- 2. **Search for MCP Settings**
24
- - Type "Cline MCP" in the search bar
25
- - Look for "Cline: MCP Settings"
92
+ ```json
93
+ "IBMCLOUD_API_KEY": "your-ibm-cloud-api-key-here"
94
+ ```
95
+
96
+ > **Security:** Add the config file to `.gitignore` and never commit it. Prefer Option A or B whenever possible.
26
97
 
27
- 3. **Edit settings.json**
28
- - Click "Edit in settings.json" link
29
- - This will open your VSCode settings file
98
+ ---
30
99
 
31
- 4. **Add the MCP Server Configuration**
32
-
33
- Copy and paste this configuration into your settings.json:
100
+ ## βš™οΈ Step 3: Configure your client
34
101
 
35
- ```json
36
- {
37
- "cline.mcpServers": {
38
- "code-engine": {
39
- "command": "node",
40
- "args": [
41
- "/Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js"
42
- ],
43
- "env": {
44
- "IBMCLOUD_API_KEY": "YOUR_IBMCLOUD_API_KEY_HERE"
45
- }
46
- }
47
- }
48
- }
49
- ```
102
+ Choose your IDE or client below. Each config uses the `${env:IBMCLOUD_API_KEY}` pattern (Option A). Swap in the Option B or C value if you prefer one of those approaches.
50
103
 
51
- 5. **Replace YOUR_IBMCLOUD_API_KEY_HERE**
52
- - Get your IBM Cloud API key from: https://cloud.ibm.com/iam/apikeys
53
- - Replace the placeholder with your actual API key
54
- - Keep the quotes around the key
104
+ ---
55
105
 
56
- 6. **Save the file**
57
- - Press `Cmd + S` (Mac) or `Ctrl + S` (Windows/Linux)
106
+ ### 1. VS Code + GitHub Copilot β€” extension (easiest)
58
107
 
59
- ## Step 3: Restart Cline/Bob
108
+ The official extension handles server startup, API key storage, and MCP registration automatically β€” no `mcp.json` editing required.
60
109
 
61
- 1. **Reload VSCode Window**
62
- - Press `Cmd + Shift + P` (Mac) or `Ctrl + Shift + P` (Windows/Linux)
63
- - Type "Reload Window"
64
- - Press Enter
110
+ | Platform | Install |
111
+ |---|---|
112
+ | VS Code Marketplace | [MarkusvanKempen.code-engine-mcp](https://marketplace.visualstudio.com/items?itemName=MarkusvanKempen.code-engine-mcp) |
113
+ | Open VSX (Cursor / Theia / Gitpod / Codium) | [markusvankempen.code-engine-mcp](https://open-vsx.org/extension/markusvankempen/code-engine-mcp) |
65
114
 
66
- 2. **Or Restart Cline**
67
- - Open Cline sidebar
68
- - Look for restart/reload option
115
+ After installing:
69
116
 
70
- ## Step 4: Verify the Connection
117
+ 1. Open the **IBM Code Engine MCP** sidebar panel (cloud icon in the Activity Bar)
118
+ 2. Paste your IBM Cloud API key and click **Save**
119
+ 3. Click **Configure MCP** β€” writes the server entry to the global `mcp.json`
120
+ 4. Click **Run Diagnostics** to confirm Node.js, the API key, and tool discovery are all βœ…
71
121
 
72
- 1. **Check MCP Status**
73
- - Look at the Cline status bar
74
- - You should see "MCP" indicator
75
- - It should show "code-engine" as connected
122
+ > The extension stores the key in VS Code global settings β€” encrypted by the OS keychain, never in a plaintext file.
76
123
 
77
- 2. **Test with a Simple Command**
78
-
79
- Ask Bob:
80
- ```
81
- Can you detect which container runtime I have installed?
82
- ```
124
+ ---
83
125
 
84
- Bob should respond with Docker or Podman version information.
126
+ ### 2. VS Code + GitHub Copilot β€” manual `mcp.json`
85
127
 
86
- ## Step 5: Test Docker/Podman Integration
128
+ Use this if you prefer to manage the config yourself without the extension.
87
129
 
88
- Ask Bob:
130
+ Create (or edit) `.vscode/mcp.json` in your workspace root, or the global config at `~/Library/Application Support/Code/User/mcp.json` (macOS):
131
+
132
+ ```bash
133
+ # workspace-level (add to .gitignore)
134
+ mkdir -p .vscode
135
+ echo '.vscode/mcp.json' >> .gitignore
89
136
  ```
90
- Can you list all my local Docker images?
137
+
138
+ ```json
139
+ {
140
+ "servers": {
141
+ "code-engine": {
142
+ "type": "stdio",
143
+ "command": "npx",
144
+ "args": ["-y", "code-engine-mcp-server@latest"],
145
+ "env": {
146
+ "IBMCLOUD_API_KEY": "${env:IBMCLOUD_API_KEY}",
147
+ "IBMCLOUD_REGION": "us-south"
148
+ }
149
+ }
150
+ }
151
+ }
91
152
  ```
92
153
 
93
- Bob should execute the `list_local_images` tool and show your images.
154
+ Restart the server after saving: **Cmd+Shift+P** β†’ **MCP: Restart Server** β†’ `code-engine`.
155
+
156
+ ---
94
157
 
95
- ## Step 6: Test Code Engine Integration
158
+ ### 3. Claude Desktop
96
159
 
97
- Ask Bob:
160
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
161
+
162
+ ```json
163
+ {
164
+ "mcpServers": {
165
+ "code-engine": {
166
+ "command": "npx",
167
+ "args": ["-y", "code-engine-mcp-server@latest"],
168
+ "env": {
169
+ "IBMCLOUD_API_KEY": "${env:IBMCLOUD_API_KEY}",
170
+ "IBMCLOUD_REGION": "us-south"
171
+ }
172
+ }
173
+ }
174
+ }
98
175
  ```
99
- Can you list all my Code Engine projects?
176
+
177
+ > Claude Desktop does not support `${env:...}` substitution β€” use Option A (export the variable in your shell profile before launching Claude) or Option C (inline, with the file excluded from git).
178
+
179
+ Restart Claude Desktop after saving.
180
+
181
+ ---
182
+
183
+ ### 4. Cline (VS Code Extension)
184
+
185
+ 1. Open **VS Code Settings** (`Cmd+,`)
186
+ 2. Search for **Cline: MCP Settings** β†’ **Edit in settings.json**
187
+ 3. Add:
188
+
189
+ ```json
190
+ {
191
+ "cline.mcpServers": {
192
+ "code-engine": {
193
+ "command": "npx",
194
+ "args": ["-y", "code-engine-mcp-server@latest"],
195
+ "env": {
196
+ "IBMCLOUD_API_KEY": "${env:IBMCLOUD_API_KEY}",
197
+ "IBMCLOUD_REGION": "us-south"
198
+ }
199
+ }
200
+ }
201
+ }
100
202
  ```
101
203
 
102
- Bob should execute the `ce_list_projects` tool and show your projects.
103
-
104
- ## Troubleshooting
105
-
106
- ### MCP Server Not Showing as Connected
107
-
108
- 1. **Check the path is correct**
109
- ```bash
110
- ls -la /Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js
111
- ```
112
-
113
- 2. **Check Node.js is available**
114
- ```bash
115
- node --version
116
- ```
117
- Should show v18 or higher
118
-
119
- 3. **Test the server manually**
120
- ```bash
121
- node /Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js
122
- ```
123
- Should show: "Code Engine MCP Server running on stdio"
124
- Press Ctrl+C to exit
125
-
126
- 4. **Check VSCode Output**
127
- - View β†’ Output
128
- - Select "Cline" from dropdown
129
- - Look for MCP connection errors
130
-
131
- ### Docker Commands Not Working
132
-
133
- 1. **Verify Docker is installed**
134
- ```bash
135
- docker --version
136
- ```
137
-
138
- 2. **Check Docker daemon is running**
139
- ```bash
140
- docker ps
141
- ```
142
-
143
- 3. **Check permissions**
144
- - You may need to add your user to the docker group
145
- - Or use Podman instead
146
-
147
- ### Code Engine Commands Not Working
148
-
149
- 1. **Verify IBM Cloud CLI**
150
- ```bash
151
- ibmcloud --version
152
- ```
153
-
154
- 2. **Check Code Engine plugin**
155
- ```bash
156
- ibmcloud plugin list
157
- ```
158
- Should show "code-engine" plugin
159
-
160
- 3. **Verify API key**
161
- - Make sure you replaced the placeholder in settings.json
162
- - Test manually:
163
- ```bash
164
- export IBMCLOUD_API_KEY="your-key-here"
165
- ibmcloud ce project list
166
- ```
167
-
168
- ## What You Can Do Now
169
-
170
- Once configured, you can ask Bob to:
171
-
172
- ### Docker/Podman Operations
173
- - "Detect my container runtime"
174
- - "Build a container from ./Dockerfile as myapp:latest"
175
- - "List all my local images"
176
- - "Test myapp:latest locally on port 8080"
177
- - "Get logs from container abc123"
178
- - "Stop and remove container abc123"
179
- - "List all running containers"
180
-
181
- ### Code Engine Operations
182
- - "List all my Code Engine projects"
183
- - "List applications in project 'my-project'"
184
- - "Get details of application 'my-app' in project 'my-project'"
185
- - "Create an application named 'test-app' with image 'nginx:latest' in project 'my-project'"
186
-
187
- ### Complete Workflows
204
+ > If your shell exports `IBMCLOUD_API_KEY`, Cline inherits it automatically β€” the `${env:...}` reference will resolve without any extra config.
205
+
206
+ ---
207
+
208
+ ### 5. Cursor IDE
209
+
210
+ Cursor supports MCP servers in its settings UI or via a `~/.cursor/mcp.json` file.
211
+
212
+ **UI approach:**
213
+ 1. Go to **Cursor Settings** β†’ **General** β†’ **MCP**
214
+ 2. Click **+ Add New MCP Server**
215
+ 3. Fill in:
216
+ - **Name**: `code-engine`
217
+ - **Type**: `stdio`
218
+ - **Command**: `npx`
219
+ - **Args**: `-y code-engine-mcp-server@latest`
220
+ - **Environment Variables**: `IBMCLOUD_API_KEY` = your key value
221
+
222
+ **File approach** (`~/.cursor/mcp.json`):
223
+
224
+ ```json
225
+ {
226
+ "mcpServers": {
227
+ "code-engine": {
228
+ "command": "npx",
229
+ "args": ["-y", "code-engine-mcp-server@latest"],
230
+ "env": {
231
+ "IBMCLOUD_API_KEY": "${env:IBMCLOUD_API_KEY}",
232
+ "IBMCLOUD_REGION": "us-south"
233
+ }
234
+ }
235
+ }
236
+ }
188
237
  ```
189
- I have a Node.js app in ./my-app with a Dockerfile. Can you:
190
- 1. Build it as myapp:v1.0.0
191
- 2. Test it locally on port 3000
192
- 3. Push it to icr.io/my-namespace/myapp:v1.0.0
193
- 4. Deploy it to my Code Engine project "production"
238
+
239
+ Cursor also supports the Open VSX extension: [markusvankempen.code-engine-mcp](https://open-vsx.org/extension/markusvankempen/code-engine-mcp)
240
+
241
+ ---
242
+
243
+ ## πŸš€ Step 4: Verify the connection
244
+
245
+ Once configured, restart your IDE or reload the MCP server and test with:
246
+
247
+ > *"Can you detect which container runtime I have installed?"*
248
+
249
+ The assistant should respond with your Docker or Podman version. If it fails, see the Troubleshooting section below.
250
+
251
+ ---
252
+
253
+ ## πŸ€– Step 5: The agentic experience
254
+
255
+ You don't need to know Docker or Code Engine commands. State your goal and the AI handles discovery, execution, and self-correction autonomously.
256
+
257
+ **Example from a real session:**
258
+
259
+ **User:** *"I have an app in the `developer-splash` folder. Deploy it to my Code Engine project."*
260
+
261
+ **Assistant's thought process:**
262
+ 1. *Discovery:* "Let me check what projects and namespaces exist… Found project `markus-app-v2-toronto` and namespace `mvk-code-engine`."
263
+ 2. *Prerequisites:* "No pull secret in this project yet. I'll create `icr-pull-secret` using the current API key."
264
+ 3. *Execution:* "Running the full pipeline: build β†’ push β†’ deploy β†’ wait."
265
+ 4. *Validation:* "Stuck at 'deploying'. Checking logs… readiness probe failing."
266
+ 5. *Self-correction:* "The `sed` pattern in the Dockerfile used `\s*` which Alpine BusyBox doesn't support. Fixing to `[[:space:]]*` and rebuilding."
267
+ 6. *Completion:* "App is live! Status: ready."
268
+
269
+ **Response to user:** *"Your app is deployed at `https://developer-splash.29m5mrru3s3n.ca-tor.codeengine.appdomain.cloud`. I fixed a minor port config issue in the Dockerfile along the way."*
270
+
271
+ ---
272
+
273
+ ## πŸ› οΈ Troubleshooting
274
+
275
+ ### `IBMCLOUD_API_KEY` not set / `401 Unauthorized`
276
+
277
+ The server requires the key at startup. Verify it is exported in the shell that launches your IDE:
278
+
279
+ ```bash
280
+ echo $IBMCLOUD_API_KEY # should print your key, not empty
194
281
  ```
195
282
 
196
- Bob will execute all these steps automatically!
283
+ If empty, run `source .env` (from the repo root after filling in `.env`) or add the export to your shell profile.
284
+
285
+ ### Tools show `undefined` or AI can't use them
197
286
 
198
- ## Next Steps
287
+ Run **Diagnostics** (extension sidebar) or check `tools/list` in the [MCP Inspector](https://github.com/modelcontextprotocol/inspector). If the tool list is empty, the server exited at startup β€” run `node build/index.js` directly to see any error output.
288
+
289
+ ### `Cannot find module` / `MODULE_NOT_FOUND`
290
+
291
+ Use `npx -y code-engine-mcp-server@latest` instead of a local path, or ensure the repo is built with `npm install && npm run build` and use the absolute path to `build/index.js`.
292
+
293
+ ### Port / permission errors on macOS
294
+
295
+ If `npx` can't find Node.js, ensure `node` and `npx` are on your `PATH`:
296
+
297
+ ```bash
298
+ node --version # must be β‰₯ 18
299
+ npx --version
300
+ ```
199
301
 
200
- 1. βœ… MCP server is built and ready
201
- 2. βœ… Configuration example is provided
202
- 3. ⏳ Add configuration to VSCode settings
203
- 4. ⏳ Restart VSCode/Cline
204
- 5. ⏳ Test with simple commands
205
- 6. ⏳ Start using Bob for Docker and Code Engine tasks!
302
+ Install from [nodejs.org](https://nodejs.org) if missing.
206
303
 
207
- ## Need Help?
304
+ ### App revision stuck in `no_revision_ready`
208
305
 
209
- - Check the README.md for detailed documentation
210
- - Review MCP_SERVER_SETUP_GUIDE.md for comprehensive setup
211
- - Look at CLINE_CONFIG_EXAMPLE.json for configuration reference
212
- - Open an issue if you encounter problems
306
+ See [MCP_INSPECTOR_TROUBLESHOOTING.md](./MCP_INSPECTOR_TROUBLESHOOTING.md) β€” the two most common causes are a stale ICR pull secret and an nginx port not rewritten in the Dockerfile.
213
307
 
214
- ## Security Note
308
+ ---
215
309
 
216
- ⚠️ **Important**: Never commit your IBM Cloud API key to version control!
310
+ ## πŸ” Security checklist
217
311
 
218
- - Keep your API key in VSCode settings (not tracked by git)
219
- - Or use environment variables
220
- - Consider using IBM Cloud IAM for better security
312
+ - [ ] `.env` is in `.gitignore` (already set in this repo β€” verify with `git check-ignore .env`)
313
+ - [ ] `.vscode/mcp.json` is in `.gitignore` if it contains inline credentials
314
+ - [ ] API key uses `${env:IBMCLOUD_API_KEY}` or `${input:...}` rather than an inline value
315
+ - [ ] API key has only the minimum required IAM permissions (Code Engine Editor + Container Registry Reader)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "code-engine-mcp-server",
3
3
  "mcpName": "io.github.markusvankempen/code-engine-mcp-server",
4
- "version": "1.0.4",
4
+ "version": "1.0.7",
5
5
  "description": "MCP server for IBM Code Engine and Docker/Podman integration",
6
6
  "repository": {
7
7
  "type": "git",
@@ -23,7 +23,9 @@
23
23
  "deploy": "tsx src/deploy-cli.ts",
24
24
  "start": "node build/simple-client.js",
25
25
  "prepare": "npm run build",
26
- "test": "echo \"Error: no test specified\" && exit 1"
26
+ "test": "node --experimental-vm-modules node_modules/.bin/jest",
27
+ "test:watch": "node --experimental-vm-modules node_modules/.bin/jest --watch",
28
+ "test:coverage": "node --experimental-vm-modules node_modules/.bin/jest --coverage"
27
29
  },
28
30
  "keywords": [
29
31
  "mcp",
@@ -56,7 +58,10 @@
56
58
  "dotenv": "^17.4.2"
57
59
  },
58
60
  "devDependencies": {
61
+ "@types/jest": "^30.0.0",
59
62
  "@types/node": "^20.0.0",
63
+ "jest": "^30.4.2",
64
+ "ts-jest": "^29.4.9",
60
65
  "tsx": "^4.7.0",
61
66
  "typescript": "^5.3.0"
62
67
  }