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.
- package/README.md +441 -81
- package/build/index.js +1268 -81
- package/build/index.js.map +1 -1
- package/docs/CONTRIBUTING.md +92 -26
- package/docs/MCP_INSPECTOR_TROUBLESHOOTING.md +301 -0
- package/docs/SETUP_INSTRUCTIONS.md +272 -177
- package/docs/images/inspector-1-setup.png +0 -0
- package/docs/images/inspector-2-connected.png +0 -0
- package/docs/images/inspector-3-tools-list.png +0 -0
- package/docs/images/inspector-4-tool-selected.png +0 -0
- package/docs/images/inspector-5-tool-result.png +0 -0
- package/docs/images/inspector-localhost-1-setup.png +0 -0
- package/docs/images/inspector-localhost-2-connected.png +0 -0
- package/docs/images/inspector-localhost-3-result.png +0 -0
- package/docs/images/inspector-localhost-3-tool-selected.png +0 -0
- package/docs/images/inspector-localhost-4-result-detail.png +0 -0
- package/docs/images/inspector-localhost-4-result.png +0 -0
- package/package.json +7 -2
- package/docs/API_CALL_SCENARIOS.md +0 -594
- package/docs/CODE_ENGINE_API_REFERENCE.md +0 -764
package/docs/CONTRIBUTING.md
CHANGED
|
@@ -1,38 +1,104 @@
|
|
|
1
|
-
# Contributing
|
|
1
|
+
# Contributing to IBM Code Engine MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
First off, thank you for considering contributing! The `code-engine-mcp-server` project is an open-source initiative to enable AI-driven deployment for IBM Code Engine. We welcome contributions from the community.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## ๐ Tech Stack
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- **Runtime**: Node.js 24+ (pinned via `mise`)
|
|
8
|
+
- **Language**: TypeScript (ESM / Node16 modules)
|
|
9
|
+
- **Testing**: Jest + ts-jest
|
|
10
|
+
- **Key Libraries**:
|
|
11
|
+
- `@modelcontextprotocol/sdk` โ core MCP implementation
|
|
12
|
+
- `axios` โ IBM Cloud API calls
|
|
13
|
+
- `dotenv` โ environment configuration
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
---
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
- Keep pull requests focused and reviewable.
|
|
16
|
-
- Write clear commit messages that explain why the change is needed.
|
|
17
|
+
## ๐ Environment Setup
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
We use [`mise`](https://mise.jdx.dev) to pin the Node.js version consistently.
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
21
|
+
1. **Fork and clone**
|
|
22
|
+
```bash
|
|
23
|
+
git clone https://github.com/markusvankempen/code-engine-mcp-server.git
|
|
24
|
+
cd code-engine-mcp-server
|
|
25
|
+
```
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
2. **Install Node.js via mise**
|
|
28
|
+
```bash
|
|
29
|
+
mise install
|
|
30
|
+
```
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
3. **Install dependencies**
|
|
33
|
+
```bash
|
|
34
|
+
npm install
|
|
35
|
+
```
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
4. **Configure environment**
|
|
38
|
+
```bash
|
|
39
|
+
cp .env.example .env # add your IBMCLOUD_API_KEY
|
|
40
|
+
```
|
|
41
|
+
> For unit tests, no live IBM Cloud connection is required โ the MCP tool-discovery tests run against the local built server.
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
5. **Build the server**
|
|
44
|
+
```bash
|
|
45
|
+
mise run build # or: npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ๐งช Development Workflow
|
|
51
|
+
|
|
52
|
+
### Running tests
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
mise run test # run all Jest tests
|
|
56
|
+
mise run test-watch # watch mode
|
|
57
|
+
mise run test-coverage # with coverage report
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or directly with npm:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm test
|
|
64
|
+
npm run test:coverage
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Tests live in `__tests__/` and use the `.test.ts` suffix.
|
|
68
|
+
|
|
69
|
+
### Adding a new MCP tool
|
|
70
|
+
|
|
71
|
+
1. Define the tool in `src/index.ts` (add to `containerTools` or `codeEngineTools` array)
|
|
72
|
+
2. Add a handler in the `CallToolRequestSchema` switch block
|
|
73
|
+
3. Add the tool name to `EXPECTED_*_TOOLS` in `__tests__/mcp-tools.test.ts`
|
|
74
|
+
4. Run `npm test` โ if the new tool shows up, the test passes automatically
|
|
75
|
+
|
|
76
|
+
**Example test for a new tool:**
|
|
77
|
+
```typescript
|
|
78
|
+
test('my_new_tool responds to a valid call', async () => {
|
|
79
|
+
// Use the discoverTools() helper from the test file, or write
|
|
80
|
+
// a focused JSON-RPC test using spawn + JSON-RPC as shown in
|
|
81
|
+
// __tests__/mcp-tools.test.ts
|
|
82
|
+
expect(tools).toContain('my_new_tool');
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## ๐ Pull Request Process
|
|
89
|
+
|
|
90
|
+
1. **Branch** off `main` โ use `feature/tool-name` or `fix/description`
|
|
91
|
+
2. **Commit messages** โ be descriptive about *why*, not just *what*
|
|
92
|
+
3. **Tests** โ add/update tests for any new logic
|
|
93
|
+
4. **Docs** โ update `README.md` or `docs/` if behaviour changes
|
|
94
|
+
5. **CI** โ ensure `npm test` and `npm run build` pass locally before opening a PR
|
|
95
|
+
6. Open a PR against `main` and link related issues
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## โ Getting Help
|
|
100
|
+
|
|
101
|
+
Open a [GitHub Issue](https://github.com/markusvankempen/code-engine-mcp-server/issues) or reach out via the contact info in `README.md`.
|
|
102
|
+
|
|
103
|
+
Happy coding! ๐
|
|
34
104
|
|
|
35
|
-
- Expected behavior
|
|
36
|
-
- Actual behavior
|
|
37
|
-
- Steps to reproduce
|
|
38
|
-
- Relevant logs or screenshots
|
|
@@ -0,0 +1,301 @@
|
|
|
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
|
+

|
|
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
|
+

|
|
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
|
+

|
|
111
|
+
|
|
112
|
+
Scrolling down shows the full JSON response with your real projects:
|
|
113
|
+
|
|
114
|
+

|
|
115
|
+
|
|
116
|
+
Expected response shape:
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"projects": [
|
|
120
|
+
{
|
|
121
|
+
"id": "YOUR_CE_PROJECT_ID",
|
|
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
|
+
### App stuck in `no_revision_ready` with `reason: "unknown"`
|
|
228
|
+
|
|
229
|
+
**Symptom:** `proc_build_push_deploy` (or `ce_wait_for_app_ready`) returns:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"status": "failed",
|
|
234
|
+
"reason": "unknown",
|
|
235
|
+
"status_details": {
|
|
236
|
+
"reason": "unknown",
|
|
237
|
+
"latest_created_revision": "myapp-00001"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The revision never becomes ready and there are no descriptive error messages.
|
|
243
|
+
|
|
244
|
+
**Two common root causes** produce identical-looking `reason: "unknown"` failures:
|
|
245
|
+
|
|
246
|
+
#### Cause A โ Stale or expired ICR pull secret
|
|
247
|
+
|
|
248
|
+
Code Engine cannot pull the container image because the registry pull secret has outdated credentials. This is the most common cause when:
|
|
249
|
+
|
|
250
|
+
- You haven't deployed in a while (IAM tokens expire)
|
|
251
|
+
- The API key was rotated
|
|
252
|
+
- The secret was created manually or by a previous tool run without refreshing it first
|
|
253
|
+
|
|
254
|
+
**Fix โ use `ce_refresh_icr_pull_secret`:**
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"tool": "ce_refresh_icr_pull_secret",
|
|
259
|
+
"arguments": {
|
|
260
|
+
"project_id": "<your-project-id>",
|
|
261
|
+
"secret_name": "icr-pull-secret",
|
|
262
|
+
"icr_host": "us.icr.io"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
This tool uses the server's own `IBMCLOUD_API_KEY` to delete the stale secret and recreate it with fresh credentials โ no API key input required. After refreshing, redeploy the app with `ce_update_application` or `proc_build_push_deploy`.
|
|
268
|
+
|
|
269
|
+
> **Note:** Since version 1.0.8, `proc_build_push_deploy` automatically refreshes the pull secret as step 4.5 before creating or updating the app, so this manual step is only needed for older deployments or when using `ce_create_application` directly.
|
|
270
|
+
|
|
271
|
+
#### Cause B โ nginx port not rewritten (Alpine BusyBox `sed` limitation)
|
|
272
|
+
|
|
273
|
+
If your Dockerfile rewrites the nginx listen port using a `sed` command with `\s*` or `\s+` (Perl regex escapes), the rewrite silently fails on Alpine Linux because its BusyBox `sed` only supports POSIX regex โ **not** Perl escape sequences. nginx stays on port 80, but Code Engine health-checks port 8080, so the revision never passes.
|
|
274
|
+
|
|
275
|
+
**Symptom inside the container:**
|
|
276
|
+
```bash
|
|
277
|
+
# nginx is listening on 80 instead of 8080
|
|
278
|
+
nginx -T | grep listen # shows: listen 80
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Fix โ use POSIX character class in `sed`:**
|
|
282
|
+
|
|
283
|
+
```dockerfile
|
|
284
|
+
# WRONG โ \s* fails silently on Alpine BusyBox sed
|
|
285
|
+
RUN sed -i 's/listen\s*80;/listen 8080;/g' /etc/nginx/conf.d/default.conf
|
|
286
|
+
|
|
287
|
+
# CORRECT โ POSIX [[:space:]]* works on Alpine
|
|
288
|
+
RUN sed -i 's/listen[[:space:]]*80;/listen 8080;/g' /etc/nginx/conf.d/default.conf \
|
|
289
|
+
&& sed -i 's/listen[[:space:]]*\[::\]:80;/listen [::]:8080;/g' /etc/nginx/conf.d/default.conf
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
The `proc_validate_dockerfile` tool (and the built-in validator inside `proc_build_push_deploy`) now warn about `\s*` and `\s+` in `sed` patterns that touch the `listen` port line.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Tips
|
|
297
|
+
|
|
298
|
+
- Use the inspector's **Copy value** button on any result to paste exact JSON into a GitHub issue.
|
|
299
|
+
- The **History** panel persists across tool calls in the same session โ useful for comparing before/after behaviour when debugging.
|
|
300
|
+
- To test a freshly built change, kill the inspector, run `npm run build`, and relaunch.
|
|
301
|
+
- All `ce_` tools that need a `project_id` can discover it first with `ce_list_projects` โ the same workflow your AI assistant uses.
|