code-engine-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.
- package/LICENSE +21 -0
- package/README.md +387 -0
- package/build/client.d.ts +3 -0
- package/build/client.d.ts.map +1 -0
- package/build/client.js +194 -0
- package/build/client.js.map +1 -0
- package/build/context-discovery.d.ts +86 -0
- package/build/context-discovery.d.ts.map +1 -0
- package/build/context-discovery.js +291 -0
- package/build/context-discovery.js.map +1 -0
- package/build/deploy-tool-enhanced.d.ts +42 -0
- package/build/deploy-tool-enhanced.d.ts.map +1 -0
- package/build/deploy-tool-enhanced.js +323 -0
- package/build/deploy-tool-enhanced.js.map +1 -0
- package/build/deploy-tool.d.ts +27 -0
- package/build/deploy-tool.d.ts.map +1 -0
- package/build/deploy-tool.js +213 -0
- package/build/deploy-tool.js.map +1 -0
- package/build/index.d.ts +11 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1117 -0
- package/build/index.js.map +1 -0
- package/build/simple-client.d.ts +3 -0
- package/build/simple-client.d.ts.map +1 -0
- package/build/simple-client.js +275 -0
- package/build/simple-client.js.map +1 -0
- package/build/test-all-tools.d.ts +3 -0
- package/build/test-all-tools.d.ts.map +1 -0
- package/build/test-all-tools.js +254 -0
- package/build/test-all-tools.js.map +1 -0
- package/build/test-integration.d.ts +3 -0
- package/build/test-integration.d.ts.map +1 -0
- package/build/test-integration.js +484 -0
- package/build/test-integration.js.map +1 -0
- package/docs/API_CALL_SCENARIOS.md +594 -0
- package/docs/CLIENT_README.md +310 -0
- package/docs/CLINE_CONFIG_EXAMPLE.json +14 -0
- package/docs/CODE_ENGINE_API_REFERENCE.md +764 -0
- package/docs/CODE_OF_CONDUCT.md +46 -0
- package/docs/CONTRIBUTING.md +38 -0
- package/docs/MAINTAINERS.md +15 -0
- package/docs/SETUP_INSTRUCTIONS.md +218 -0
- package/package.json +44 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
# Code Engine API Reference for MCP
|
|
2
|
+
|
|
3
|
+
**Author:** Markus van Kempen | markus.van.kempen@gmail.com
|
|
4
|
+
**Research | Floor 7½ 🏢🤏**
|
|
5
|
+
|
|
6
|
+
**Official API Documentation:** https://cloud.ibm.com/apidocs/codeengine/v2
|
|
7
|
+
|
|
8
|
+
This document provides comprehensive API procedures that MCP tools can execute directly without creating standalone scripts.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
1. [Authentication](#authentication)
|
|
15
|
+
2. [Projects](#projects)
|
|
16
|
+
3. [Applications](#applications)
|
|
17
|
+
4. [Builds](#builds)
|
|
18
|
+
5. [Build Runs](#build-runs)
|
|
19
|
+
6. [Jobs](#jobs)
|
|
20
|
+
7. [Secrets & ConfigMaps](#secrets--configmaps)
|
|
21
|
+
8. [Common Workflows](#common-workflows)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Authentication
|
|
26
|
+
|
|
27
|
+
### Get IAM Token
|
|
28
|
+
|
|
29
|
+
**Purpose:** Authenticate with IBM Cloud to get access token for API calls
|
|
30
|
+
|
|
31
|
+
**Endpoint:** `POST https://iam.cloud.ibm.com/identity/token`
|
|
32
|
+
|
|
33
|
+
**Headers:**
|
|
34
|
+
```
|
|
35
|
+
Content-Type: application/x-www-form-urlencoded
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Body:**
|
|
39
|
+
```
|
|
40
|
+
grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey={IBM_CLOUD_API_KEY}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Response:**
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"access_token": "eyJhbGc...",
|
|
47
|
+
"refresh_token": "...",
|
|
48
|
+
"token_type": "Bearer",
|
|
49
|
+
"expires_in": 3600
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**MCP Tool:** Use `execute_command` to call via curl or implement as MCP tool
|
|
54
|
+
|
|
55
|
+
**Example:**
|
|
56
|
+
```bash
|
|
57
|
+
curl -X POST https://iam.cloud.ibm.com/identity/token \
|
|
58
|
+
-H "Content-Type: application/x-www-form-urlencoded" \
|
|
59
|
+
-d "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBM_CLOUD_API_KEY"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Projects
|
|
65
|
+
|
|
66
|
+
### List Projects
|
|
67
|
+
|
|
68
|
+
**Purpose:** Get all Code Engine projects in a region
|
|
69
|
+
|
|
70
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects`
|
|
71
|
+
|
|
72
|
+
**Headers:**
|
|
73
|
+
```
|
|
74
|
+
Authorization: Bearer {access_token}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Query Parameters:**
|
|
78
|
+
- `limit` (optional): Number of projects to return (default: 100)
|
|
79
|
+
- `start` (optional): Token for pagination
|
|
80
|
+
|
|
81
|
+
**Response:**
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"projects": [
|
|
85
|
+
{
|
|
86
|
+
"id": "7e131e87-e967-4e7f-a2f1-480957244eac",
|
|
87
|
+
"name": "markus-app-v2-toronto",
|
|
88
|
+
"region": "ca-tor",
|
|
89
|
+
"status": "active",
|
|
90
|
+
"created_at": "2026-05-07T18:39:19Z",
|
|
91
|
+
"resource_group_id": "..."
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"limit": 100
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Regions:**
|
|
99
|
+
- `us-south` - Dallas
|
|
100
|
+
- `us-east` - Washington DC
|
|
101
|
+
- `eu-de` - Frankfurt
|
|
102
|
+
- `eu-gb` - London
|
|
103
|
+
- `jp-tok` - Tokyo
|
|
104
|
+
- `jp-osa` - Osaka
|
|
105
|
+
- `au-syd` - Sydney
|
|
106
|
+
- `ca-tor` - Toronto
|
|
107
|
+
- `br-sao` - São Paulo
|
|
108
|
+
|
|
109
|
+
### Create Project
|
|
110
|
+
|
|
111
|
+
**Purpose:** Create a new Code Engine project
|
|
112
|
+
|
|
113
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects`
|
|
114
|
+
|
|
115
|
+
**Headers:**
|
|
116
|
+
```
|
|
117
|
+
Authorization: Bearer {access_token}
|
|
118
|
+
Content-Type: application/json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Body:**
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"name": "my-project",
|
|
125
|
+
"resource_group_id": "default"
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Response:**
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"id": "project-id",
|
|
133
|
+
"name": "my-project",
|
|
134
|
+
"region": "ca-tor",
|
|
135
|
+
"status": "creating",
|
|
136
|
+
"created_at": "2026-05-07T18:39:19Z"
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Get Project
|
|
141
|
+
|
|
142
|
+
**Purpose:** Get details of a specific project
|
|
143
|
+
|
|
144
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}`
|
|
145
|
+
|
|
146
|
+
**Headers:**
|
|
147
|
+
```
|
|
148
|
+
Authorization: Bearer {access_token}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Delete Project
|
|
152
|
+
|
|
153
|
+
**Purpose:** Delete a Code Engine project
|
|
154
|
+
|
|
155
|
+
**Endpoint:** `DELETE https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}`
|
|
156
|
+
|
|
157
|
+
**Headers:**
|
|
158
|
+
```
|
|
159
|
+
Authorization: Bearer {access_token}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Applications
|
|
165
|
+
|
|
166
|
+
### List Applications
|
|
167
|
+
|
|
168
|
+
**Purpose:** Get all applications in a project
|
|
169
|
+
|
|
170
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/apps`
|
|
171
|
+
|
|
172
|
+
**Headers:**
|
|
173
|
+
```
|
|
174
|
+
Authorization: Bearer {access_token}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Query Parameters:**
|
|
178
|
+
- `limit` (optional): Number of apps to return
|
|
179
|
+
- `start` (optional): Token for pagination
|
|
180
|
+
|
|
181
|
+
**Response:**
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"apps": [
|
|
185
|
+
{
|
|
186
|
+
"name": "markus-app-v2",
|
|
187
|
+
"status": "ready",
|
|
188
|
+
"image_reference": "icr.io/codeengine/helloworld",
|
|
189
|
+
"image_port": 8080,
|
|
190
|
+
"endpoint": "markus-app-v2.29m5mrru3s3n.ca-tor.codeengine.appdomain.cloud",
|
|
191
|
+
"scale_min_instances": 0,
|
|
192
|
+
"scale_max_instances": 1,
|
|
193
|
+
"scale_cpu_limit": "0.25",
|
|
194
|
+
"scale_memory_limit": "0.5G"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Create Application
|
|
201
|
+
|
|
202
|
+
**Purpose:** Create a new application
|
|
203
|
+
|
|
204
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/apps`
|
|
205
|
+
|
|
206
|
+
**Headers:**
|
|
207
|
+
```
|
|
208
|
+
Authorization: Bearer {access_token}
|
|
209
|
+
Content-Type: application/json
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Body:**
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"name": "my-app",
|
|
216
|
+
"image_reference": "icr.io/namespace/image:tag",
|
|
217
|
+
"image_port": 8080,
|
|
218
|
+
"scale_min_instances": 0,
|
|
219
|
+
"scale_max_instances": 10,
|
|
220
|
+
"scale_cpu_limit": "1",
|
|
221
|
+
"scale_memory_limit": "4G",
|
|
222
|
+
"run_env_variables": [
|
|
223
|
+
{
|
|
224
|
+
"type": "literal",
|
|
225
|
+
"name": "ENV_VAR",
|
|
226
|
+
"value": "value"
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Scaling Options:**
|
|
233
|
+
- `scale_min_instances`: Minimum instances (0 for scale-to-zero)
|
|
234
|
+
- `scale_max_instances`: Maximum instances
|
|
235
|
+
- `scale_cpu_limit`: CPU limit (0.125, 0.25, 0.5, 1, 2, 4, 6, 8)
|
|
236
|
+
- `scale_memory_limit`: Memory limit (0.25G, 0.5G, 1G, 2G, 4G, 8G, 16G, 32G)
|
|
237
|
+
- `scale_concurrency`: Requests per instance (default: 100)
|
|
238
|
+
- `scale_concurrency_target`: Target concurrency for scaling
|
|
239
|
+
|
|
240
|
+
**Environment Variables:**
|
|
241
|
+
- `type: "literal"` - Plain text value
|
|
242
|
+
- `type: "config_map_key_reference"` - Reference to ConfigMap
|
|
243
|
+
- `type: "secret_key_reference"` - Reference to Secret
|
|
244
|
+
|
|
245
|
+
### Get Application
|
|
246
|
+
|
|
247
|
+
**Purpose:** Get details of a specific application
|
|
248
|
+
|
|
249
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/apps/{app_name}`
|
|
250
|
+
|
|
251
|
+
**Headers:**
|
|
252
|
+
```
|
|
253
|
+
Authorization: Bearer {access_token}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Update Application
|
|
257
|
+
|
|
258
|
+
**Purpose:** Update an existing application
|
|
259
|
+
|
|
260
|
+
**Endpoint:** `PATCH https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/apps/{app_name}`
|
|
261
|
+
|
|
262
|
+
**Headers:**
|
|
263
|
+
```
|
|
264
|
+
Authorization: Bearer {access_token}
|
|
265
|
+
Content-Type: application/merge-patch+json
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Body:** (only include fields to update)
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"image_reference": "icr.io/namespace/image:new-tag",
|
|
272
|
+
"scale_max_instances": 5
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Delete Application
|
|
277
|
+
|
|
278
|
+
**Purpose:** Delete an application
|
|
279
|
+
|
|
280
|
+
**Endpoint:** `DELETE https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/apps/{app_name}`
|
|
281
|
+
|
|
282
|
+
**Headers:**
|
|
283
|
+
```
|
|
284
|
+
Authorization: Bearer {access_token}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Builds
|
|
290
|
+
|
|
291
|
+
### List Builds
|
|
292
|
+
|
|
293
|
+
**Purpose:** Get all build configurations in a project
|
|
294
|
+
|
|
295
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/builds`
|
|
296
|
+
|
|
297
|
+
**Headers:**
|
|
298
|
+
```
|
|
299
|
+
Authorization: Bearer {access_token}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Create Build
|
|
303
|
+
|
|
304
|
+
**Purpose:** Create a build configuration
|
|
305
|
+
|
|
306
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/builds`
|
|
307
|
+
|
|
308
|
+
**Headers:**
|
|
309
|
+
```
|
|
310
|
+
Authorization: Bearer {access_token}
|
|
311
|
+
Content-Type: application/json
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Body:**
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"name": "my-build",
|
|
318
|
+
"output_image": "private.{region}.icr.io/{project_id}/my-image",
|
|
319
|
+
"output_secret": "ce-auto-icr-private-{region}",
|
|
320
|
+
"source_type": "local",
|
|
321
|
+
"strategy_type": "dockerfile",
|
|
322
|
+
"strategy_spec_file": "Dockerfile",
|
|
323
|
+
"strategy_size": "medium"
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**Source Types:**
|
|
328
|
+
- `local` - Upload source code directly
|
|
329
|
+
- `git` - Build from Git repository
|
|
330
|
+
|
|
331
|
+
**Strategy Types:**
|
|
332
|
+
- `dockerfile` - Use Dockerfile
|
|
333
|
+
- `buildpacks` - Use Cloud Native Buildpacks
|
|
334
|
+
|
|
335
|
+
**Strategy Sizes:**
|
|
336
|
+
- `small` - 2 vCPU, 4 GB memory
|
|
337
|
+
- `medium` - 4 vCPU, 8 GB memory
|
|
338
|
+
- `large` - 8 vCPU, 16 GB memory
|
|
339
|
+
- `xlarge` - 16 vCPU, 32 GB memory
|
|
340
|
+
|
|
341
|
+
### Get Build
|
|
342
|
+
|
|
343
|
+
**Purpose:** Get details of a build configuration
|
|
344
|
+
|
|
345
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/builds/{build_name}`
|
|
346
|
+
|
|
347
|
+
**Headers:**
|
|
348
|
+
```
|
|
349
|
+
Authorization: Bearer {access_token}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Delete Build
|
|
353
|
+
|
|
354
|
+
**Purpose:** Delete a build configuration
|
|
355
|
+
|
|
356
|
+
**Endpoint:** `DELETE https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/builds/{build_name}`
|
|
357
|
+
|
|
358
|
+
**Headers:**
|
|
359
|
+
```
|
|
360
|
+
Authorization: Bearer {access_token}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Build Runs
|
|
366
|
+
|
|
367
|
+
### List Build Runs
|
|
368
|
+
|
|
369
|
+
**Purpose:** Get all build runs in a project
|
|
370
|
+
|
|
371
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/build_runs`
|
|
372
|
+
|
|
373
|
+
**Headers:**
|
|
374
|
+
```
|
|
375
|
+
Authorization: Bearer {access_token}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Create Build Run
|
|
379
|
+
|
|
380
|
+
**Purpose:** Start a new build
|
|
381
|
+
|
|
382
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/build_runs`
|
|
383
|
+
|
|
384
|
+
**Headers:**
|
|
385
|
+
```
|
|
386
|
+
Authorization: Bearer {access_token}
|
|
387
|
+
Content-Type: application/json
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Body:**
|
|
391
|
+
```json
|
|
392
|
+
{
|
|
393
|
+
"build_name": "my-build",
|
|
394
|
+
"name": "my-build-run-123"
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Response:**
|
|
399
|
+
```json
|
|
400
|
+
{
|
|
401
|
+
"name": "my-build-run-123",
|
|
402
|
+
"status": "pending",
|
|
403
|
+
"build_name": "my-build",
|
|
404
|
+
"created_at": "2026-05-07T18:42:19Z"
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Upload Source Code
|
|
409
|
+
|
|
410
|
+
**Purpose:** Upload source code for a build run
|
|
411
|
+
|
|
412
|
+
**Endpoint:** `PUT https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/build_runs/{build_run_name}/source`
|
|
413
|
+
|
|
414
|
+
**Headers:**
|
|
415
|
+
```
|
|
416
|
+
Authorization: Bearer {access_token}
|
|
417
|
+
Content-Type: multipart/form-data
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Body:** (multipart form data)
|
|
421
|
+
```
|
|
422
|
+
file: <source_code.zip>
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Note:** Source code must be a ZIP archive
|
|
426
|
+
|
|
427
|
+
### Get Build Run
|
|
428
|
+
|
|
429
|
+
**Purpose:** Get status of a build run
|
|
430
|
+
|
|
431
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/build_runs/{build_run_name}`
|
|
432
|
+
|
|
433
|
+
**Headers:**
|
|
434
|
+
```
|
|
435
|
+
Authorization: Bearer {access_token}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
**Response:**
|
|
439
|
+
```json
|
|
440
|
+
{
|
|
441
|
+
"name": "my-build-run-123",
|
|
442
|
+
"status": "succeeded",
|
|
443
|
+
"output_image": "private.ca-tor.icr.io/project-id/my-image:latest",
|
|
444
|
+
"status_details": {
|
|
445
|
+
"completion_time": "2026-05-07T18:45:00Z",
|
|
446
|
+
"reason": "Succeeded"
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
**Status Values:**
|
|
452
|
+
- `pending` - Build queued
|
|
453
|
+
- `running` - Build in progress
|
|
454
|
+
- `succeeded` - Build completed successfully
|
|
455
|
+
- `failed` - Build failed
|
|
456
|
+
|
|
457
|
+
### Delete Build Run
|
|
458
|
+
|
|
459
|
+
**Purpose:** Delete a build run
|
|
460
|
+
|
|
461
|
+
**Endpoint:** `DELETE https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/build_runs/{build_run_name}`
|
|
462
|
+
|
|
463
|
+
**Headers:**
|
|
464
|
+
```
|
|
465
|
+
Authorization: Bearer {access_token}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## Jobs
|
|
471
|
+
|
|
472
|
+
### List Jobs
|
|
473
|
+
|
|
474
|
+
**Purpose:** Get all jobs in a project
|
|
475
|
+
|
|
476
|
+
**Endpoint:** `GET https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/jobs`
|
|
477
|
+
|
|
478
|
+
**Headers:**
|
|
479
|
+
```
|
|
480
|
+
Authorization: Bearer {access_token}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Create Job
|
|
484
|
+
|
|
485
|
+
**Purpose:** Create a job definition
|
|
486
|
+
|
|
487
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/jobs`
|
|
488
|
+
|
|
489
|
+
**Headers:**
|
|
490
|
+
```
|
|
491
|
+
Authorization: Bearer {access_token}
|
|
492
|
+
Content-Type: application/json
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**Body:**
|
|
496
|
+
```json
|
|
497
|
+
{
|
|
498
|
+
"name": "my-job",
|
|
499
|
+
"image_reference": "icr.io/namespace/image:tag",
|
|
500
|
+
"run_mode": "task",
|
|
501
|
+
"scale_array_spec": "1-5",
|
|
502
|
+
"scale_cpu_limit": "1",
|
|
503
|
+
"scale_memory_limit": "4G",
|
|
504
|
+
"scale_max_execution_time": 7200
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### Submit Job Run
|
|
509
|
+
|
|
510
|
+
**Purpose:** Run a job
|
|
511
|
+
|
|
512
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/job_runs`
|
|
513
|
+
|
|
514
|
+
**Headers:**
|
|
515
|
+
```
|
|
516
|
+
Authorization: Bearer {access_token}
|
|
517
|
+
Content-Type: application/json
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
**Body:**
|
|
521
|
+
```json
|
|
522
|
+
{
|
|
523
|
+
"job_name": "my-job",
|
|
524
|
+
"name": "my-job-run-123"
|
|
525
|
+
}
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
## Secrets & ConfigMaps
|
|
531
|
+
|
|
532
|
+
### Create Secret
|
|
533
|
+
|
|
534
|
+
**Purpose:** Store sensitive data
|
|
535
|
+
|
|
536
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/secrets`
|
|
537
|
+
|
|
538
|
+
**Headers:**
|
|
539
|
+
```
|
|
540
|
+
Authorization: Bearer {access_token}
|
|
541
|
+
Content-Type: application/json
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
**Body:**
|
|
545
|
+
```json
|
|
546
|
+
{
|
|
547
|
+
"name": "my-secret",
|
|
548
|
+
"format": "generic",
|
|
549
|
+
"data": {
|
|
550
|
+
"key1": "base64_encoded_value",
|
|
551
|
+
"key2": "base64_encoded_value"
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**Secret Formats:**
|
|
557
|
+
- `generic` - Generic secret
|
|
558
|
+
- `ssh_auth` - SSH authentication
|
|
559
|
+
- `basic_auth` - Basic authentication
|
|
560
|
+
- `tls` - TLS certificate
|
|
561
|
+
- `service_access` - Service credentials
|
|
562
|
+
- `registry` - Container registry credentials
|
|
563
|
+
|
|
564
|
+
### Create ConfigMap
|
|
565
|
+
|
|
566
|
+
**Purpose:** Store non-sensitive configuration
|
|
567
|
+
|
|
568
|
+
**Endpoint:** `POST https://api.{region}.codeengine.cloud.ibm.com/v2/projects/{project_id}/config_maps`
|
|
569
|
+
|
|
570
|
+
**Headers:**
|
|
571
|
+
```
|
|
572
|
+
Authorization: Bearer {access_token}
|
|
573
|
+
Content-Type: application/json
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
**Body:**
|
|
577
|
+
```json
|
|
578
|
+
{
|
|
579
|
+
"name": "my-config",
|
|
580
|
+
"data": {
|
|
581
|
+
"config_key": "config_value"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
## Common Workflows
|
|
589
|
+
|
|
590
|
+
### Workflow 1: Deploy Application with Public Image
|
|
591
|
+
|
|
592
|
+
**Steps:**
|
|
593
|
+
1. Get IAM token
|
|
594
|
+
2. List projects to find project ID
|
|
595
|
+
3. Create/update application with image reference
|
|
596
|
+
|
|
597
|
+
**MCP Tool Sequence:**
|
|
598
|
+
```
|
|
599
|
+
1. execute_command: Get IAM token
|
|
600
|
+
2. execute_command: List projects
|
|
601
|
+
3. execute_command: Create application
|
|
602
|
+
4. execute_command: Get application status
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Workflow 2: Build and Deploy from Source
|
|
606
|
+
|
|
607
|
+
**Steps:**
|
|
608
|
+
1. Get IAM token
|
|
609
|
+
2. Get project ID
|
|
610
|
+
3. Create build configuration
|
|
611
|
+
4. Create build run
|
|
612
|
+
5. Upload source code ZIP
|
|
613
|
+
6. Wait for build to complete
|
|
614
|
+
7. Create/update application with built image
|
|
615
|
+
|
|
616
|
+
**MCP Tool Sequence:**
|
|
617
|
+
```
|
|
618
|
+
1. execute_command: Get IAM token
|
|
619
|
+
2. execute_command: Get project ID
|
|
620
|
+
3. execute_command: Create build
|
|
621
|
+
4. execute_command: Create build run
|
|
622
|
+
5. execute_command: Upload source (multipart)
|
|
623
|
+
6. execute_command: Poll build run status
|
|
624
|
+
7. execute_command: Create/update application
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Workflow 3: Update Application Image
|
|
628
|
+
|
|
629
|
+
**Steps:**
|
|
630
|
+
1. Get IAM token
|
|
631
|
+
2. Get project ID
|
|
632
|
+
3. Update application with new image
|
|
633
|
+
|
|
634
|
+
**MCP Tool Sequence:**
|
|
635
|
+
```
|
|
636
|
+
1. execute_command: Get IAM token
|
|
637
|
+
2. execute_command: Get project ID
|
|
638
|
+
3. execute_command: PATCH application
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### Workflow 4: Scale Application
|
|
642
|
+
|
|
643
|
+
**Steps:**
|
|
644
|
+
1. Get IAM token
|
|
645
|
+
2. Get project ID
|
|
646
|
+
3. Update application scaling parameters
|
|
647
|
+
|
|
648
|
+
**MCP Tool Sequence:**
|
|
649
|
+
```
|
|
650
|
+
1. execute_command: Get IAM token
|
|
651
|
+
2. execute_command: Get project ID
|
|
652
|
+
3. execute_command: PATCH application with new scale settings
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### Workflow 5: Deploy to New Region
|
|
656
|
+
|
|
657
|
+
**Steps:**
|
|
658
|
+
1. Get IAM token
|
|
659
|
+
2. List projects in target region
|
|
660
|
+
3. Create project if needed
|
|
661
|
+
4. Create application in new region
|
|
662
|
+
|
|
663
|
+
**MCP Tool Sequence:**
|
|
664
|
+
```
|
|
665
|
+
1. execute_command: Get IAM token
|
|
666
|
+
2. execute_command: List projects in region
|
|
667
|
+
3. execute_command: Create project (if needed)
|
|
668
|
+
4. execute_command: Create application
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
---
|
|
672
|
+
|
|
673
|
+
## Error Handling
|
|
674
|
+
|
|
675
|
+
### Common HTTP Status Codes
|
|
676
|
+
|
|
677
|
+
- `200 OK` - Success
|
|
678
|
+
- `201 Created` - Resource created
|
|
679
|
+
- `204 No Content` - Success with no response body
|
|
680
|
+
- `400 Bad Request` - Invalid request
|
|
681
|
+
- `401 Unauthorized` - Invalid or expired token
|
|
682
|
+
- `403 Forbidden` - Insufficient permissions
|
|
683
|
+
- `404 Not Found` - Resource not found
|
|
684
|
+
- `409 Conflict` - Resource already exists
|
|
685
|
+
- `429 Too Many Requests` - Rate limit exceeded
|
|
686
|
+
- `500 Internal Server Error` - Server error
|
|
687
|
+
|
|
688
|
+
### Error Response Format
|
|
689
|
+
|
|
690
|
+
```json
|
|
691
|
+
{
|
|
692
|
+
"errors": [
|
|
693
|
+
{
|
|
694
|
+
"code": "error_code",
|
|
695
|
+
"message": "Error description",
|
|
696
|
+
"target": {
|
|
697
|
+
"type": "field",
|
|
698
|
+
"name": "field_name"
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
],
|
|
702
|
+
"trace": "trace-id",
|
|
703
|
+
"status_code": 400
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
## Best Practices
|
|
710
|
+
|
|
711
|
+
1. **Token Management**
|
|
712
|
+
- Cache IAM tokens (valid for 1 hour)
|
|
713
|
+
- Refresh before expiration
|
|
714
|
+
- Don't request new token for every API call
|
|
715
|
+
|
|
716
|
+
2. **Polling**
|
|
717
|
+
- Use reasonable intervals (5-10 seconds)
|
|
718
|
+
- Implement timeout limits
|
|
719
|
+
- Check status before proceeding
|
|
720
|
+
|
|
721
|
+
3. **Error Handling**
|
|
722
|
+
- Always check HTTP status codes
|
|
723
|
+
- Parse error messages for details
|
|
724
|
+
- Implement retry logic for transient errors
|
|
725
|
+
|
|
726
|
+
4. **Resource Naming**
|
|
727
|
+
- Use lowercase letters, numbers, hyphens
|
|
728
|
+
- Start with letter
|
|
729
|
+
- Max 63 characters
|
|
730
|
+
- Must be unique within project
|
|
731
|
+
|
|
732
|
+
5. **Image References**
|
|
733
|
+
- Use specific tags, not `latest`
|
|
734
|
+
- Include full registry path
|
|
735
|
+
- Verify image exists before deployment
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
739
|
+
## MCP Integration
|
|
740
|
+
|
|
741
|
+
All these API calls can be executed through MCP tools:
|
|
742
|
+
|
|
743
|
+
1. **execute_command** - For curl-based API calls
|
|
744
|
+
2. **Custom MCP Tools** - Implement dedicated Code Engine tools
|
|
745
|
+
3. **Skill Orchestration** - Bob skill coordinates the workflow
|
|
746
|
+
|
|
747
|
+
**Example MCP Tool Implementation:**
|
|
748
|
+
```typescript
|
|
749
|
+
{
|
|
750
|
+
name: "code_engine_api",
|
|
751
|
+
description: "Execute Code Engine API calls",
|
|
752
|
+
inputSchema: {
|
|
753
|
+
type: "object",
|
|
754
|
+
properties: {
|
|
755
|
+
action: { type: "string", enum: ["list_projects", "create_app", ...] },
|
|
756
|
+
region: { type: "string" },
|
|
757
|
+
project_id: { type: "string" },
|
|
758
|
+
parameters: { type: "object" }
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
This allows Bob to execute any Code Engine operation through MCP without creating standalone scripts.
|