code-engine-mcp-server 1.0.4 → 1.0.6

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,232 @@
1
+ # Troubleshooting with the MCP Inspector
2
+
3
+ The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is an interactive browser UI that lets you connect directly to any MCP server, browse its tools, run them manually, and inspect the raw JSON-RPC traffic. This is the fastest way to verify your `code-engine-mcp-server` is working correctly — without needing a full AI assistant session.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ | Requirement | Notes |
10
+ |-------------|-------|
11
+ | Node.js ≥ 18 | Required to run the server and the inspector |
12
+ | Built server | Run `npm run build` in the repo root |
13
+ | IBM Cloud API key | Set in your environment or passed directly to the inspector |
14
+
15
+ ---
16
+
17
+ ## Step 1 — Build the server
18
+
19
+ ```bash
20
+ cd /path/to/code-engine-mcp-server
21
+ npm install && npm run build
22
+ ```
23
+
24
+ Verify the entry point exists:
25
+
26
+ ```bash
27
+ ls -lh build/index.js
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Step 2 — Launch the MCP Inspector
33
+
34
+ The inspector runs the MCP server as a child process (STDIO transport), so **no manual server startup is needed**.
35
+
36
+ ```bash
37
+ npx @modelcontextprotocol/inspector \
38
+ node build/index.js
39
+ ```
40
+
41
+ The inspector prints two URLs:
42
+
43
+ ```
44
+ MCP Inspector is up and running at http://localhost:6274 🚀
45
+ ```
46
+
47
+ Open the URL it prints. If it adds a `?MCP_PROXY_AUTH_TOKEN=...` query parameter, use the full URL including that token — it is required to connect to the proxy.
48
+
49
+ > If port 6274 or 6277 is already in use from a stale run, kill the old process first:
50
+ > ```bash
51
+ > lsof -ti :6274,:6277 | xargs kill -9
52
+ > ```
53
+
54
+ ---
55
+
56
+ ## Step 3 — Connect with your API key
57
+
58
+ The server requires `IBMCLOUD_API_KEY` (and optionally `IBMCLOUD_REGION`). Pass them as environment variables in the inspector's **Environment Variables** panel before connecting:
59
+
60
+ | Key | Example value |
61
+ |-----|---------------|
62
+ | `IBMCLOUD_API_KEY` | `YOUR_IBM_CLOUD_API_KEY` |
63
+ | `IBMCLOUD_REGION` | `us-south` |
64
+
65
+ Or set them in your shell before launching the inspector:
66
+
67
+ ```bash
68
+ export IBMCLOUD_API_KEY=your-key
69
+ export IBMCLOUD_REGION=us-south
70
+
71
+ npx @modelcontextprotocol/inspector node build/index.js
72
+ ```
73
+
74
+ The inspector UI looks like this with the STDIO transport configured and `IBMCLOUD_API_KEY` / `IBMCLOUD_REGION` entered:
75
+
76
+ ![Inspector setup — STDIO mode with env vars](images/inspector-localhost-1-setup.png)
77
+
78
+ Once variables are set, click **Connect**. The status indicator turns green and the server name (`code-engine-mcp-server`) appears with the tools list populated:
79
+
80
+ ![Inspector connected — STDIO, tools listed](images/inspector-localhost-2-connected.png)
81
+
82
+ ---
83
+
84
+ ## Step 4 — List all tools
85
+
86
+ 1. Click the **Tools** tab.
87
+ 2. Click **List Tools**.
88
+
89
+ You should see all ~62 tools grouped by category:
90
+
91
+ | Category prefix | Example tools |
92
+ |-----------------|--------------|
93
+ | `ce_` | `ce_list_projects`, `ce_create_application`, `ce_get_app_logs` |
94
+ | `docker_` | `docker_build_image`, `docker_push_image` |
95
+ | `icr_` | `icr_list_namespaces`, `icr_list_images` |
96
+ | `proc_` | `proc_build_push_deploy`, `proc_build_run_and_deploy` |
97
+
98
+ If the list is empty or an error appears, check [Common errors](#common-errors) below.
99
+
100
+ ---
101
+
102
+ ## Step 5 — Run a tool manually
103
+
104
+ ### 5a — List your Code Engine projects
105
+
106
+ Select `ce_list_projects` from the tools list and click **Run Tool** (no parameters needed).
107
+
108
+ The result panel shows **Tool Result: Success** in green:
109
+
110
+ ![Tool Result: Success — ce_list_projects](images/inspector-localhost-3-result.png)
111
+
112
+ Scrolling down shows the full JSON response with your real projects:
113
+
114
+ ![Tool result JSON — projects list](images/inspector-localhost-4-result-detail.png)
115
+
116
+ Expected response shape:
117
+ ```json
118
+ {
119
+ "projects": [
120
+ {
121
+ "id": "7e131e87-e967-4e7f-a2f1-480957244eac",
122
+ "name": "markus-app-v2-toronto",
123
+ "region": "ca-tor",
124
+ "status": "active"
125
+ }
126
+ ],
127
+ "total": 3
128
+ }
129
+ ```
130
+
131
+ ### 5b — Get app logs
132
+
133
+ Select `ce_get_app_logs` and fill in:
134
+
135
+ | Parameter | Value |
136
+ |-----------|-------|
137
+ | `project_id` | your project ID from step 5a |
138
+ | `app_name` | an app deployed in that project |
139
+ | `tail_lines` | `50` (optional, default 100) |
140
+
141
+ Click **Run Tool**. The tool fetches logs via the Kubernetes proxy API (same mechanism as `ibmcloud ce app logs`).
142
+
143
+ ### 5c — List app instances
144
+
145
+ Select `ce_list_app_instances`:
146
+
147
+ | Parameter | Value |
148
+ |-----------|-------|
149
+ | `project_id` | your project ID |
150
+ | `app_name` | an app name |
151
+
152
+ This confirms running pods and their current state.
153
+
154
+ ---
155
+
156
+ ## Step 6 — Inspect the raw JSON-RPC traffic
157
+
158
+ The **History** panel on the left shows every request and response in order:
159
+
160
+ | # | Method | Purpose |
161
+ |---|--------|---------|
162
+ | 1 | `initialize` | Handshake — server returns its name, version, capabilities |
163
+ | 2 | `notifications/initialized` | Client acknowledges capabilities |
164
+ | 3 | `tools/list` | Client fetches all available tools |
165
+ | 4 | `tools/call` | Client invokes a specific tool |
166
+
167
+ Click any history entry to see the full JSON payload. This is useful for copying exact tool inputs/outputs into bug reports.
168
+
169
+ > **Why does raw `curl` give "Method not found"?**
170
+ > A bare `curl` to the server's STDIO stream sends data without going through the `initialize` handshake first. The server correctly rejects it. The inspector handles the full handshake automatically.
171
+
172
+ ---
173
+
174
+ ## Common errors
175
+
176
+ ### `IBMCLOUD_API_KEY` not set
177
+
178
+ **Symptom:** Tools return `401 Unauthorized` or `Missing API key` errors.
179
+
180
+ **Fix:** Set the environment variable before launching the inspector, or add it in the inspector's Environment Variables panel and reconnect.
181
+
182
+ ---
183
+
184
+ ### `ECONNREFUSED` / server won't start
185
+
186
+ **Symptom:** Inspector shows "Connection failed" immediately after clicking Connect.
187
+
188
+ **Fix:**
189
+ 1. Confirm the build exists: `ls build/index.js`
190
+ 2. Test the server directly: `node build/index.js` — it should print nothing and wait (STDIO mode).
191
+ 3. Check Node.js version: `node --version` (must be ≥ 18).
192
+
193
+ ---
194
+
195
+ ### Port already in use
196
+
197
+ **Symptom:** Inspector fails to start with `EADDRINUSE :6274` or `:6277`.
198
+
199
+ **Fix:**
200
+ ```bash
201
+ lsof -ti :6274,:6277 | xargs kill -9
202
+ ```
203
+
204
+ Then rerun `npx @modelcontextprotocol/inspector node build/index.js`.
205
+
206
+ ---
207
+
208
+ ### Tools list is empty
209
+
210
+ **Symptom:** `tools/list` returns `[]` or the Tools tab shows nothing.
211
+
212
+ **Fix:** The server may have exited during startup (e.g. missing dependency). Run `node build/index.js` directly and check stderr for stack traces.
213
+
214
+ ---
215
+
216
+ ### `ce_get_app_logs` returns no pods
217
+
218
+ **Symptom:** Response says no pods found for the app.
219
+
220
+ **Possible causes:**
221
+ - The app has scaled to zero (Code Engine scales idle apps down). Send a request to the app URL first to wake it up, then retry.
222
+ - The `app_name` doesn't match exactly — it's case-sensitive.
223
+ - The `project_id` is wrong — use `ce_list_projects` to confirm.
224
+
225
+ ---
226
+
227
+ ## Tips
228
+
229
+ - Use the inspector's **Copy value** button on any result to paste exact JSON into a GitHub issue.
230
+ - The **History** panel persists across tool calls in the same session — useful for comparing before/after behaviour when debugging.
231
+ - To test a freshly built change, kill the inspector, run `npm run build`, and relaunch.
232
+ - All `ce_` tools that need a `project_id` can discover it first with `ce_list_projects` — the same workflow your AI assistant uses.
@@ -1,220 +1,123 @@
1
- # Quick Setup Instructions for Bob/Cline
1
+ # Setup Instructions for MCP Clients (VS Code, Antigravity, Bob, Cursor)
2
2
 
3
- Follow these steps to enable Bob to understand Docker and Code Engine commands.
3
+ Follow these steps to enable your AI assistant to understand Docker and Code Engine commands across different IDEs and MCP clients.
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: Verify the Build
8
8
 
9
- The MCP server has been built successfully. Verify it exists:
9
+ The MCP server must be built before it can be used. Verify it exists:
10
10
 
11
11
  ```bash
12
12
  ls -la /Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js
13
13
  ```
14
14
 
15
- You should see the compiled JavaScript file.
15
+ If it doesn't exist, run `npm install && npm run build` in the server root.
16
16
 
17
- ## Step 2: Configure Cline in VSCode
17
+ ---
18
18
 
19
- 1. **Open VSCode Settings**
20
- - Press `Cmd + ,` (Mac) or `Ctrl + ,` (Windows/Linux)
21
- - Or go to: Code → Settings → Settings
19
+ ## ⚙️ Step 2: Configure Your Client
22
20
 
23
- 2. **Search for MCP Settings**
24
- - Type "Cline MCP" in the search bar
25
- - Look for "Cline: MCP Settings"
21
+ Choose your IDE/Client below and follow the specific configuration steps.
26
22
 
27
- 3. **Edit settings.json**
28
- - Click "Edit in settings.json" link
29
- - This will open your VSCode settings file
30
-
31
- 4. **Add the MCP Server Configuration**
32
-
33
- Copy and paste this configuration into your settings.json:
23
+ ### 1. VS Code + GitHub Copilot (Official Extension)
24
+ If you are using the latest VS Code (**1.101+**) with GitHub Copilot, the easiest way is to use our pre-built extension:
25
+ 1. Go to the `vscode-extension/` folder in this repo.
26
+ 2. Install the `.vsix` file (**Command Palette** → **Extensions: Install from VSIX...**).
27
+ 3. Open **Settings** (**Cmd+,**) and search for **IBM Code Engine MCP**.
28
+ 4. Enter your **IBM Cloud API Key**.
34
29
 
30
+ ### 2. Antigravity IDE / Claude Desktop
31
+ Antigravity uses a standard MCP configuration file.
32
+ 1. Open (or create) your MCP config file at:
33
+ `~/Library/Application Support/Claude/claude_desktop_config.json`
34
+ 2. Add the following entry:
35
35
  ```json
36
36
  {
37
- "cline.mcpServers": {
37
+ "mcpServers": {
38
38
  "code-engine": {
39
39
  "command": "node",
40
- "args": [
41
- "/Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js"
42
- ],
40
+ "args": ["/Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js"],
43
41
  "env": {
44
- "IBMCLOUD_API_KEY": "YOUR_IBMCLOUD_API_KEY_HERE"
42
+ "IBMCLOUD_API_KEY": "YOUR_IBM_CLOUD_API_KEY",
43
+ "IBMCLOUD_REGION": "us-south"
45
44
  }
46
45
  }
47
46
  }
48
47
  }
49
48
  ```
50
49
 
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
55
-
56
- 6. **Save the file**
57
- - Press `Cmd + S` (Mac) or `Ctrl + S` (Windows/Linux)
58
-
59
- ## Step 3: Restart Cline/Bob
60
-
61
- 1. **Reload VSCode Window**
62
- - Press `Cmd + Shift + P` (Mac) or `Ctrl + Shift + P` (Windows/Linux)
63
- - Type "Reload Window"
64
- - Press Enter
65
-
66
- 2. **Or Restart Cline**
67
- - Open Cline sidebar
68
- - Look for restart/reload option
69
-
70
- ## Step 4: Verify the Connection
71
-
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
76
-
77
- 2. **Test with a Simple Command**
78
-
79
- Ask Bob:
80
- ```
81
- Can you detect which container runtime I have installed?
82
- ```
83
-
84
- Bob should respond with Docker or Podman version information.
85
-
86
- ## Step 5: Test Docker/Podman Integration
87
-
88
- Ask Bob:
89
- ```
90
- Can you list all my local Docker images?
91
- ```
92
-
93
- Bob should execute the `list_local_images` tool and show your images.
94
-
95
- ## Step 6: Test Code Engine Integration
96
-
97
- Ask Bob:
98
- ```
99
- Can you list all my Code Engine projects?
100
- ```
101
-
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
50
+ ### 3. Bob / Cline (VS Code Extension)
51
+ 1. Open **VS Code Settings** and search for **Cline: MCP Settings**.
52
+ 2. Click **Edit in settings.json**.
53
+ 3. Add the server to the `cline.mcpServers` object:
54
+ ```json
55
+ "cline.mcpServers": {
56
+ "code-engine": {
57
+ "command": "node",
58
+ "args": ["/Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js"],
59
+ "env": {
60
+ "IBMCLOUD_API_KEY": "YOUR_IBM_CLOUD_API_KEY"
61
+ }
62
+ }
63
+ }
122
64
  ```
123
- Should show: "Code Engine MCP Server running on stdio"
124
- Press Ctrl+C to exit
125
65
 
126
- 4. **Check VSCode Output**
127
- - View Output
128
- - Select "Cline" from dropdown
129
- - Look for MCP connection errors
66
+ ### 4. Cursor IDE
67
+ Cursor supports MCP servers directly in its settings.
68
+ 1. Go to **Cursor Settings** → **General** → **MCP**.
69
+ 2. Click **+ Add New MCP Server**.
70
+ 3. **Name**: `code-engine`
71
+ 4. **Type**: `stdio`
72
+ 5. **Command**: `node /Users/markusvankempen/projects/code-engine/code-engine-mcp-server/build/index.js`
73
+ 6. **Environment Variables**: Add `IBMCLOUD_API_KEY` with your key value.
130
74
 
131
- ### Docker Commands Not Working
75
+ ---
132
76
 
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
- ```
77
+ ## 🚀 Step 3: Verify the Connection
142
78
 
143
- 3. **Check permissions**
144
- - You may need to add your user to the docker group
145
- - Or use Podman instead
79
+ Once configured, restart your IDE or reload the MCP server and test with a simple prompt:
146
80
 
147
- ### Code Engine Commands Not Working
81
+ > "Can you detect which container runtime I have installed?"
148
82
 
149
- 1. **Verify IBM Cloud CLI**
150
- ```bash
151
- ibmcloud --version
152
- ```
83
+ The assistant should respond with your Docker or Podman version information.
153
84
 
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
- ```
85
+ ---
167
86
 
168
- ## What You Can Do Now
87
+ ## 🤖 Step 4: The Agentic Experience (No Docker/Code Engine Lingo Needed)
169
88
 
170
- Once configured, you can ask Bob to:
89
+ The true power of this MCP server is that **you don't need to know Docker or Code Engine commands**. You can simply state your goal, and the LLM will discover the environment, run the pipeline, and fix issues autonomously.
171
90
 
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"
91
+ Here is an example interaction from a real session:
180
92
 
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'"
93
+ **User:**
94
+ > "I have an app in the `developer-splash` folder. Deploy it to my Code Engine project."
186
95
 
187
- ### Complete Workflows
188
- ```
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"
194
- ```
96
+ **Assistant's Autonomous Thought Process:**
97
+ 1. *Discovery:* "Let me check what projects and namespaces exist... Found project `markus-app-v2-toronto` and namespace `mvk-code-engine`."
98
+ 2. *Prerequisites:* "No pull secret in this project yet. I'll get the API key from the `.env` file and create the secret `icr-pull-secret`."
99
+ 3. *Execution:* "Now I'll run the full pipeline: build → push → deploy → wait."
100
+ 4. *Validation:* "It's deployed but stuck at 'deploying'. Let me check the logs... The container is running but the readiness probe is failing."
101
+ 5. *Self-Correction:* "Ah, the `sed` pattern in the Dockerfile didn't match nginx alpine's default config format for port 80. I'll fix the Dockerfile with a regex-safe `sed` and rebuild."
102
+ 6. *Completion:* "App is live! 🎉 Status: ready."
195
103
 
196
- Bob will execute all these steps automatically!
104
+ **Assistant Response to User:**
105
+ > "Your app is deployed and live at: `https://developer-splash.29m5mrru3s3n.ca-tor.codeengine.appdomain.cloud`. I had to fix a minor port configuration issue in your Dockerfile, but it is successfully running now!"
197
106
 
198
- ## Next Steps
107
+ ---
199
108
 
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!
109
+ ## 🛠️ Troubleshooting
206
110
 
207
- ## Need Help?
111
+ ### "Cannot find module" or "MODULE_NOT_FOUND"
112
+ Ensure you are using an **absolute path** in the `args` or `command` field. MCP clients usually do not resolve `${workspaceFolder}` or `~` correctly.
208
113
 
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
114
+ ### "invalid character 'â'" or encoding errors
115
+ Ensure your server is built using `npm run build`. This error often occurs if there are special characters in the source code that the `stdio` transport cannot handle.
213
116
 
214
- ## Security Note
117
+ ### IBM Cloud API Key
118
+ Get your key from: [https://cloud.ibm.com/iam/apikeys](https://cloud.ibm.com/iam/apikeys). Ensure it has the necessary permissions for Code Engine and Container Registry.
215
119
 
216
- ⚠️ **Important**: Never commit your IBM Cloud API key to version control!
120
+ ---
217
121
 
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
122
+ ## 🔐 Security Note
123
+ ⚠️ **Important**: Never commit your `mcp_config.json` or any file containing your API key to version control. Always use `.gitignore` to protect your secrets.
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.6",
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
  }