constructor-research-mcp 0.4.0-beta.3 → 0.4.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/INSTALL.md CHANGED
@@ -18,13 +18,13 @@ The key is required: the MCP does nothing without it. The address is `https://co
18
18
  claude mcp add --scope user constructor-research \
19
19
  -e CONSTRUCTOR_BASE_URL=https://constructor.app \
20
20
  -e CONSTRUCTOR_ACCESS_KEY=rk-your-key \
21
- -- npx -y constructor-research-mcp@beta
21
+ -- npx -y constructor-research-mcp@latest
22
22
  ```
23
23
 
24
24
  On Windows (not WSL), use this instead:
25
25
 
26
26
  ```bat
27
- claude mcp add --scope user constructor-research -e CONSTRUCTOR_BASE_URL=https://constructor.app -e CONSTRUCTOR_ACCESS_KEY=rk-your-key -- cmd /c npx -y constructor-research-mcp@beta
27
+ claude mcp add --scope user constructor-research -e CONSTRUCTOR_BASE_URL=https://constructor.app -e CONSTRUCTOR_ACCESS_KEY=rk-your-key -- cmd /c npx -y constructor-research-mcp@latest
28
28
  ```
29
29
 
30
30
  **Codex**: run once:
@@ -33,7 +33,7 @@ claude mcp add --scope user constructor-research -e CONSTRUCTOR_BASE_URL=https:/
33
33
  codex mcp add constructor-research \
34
34
  --env CONSTRUCTOR_BASE_URL=https://constructor.app \
35
35
  --env CONSTRUCTOR_ACCESS_KEY=rk-your-key \
36
- -- npx -y constructor-research-mcp@beta
36
+ -- npx -y constructor-research-mcp@latest
37
37
  ```
38
38
 
39
39
  The first start downloads the package and can exceed Codex's 10-second start limit. If Codex reports a timeout, restart it once, or add `startup_timeout_sec = 60` under `[mcp_servers.constructor-research]` in `~/.codex/config.toml`. The full entry, if you prefer to write it by hand:
@@ -41,7 +41,7 @@ The first start downloads the package and can exceed Codex's 10-second start lim
41
41
  ```toml
42
42
  [mcp_servers.constructor-research]
43
43
  command = "npx"
44
- args = ["-y", "constructor-research-mcp@beta"]
44
+ args = ["-y", "constructor-research-mcp@latest"]
45
45
  startup_timeout_sec = 60
46
46
  tool_timeout_sec = 30
47
47
 
@@ -58,7 +58,7 @@ CONSTRUCTOR_ACCESS_KEY = "rk-your-key"
58
58
  "mcp": {
59
59
  "constructor-research": {
60
60
  "type": "local",
61
- "command": ["npx", "-y", "constructor-research-mcp@beta"],
61
+ "command": ["npx", "-y", "constructor-research-mcp@latest"],
62
62
  "environment": {
63
63
  "CONSTRUCTOR_BASE_URL": "https://constructor.app",
64
64
  "CONSTRUCTOR_ACCESS_KEY": "rk-your-key"
@@ -74,10 +74,10 @@ Then restart the tool, or run `/mcp` in Claude Code, so it starts the MCP. The f
74
74
 
75
75
  ## 2. Or keep the key out of the tool's settings
76
76
 
77
- Step 1 stores the key in the tool's settings file (`~/.claude.json`, `~/.codex/config.toml`, `opencode.json`). To avoid that, add the MCP without the two variables (`claude mcp add --scope user constructor-research -- npx -y constructor-research-mcp@beta`, and the same for Codex and OpenCode) and save the key in a terminal; it asks for the key without showing it:
77
+ Step 1 stores the key in the tool's settings file (`~/.claude.json`, `~/.codex/config.toml`, `opencode.json`). To avoid that, add the MCP without the two variables (`claude mcp add --scope user constructor-research -- npx -y constructor-research-mcp@latest`, and the same for Codex and OpenCode) and save the key in a terminal; it asks for the key without showing it:
78
78
 
79
79
  ```sh
80
- npx -y -p constructor-research-mcp@beta constructor-research-set-key https://constructor.app
80
+ npx -y -p constructor-research-mcp@latest constructor-research-set-key https://constructor.app
81
81
  ```
82
82
 
83
83
  It checks the key with Constructor and saves it, with that address, to `~/.config/constructor-research/access-key.json` (readable only by you). Claude Code, Codex, OpenCode and the wait hooks all use this one file, and a new key needs no restart. To switch Constructor or replace a revoked key, run it again. A key set in the tool's settings wins over the file. Never paste the key into the chat.
@@ -92,7 +92,7 @@ Builds can take many minutes. These add-ons wake the agent when a deployment it
92
92
 
93
93
  ## Update
94
94
 
95
- Restart the tool (or `/mcp` in Claude Code): `@beta` fetches the newest beta on start. Your key is kept.
95
+ Restart the tool (or `/mcp` in Claude Code): `@latest` fetches the newest version on start. Your key is kept.
96
96
 
97
97
  ## Troubleshooting
98
98
 
@@ -109,7 +109,7 @@ which npx
109
109
  **Check the MCP on its own.** Run the MCP Inspector, then turn on the server's toggle and open Tools:
110
110
 
111
111
  ```sh
112
- npx @modelcontextprotocol/inspector@2.11.0 -- npx -y constructor-research-mcp@beta
112
+ npx @modelcontextprotocol/inspector@2.11.0 -- npx -y constructor-research-mcp@latest
113
113
  ```
114
114
 
115
115
  ## Uninstall
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Constructor Research MCP
2
2
 
3
- > **Beta (0.4.0-beta):** works only with Constructor's public API and a personal access key (`rk-…`); there is no browser sign-in. The public API is not yet on every Constructor. Install with `@beta`; `@latest` is still 0.3.x with browser sign-in.
3
+ > **0.4:** works with Constructor's public API and a personal access key (`rk-…`); browser sign-in is gone. On a Constructor without the public API yet, pin the previous version: `constructor-research-mcp@0.3.3`.
4
4
 
5
5
  Local stdio MCP for Codex CLI, Claude Code and OpenCode. Submit the whole application once; the MCP builds images, connects services, configures them and starts them. The agent supplies missing configuration and reports the result.
6
6
 
@@ -14,7 +14,7 @@ You need Node.js 22+ and your personal access key (`rk-…`); the MCP does not w
14
14
  claude mcp add --scope user constructor-research \
15
15
  -e CONSTRUCTOR_BASE_URL=https://constructor.app \
16
16
  -e CONSTRUCTOR_ACCESS_KEY=rk-your-key \
17
- -- npx -y constructor-research-mcp@beta
17
+ -- npx -y constructor-research-mcp@latest
18
18
  ```
19
19
 
20
20
  **Codex**
@@ -23,7 +23,7 @@ claude mcp add --scope user constructor-research \
23
23
  codex mcp add constructor-research \
24
24
  --env CONSTRUCTOR_BASE_URL=https://constructor.app \
25
25
  --env CONSTRUCTOR_ACCESS_KEY=rk-your-key \
26
- -- npx -y constructor-research-mcp@beta
26
+ -- npx -y constructor-research-mcp@latest
27
27
  ```
28
28
 
29
29
  **OpenCode**: add the entry to `~/.config/opencode/opencode.json` (layouts for 1.x and 2.x in [INSTALL.md](INSTALL.md)).
@@ -37,7 +37,7 @@ The key then sits in the tool's settings file (`~/.claude.json`, `~/.codex/confi
37
37
  The MCP uses only a personal access key (`rk-…`) from Constructor's public API; there is no browser sign-in. Every request carries it as `X-Research-AccessKey: Bearer rk-…`, to the account API (`/api/platform-account/v1`), the desk storage (WebDAV) and the logs alike. The key never goes through the chat. It comes from the MCP settings (`CONSTRUCTOR_ACCESS_KEY`, with `CONSTRUCTOR_BASE_URL`, as in Install), or from a key file the user saves in a terminal, where the key is read hidden, checked against Constructor and saved:
38
38
 
39
39
  ```sh
40
- npx -y -p constructor-research-mcp@beta constructor-research-set-key https://acme.constructor.app
40
+ npx -y -p constructor-research-mcp@latest constructor-research-set-key https://acme.constructor.app
41
41
  ```
42
42
 
43
43
  It goes to `~/.config/constructor-research/access-key.json` (mode 600) together with the Constructor it belongs to, and the MCP works with that Constructor. All harnesses (Claude Code, Codex, OpenCode) and the wait command share this one file. Every request rereads it, so a new key needs no restart. A key is never sent to a Constructor other than the one it was saved for.
@@ -46,7 +46,7 @@ It goes to `~/.config/constructor-research/access-key.json` (mode 600) together
46
46
 
47
47
  Without a key, or when Constructor rejects it (401: revoked, expired or for another Constructor), tools return `needs_key` with the command above; a deployment pauses as `needs_key` and resumes on the next check once a valid key is saved. A desk link from another Constructor returns `wrong_environment`.
48
48
 
49
- Deployment must be switched on for the project. If it is off and the key may not switch it on (403), the operation fails at stage `prepare` with a message asking the user to switch it on in Constructor.
49
+ Deployment must be switched on for the project. When it is off, the MCP switches it on (`POST /projects/{id}/deployment`), which only the project owner may do. For anyone else (error 40005), the operation fails at stage `prepare` with a message asking the project owner to switch it on in Constructor.
50
50
 
51
51
  | Variable | Default |
52
52
  | ----------------------------------- | ----------------------------------------------------------------------------------------------- |
@@ -102,6 +102,12 @@ https://constructor.app/research/projects/<project_id>/desks/<desk_id>/viewer/fi
102
102
 
103
103
  Every tool accepts it as `desk_url`, in place of `project_id`/`desk_id`. Anything after `/desks/<desk_id>` is ignored. The link's host must be the Constructor the key belongs to; a link from another one returns `wrong_environment` (see the access key above). Explicit IDs, if also sent, must agree with the link. In `deploy_app`/`update_app`, builds without their own `desk_id` use the link's desk; `start_app`/`stop_app` and `get_deployment` take only the project from it.
104
104
 
105
+ Given only `project_id`, the MCP finds the desk itself:
106
+
107
+ - one desk in the project: it is used;
108
+ - no desk: `deploy_app`/`update_app` create one (`<application>-source`) for the sources; the file tools return an error;
109
+ - several desks: nothing is changed and the tool returns `desk_choice_required` with each desk's `name`, `id` and `desk_url`. The agent asks the user which one and repeats the call with that link or ID.
110
+
105
111
  ## Normal deployment flow
106
112
 
107
113
  1. Inspect with `get_deployment`: no arguments returns the map of all deployments (every deployment-enabled project → applications → services with names, native statuses, public URLs and ports; other projects are listed by name only); `desk_url` or `project_id` returns that project's disks, images, hardware and apps; add `application_id` for service details.
@@ -171,7 +177,9 @@ Private DNS works between containers; browser JavaScript needs a public backend
171
177
 
172
178
  ### Image reuse and limits
173
179
 
174
- Replace a service's `build` with `"image_id":"IMAGE_ID"` to skip building. `list_images` returns compact records with `not_started`, `snapshot_creation`, `in_progress`, `done` or `error`; `detailed:true` returns full records.
180
+ Replace a service's `build` with `"image_id":"IMAGE_ID"` to skip building, or with `"image":"registry/repo:tag"` to name an image already in the project by its reference or name. `list_images` returns compact records with `source` (`desk_build` or `external`), `reference` and `build_status` (`not_started`, `snapshot_creation`, `in_progress`, `done` or `error`); `detailed:true` returns full records.
181
+
182
+ External images (`source: external`) are pulled, not built, so they are accepted whatever their build status, unless it is `error`. They are added to the project in Constructor: the public API has no endpoint to add one, so `image` only finds images that are already there and lists the project's external images when nothing matches.
175
183
 
176
184
  - Build storage is omitted by default, using the API's documented **50 GB** default. Explicit `ephemeral_build_disk_size_gb` overrides must be **10–1000 GB**.
177
185
  - Each service can have multiple ports (1–65535), with at most **one public port**. That port must match where the container listens.
@@ -253,7 +261,7 @@ Constructor serves logs only live, as a stream: a build log while the build runs
253
261
  Builds can run for many minutes. The MCP keeps executing in the background, but an agent that has ended its turn is not told when they finish. `dist/wait.js` (bin `constructor-research-wait`) blocks until the given deployments, or all in-progress ones when no ID is given, finish, and prints one line each: status, message, services with public URLs, next step. Exit codes: `0` finished, `2` needs the user (failed, key, upload, volume confirmation), `3` still running at `--max-minutes` (default 60), `4` nothing in progress.
254
262
 
255
263
  ```sh
256
- npx -y -p constructor-research-mcp@beta constructor-research-wait <deployment_id>
264
+ npx -y -p constructor-research-mcp@latest constructor-research-wait <deployment_id>
257
265
  ```
258
266
 
259
267
  It watches the checkpoints the MCP writes. For deployments named by ID, if no process has advanced one for a minute (the MCP was closed), it continues it itself, exactly as the MCP would on restart. Without IDs it only watches, since those deployments may belong to other sessions. While a deployment runs, `next_action` gives the agent the exact command, including the MCP's non-default `CONSTRUCTOR_*` settings; the wait command needs the same settings as the MCP.
package/dist/api.d.ts CHANGED
@@ -3,7 +3,11 @@ export declare class ToolError extends Error {
3
3
  code: string;
4
4
  status?: number | undefined;
5
5
  apiCode?: number | undefined;
6
- constructor(code: string, message: string, status?: number | undefined, apiCode?: number | undefined);
6
+ /** Extra fields returned to the agent next to status and message. */
7
+ details?: Record<string, unknown> | undefined;
8
+ constructor(code: string, message: string, status?: number | undefined, apiCode?: number | undefined,
9
+ /** Extra fields returned to the agent next to status and message. */
10
+ details?: Record<string, unknown> | undefined);
7
11
  }
8
12
  export declare const segment: (s: string) => string;
9
13
  /** A key as Constructor shows it, with or without the "Bearer " the header adds. */
package/dist/api.js CHANGED
@@ -6,11 +6,15 @@ export class ToolError extends Error {
6
6
  code;
7
7
  status;
8
8
  apiCode;
9
- constructor(code, message, status, apiCode) {
9
+ details;
10
+ constructor(code, message, status, apiCode,
11
+ /** Extra fields returned to the agent next to status and message. */
12
+ details) {
10
13
  super(message);
11
14
  this.code = code;
12
15
  this.status = status;
13
16
  this.apiCode = apiCode;
17
+ this.details = details;
14
18
  }
15
19
  }
16
20
  export const segment = (s) => encodeURIComponent(s);
@@ -50,6 +50,15 @@ export declare class DeploymentEngine {
50
50
  * and wait; it takes about 30-40 s.
51
51
  */
52
52
  filesDesk(project: string, id: string): Promise<any>;
53
+ /** An image a service can run: built here, or external (pulled, never built). */
54
+ static usable(im: any): boolean;
55
+ /**
56
+ * The desk to use when the call names only the project: the only desk, a new one
57
+ * when there is none and `create` is given, otherwise the user chooses.
58
+ */
59
+ deskFor(project: string, create?: string): Promise<string>;
60
+ /** Turn each service's `image` (reference or name) into the project's image_id. */
61
+ resolveImages(project: string, services: any[]): Promise<any[]>;
53
62
  listImages(raw: unknown): Promise<{
54
63
  results: any[];
55
64
  total: number;
@@ -370,6 +370,58 @@ export class DeploymentEngine {
370
370
  return d;
371
371
  throw new ToolError("not_ready", `The desk's file storage was stopped (desk not used recently), so the MCP started it, as opening the desk in the browser does. It is still ${status ?? "starting"}; this takes about 30-40 s. Nothing was changed. Repeat the same call in a moment.`);
372
372
  }
373
+ /** An image a service can run: built here, or external (pulled, never built). */
374
+ static usable(im) {
375
+ return im?.source === "external"
376
+ ? im.build_status !== "error"
377
+ : im?.build_status === "done";
378
+ }
379
+ /**
380
+ * The desk to use when the call names only the project: the only desk, a new one
381
+ * when there is none and `create` is given, otherwise the user chooses.
382
+ */
383
+ async deskFor(project, create) {
384
+ await this.project(project);
385
+ const desks = await this.rows(this.root(project) + "/desks");
386
+ if (desks.length === 1)
387
+ return desks[0].id;
388
+ if (desks.length > 1)
389
+ throw new ToolError("desk_choice_required", `Project ${project} has ${desks.length} desks: ${desks.map((d) => `${d.name} (${d.id})`).join(", ")}. Nothing was changed. Ask the user which desk to use (name or link), then repeat the call with desk_url, or desk_id (build.desk_id for a service).`, undefined, undefined, {
390
+ desks: desks.map((d) => ({
391
+ id: d.id,
392
+ name: d.name,
393
+ desk_url: this.deskLink(project, d.id),
394
+ })),
395
+ });
396
+ if (!create)
397
+ bad(`Project ${project} has no desk. Ask the user to create one in Constructor, or deploy a local folder (deploy_app creates a desk for it).`);
398
+ const d = await this.api.request("POST", this.root(project) + "/desks", {
399
+ name: create,
400
+ });
401
+ return d.id;
402
+ }
403
+ /** Turn each service's `image` (reference or name) into the project's image_id. */
404
+ async resolveImages(project, services) {
405
+ if (!services?.some((s) => s.image))
406
+ return services;
407
+ const images = await this.images(project);
408
+ return services.map((s) => {
409
+ if (!s.image)
410
+ return s;
411
+ const want = s.image.trim();
412
+ const hits = images.filter((im) => im.reference === want || im.name === want || im.id === want);
413
+ const im = hits.length > 1
414
+ ? (hits.find((x) => x.reference === want) ??
415
+ bad(`Image "${want}" for ${s.name} matches several images: ${hits.map((x) => x.id).join(", ")}. Pass image_id.`))
416
+ : hits[0];
417
+ if (!im) {
418
+ const ext = images.filter((x) => x.source === "external");
419
+ bad(`Image "${want}" for ${s.name} is not in this project. ${ext.length ? `External images here: ${ext.map((x) => `${x.reference ?? x.name} (${x.id})`).join(", ")}.` : "The project has no external images."} An external image is added in Constructor first; the API cannot add one.`);
420
+ }
421
+ const { image: _i, ...rest } = s;
422
+ return { ...rest, image_id: im.id };
423
+ });
424
+ }
373
425
  async listImages(raw) {
374
426
  const input = listInput.parse(raw);
375
427
  await this.project(input.project_id);
@@ -387,6 +439,8 @@ export class DeploymentEngine {
387
439
  dockerfile: x.dockerfile,
388
440
  tag: x.tag,
389
441
  build_status: x.build_status,
442
+ source: x.source,
443
+ reference: x.reference,
390
444
  })),
391
445
  total: results.length,
392
446
  };
@@ -512,12 +566,14 @@ export class DeploymentEngine {
512
566
  input.services.length)
513
567
  bad("Service overrides must be unique.");
514
568
  const images = op.project_id ? await this.images(op.project_id) : [];
569
+ if (op.project_id)
570
+ input.services = await this.resolveImages(op.project_id, input.services);
515
571
  for (const override of input.services) {
516
572
  const at = next.findIndex((s) => s.name === override.name);
517
573
  if (at < 0)
518
574
  bad("Resume overrides can only change services already in this deployment.");
519
575
  if (override.image_id &&
520
- !images.some((im) => im.id === override.image_id && im.build_status === "done"))
576
+ !images.some((im) => im.id === override.image_id && DeploymentEngine.usable(im)))
521
577
  bad("Replacement image is not successfully built in this project.");
522
578
  const saved = next[at];
523
579
  next[at] = {
@@ -785,13 +841,15 @@ export class DeploymentEngine {
785
841
  /** Switches on deployment; when the key may not, the operation stops with what to do instead. */
786
842
  async enableDeployment(op, project) {
787
843
  try {
788
- await this.mutate(op, "PATCH", this.root(project), { deployment_enabled: true }, () => {
844
+ await this.mutate(op, "POST", this.root(project) + "/deployment", { enabled: true }, () => {
789
845
  op.status = "preparing";
790
846
  });
791
847
  }
792
848
  catch (err) {
793
- if (err instanceof ToolError && err.status === 403)
794
- throw new ToolError("deployment_disabled", "Deployment is switched off for this project, and the access key may not switch it on. Ask the user to switch on deployment for the project in Constructor, then repeat the same call.", 403, err.apiCode);
849
+ // Only the project owner may switch it on (421, error 40005); older servers answer 403.
850
+ if (err instanceof ToolError &&
851
+ (err.apiCode === 40005 || err.status === 403))
852
+ throw new ToolError("deployment_disabled", "Deployment is switched off for this project, and only the project owner can switch it on. Ask the project owner to switch on deployment for the project in Constructor, then repeat the same call.", err.status, err.apiCode);
795
853
  throw err;
796
854
  }
797
855
  }
@@ -933,8 +991,8 @@ export class DeploymentEngine {
933
991
  bad(`New service ${s.name} requires image_id or build.`);
934
992
  if (s.image_id) {
935
993
  const im = images.find((x) => x.id === s.image_id);
936
- if (!im || im.build_status !== "done")
937
- bad(`Image for ${s.name} is missing or not successfully built in this project.`);
994
+ if (!DeploymentEngine.usable(im))
995
+ bad(`Image for ${s.name} is missing, or not successfully built, in this project.`);
938
996
  }
939
997
  const hw = hardwareFor(s, old);
940
998
  if (!hw || !hardware.some((h) => h.id === hw && !h.removed))
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  /** Where a tool acts: a desk (project + desk), a project only, or a deployment-shaped input whose schema already allows a missing project_id. */
3
3
  export type Scope = "desk" | "project" | "deploy";
4
4
  /** Tool-facing schema: the engine schema plus desk_url, with the IDs it supplies made optional. */
5
- export declare function located(schema: z.ZodObject<any>, scope: Exclude<Scope, "deploy">,
5
+ export declare function located(schema: z.ZodObject<any>, _scope: Exclude<Scope, "deploy">,
6
6
  /** Inside a desk the IDs default to it, so neither a link nor IDs are required. */
7
7
  implied?: boolean): z.ZodObject<{
8
8
  [x: string]: any;
package/dist/location.js CHANGED
@@ -2,7 +2,7 @@ import { ToolError } from "./api.js";
2
2
  import { VERSION } from "./config.js";
3
3
  import { id, deskUrl } from "./schemas.js";
4
4
  /** Tool-facing schema: the engine schema plus desk_url, with the IDs it supplies made optional. */
5
- export function located(schema, scope,
5
+ export function located(schema, _scope,
6
6
  /** Inside a desk the IDs default to it, so neither a link nor IDs are required. */
7
7
  implied = false) {
8
8
  const extended = schema.extend({
@@ -19,12 +19,8 @@ implied = false) {
19
19
  desk_url: deskUrl.optional(),
20
20
  })
21
21
  .refine((x) => !!x.desk_url ||
22
- (!!x.project_id &&
23
- (scope !== "desk" ||
24
- !!x.desk_id ||
25
- schema.shape.desk_id.safeParse(undefined).success)), scope === "desk"
26
- ? "Provide desk_url (the desk link from the browser) or project_id and desk_id."
27
- : "Provide desk_url (the desk link from the browser) or project_id.");
22
+ // Without desk_id the MCP picks the project's only desk, or asks which one.
23
+ !!x.project_id, "Provide desk_url (the desk link from the browser) or project_id.");
28
24
  }
29
25
  function bad(code, message) {
30
26
  throw new ToolError(code, message);
package/dist/schemas.d.ts CHANGED
@@ -18,6 +18,7 @@ export declare const serviceInput: z.ZodObject<{
18
18
  name: z.ZodString;
19
19
  service_id: z.ZodOptional<z.ZodString>;
20
20
  image_id: z.ZodOptional<z.ZodString>;
21
+ image: z.ZodOptional<z.ZodString>;
21
22
  build: z.ZodOptional<z.ZodObject<{
22
23
  desk_id: z.ZodOptional<z.ZodString>;
23
24
  dockerfile: z.ZodOptional<z.ZodString>;
@@ -66,6 +67,7 @@ export declare const deployInput: z.ZodObject<{
66
67
  name: z.ZodString;
67
68
  service_id: z.ZodOptional<z.ZodString>;
68
69
  image_id: z.ZodOptional<z.ZodString>;
70
+ image: z.ZodOptional<z.ZodString>;
69
71
  build: z.ZodOptional<z.ZodObject<{
70
72
  desk_id: z.ZodOptional<z.ZodString>;
71
73
  dockerfile: z.ZodOptional<z.ZodString>;
@@ -120,6 +122,7 @@ export declare const updateInput: z.ZodObject<{
120
122
  name: z.ZodString;
121
123
  service_id: z.ZodOptional<z.ZodString>;
122
124
  image_id: z.ZodOptional<z.ZodString>;
125
+ image: z.ZodOptional<z.ZodString>;
123
126
  build: z.ZodOptional<z.ZodObject<{
124
127
  desk_id: z.ZodOptional<z.ZodString>;
125
128
  dockerfile: z.ZodOptional<z.ZodString>;
package/dist/schemas.js CHANGED
@@ -104,6 +104,12 @@ export const serviceInput = z
104
104
  name: serviceName,
105
105
  service_id: id.optional(),
106
106
  image_id: id.optional(),
107
+ image: z
108
+ .string()
109
+ .min(1)
110
+ .max(512)
111
+ .optional()
112
+ .describe("An image already in the project, by its reference (registry/repo:tag, for an external image) or its name, as list_images shows them. The MCP turns it into image_id. External images are added in Constructor; the API cannot add them."),
107
113
  build: build.optional(),
108
114
  hardware: z
109
115
  .strictObject({
@@ -121,11 +127,11 @@ export const serviceInput = z
121
127
  .describe("Plain strings, or {service, port[, scheme]} to point at another service of the same app; never localhost."),
122
128
  depends_on: z.array(serviceName).optional(),
123
129
  })
124
- .refine((s) => !(s.image_id && s.build), "Choose image_id or build, not both.");
130
+ .refine((s) => [s.image_id, s.image, s.build].filter(Boolean).length <= 1, "Choose one of image_id, image or build.");
125
131
  export const deskUrl = z
126
132
  .string()
127
133
  .max(2048)
128
- .describe("Link to the Constructor desk the user copied from the browser, e.g. https://constructor.app/research/projects/<project>/desks/<desk>/viewer/file. Supplies project_id and desk_id; ask the user for it instead of choosing a project or desk yourself.");
134
+ .describe("Link to the Constructor desk the user copied from the browser, e.g. https://constructor.app/research/projects/<project>/desks/<desk>/viewer/file. Supplies project_id and desk_id. With project_id alone the MCP uses the project's only desk; when the project has several, it asks for this link or desk_id.");
129
135
  const deploymentShape = {
130
136
  project_id: id.optional(),
131
137
  desk_url: deskUrl
package/dist/server.js CHANGED
@@ -40,6 +40,17 @@ async function main() {
40
40
  /** Verify Dockerfiles on their disks before any build; surface lint warnings to the agent. */
41
41
  const checked = (fn, single = false) => async (a) => {
42
42
  const begun = Date.now();
43
+ if (!single && a.project_id && a.services) {
44
+ // External images by reference or name; builds without a desk go to the project's desk.
45
+ let services = await engine.resolveImages(a.project_id, a.services);
46
+ if (services.some((x) => x.build && !x.build.desk_id)) {
47
+ const desk = await engine.deskFor(a.project_id, `${a.application_name ?? "application"}-source`);
48
+ services = services.map((x) => x.build && !x.build.desk_id
49
+ ? { ...x, build: { ...x.build, desk_id: desk } }
50
+ : x);
51
+ }
52
+ a = { ...a, services };
53
+ }
43
54
  if (!single && a.services?.some((x) => x.build?.local_path)) {
44
55
  // Upload local sources first, once per (disk, local folder, disk folder).
45
56
  const done = new Set();
@@ -156,7 +167,7 @@ async function main() {
156
167
  ? text.replace(/Where to act: ask the user for the Constructor desk link.*?if the user has not said where to deploy or where files live, ask\. /, deskInstructions(config.localDesk) + " ")
157
168
  : text;
158
169
  const server = new McpServer({ name: "constructor-research", version: VERSION }, {
159
- instructions: withDesk(`Access: the MCP works with one Constructor and the user's personal access key for it, set up outside the chat. When a tool returns needs_key, pass its instructions on to the user; never ask for the key in the chat. Where to act: ask the user for the Constructor desk link (they open the desk in the browser and copy the address; it contains /projects/<project>/desks/<desk>) and pass it as desk_url. Do not pick a project or desk yourself; if the user has not said where to deploy or where files live, ask. Ask the user only before replacing, renaming or deleting files on a disk, once per request for the whole list (the tools return confirm_required); creating folders and uploading new files need no question. ${RULES} For a local app, pass build.local_path (the folder with the Dockerfile) and deploy_app uploads it first. Hardware: leave it out; the default is used. Set hardware minimums only when the app cannot run without a GPU or a lot of RAM. Use deploy_app/update_app once for the WHOLE application. The MCP builds, resolves service URLs, configures and starts services in the background. IDs are automatic. To wait, call get_deployment(wait_seconds=20) again as often as needed (a loop of such calls is fine); never perform the deployment steps yourself. When the user asks to deploy or build, wait until the deployment is finished before answering, then give the public URL or what failed. On failure, tell the user the failed stage/service; failure.log_tail and get_logs show the last build or service log lines. Do not use browser or debugging tools. For source files: sync_files to the desk before building (the MCP checks each Dockerfile on the disk and reports warnings); after a needs_upload pause, sync and call get_deployment with files_uploaded=true. Started is not readiness.`),
170
+ instructions: withDesk(`Access: the MCP works with one Constructor and the user's personal access key for it, set up outside the chat. When a tool returns needs_key, pass its instructions on to the user; never ask for the key in the chat. Where to act: ask the user for the Constructor desk link (they open the desk in the browser and copy the address; it contains /projects/<project>/desks/<desk>) and pass it as desk_url. Do not pick a project yourself; if the user has not said where to deploy or where files live, ask. Given a project only (project_id), the MCP uses its only desk, or creates one for a deploy when there is none; when the project has several desks it returns desk_choice_required with their names and links: ask the user which one. Ask the user only before replacing, renaming or deleting files on a disk, once per request for the whole list (the tools return confirm_required); creating folders and uploading new files need no question. ${RULES} For a local app, pass build.local_path (the folder with the Dockerfile) and deploy_app uploads it first. To run an image that is already in the project, such as an external image (registry/repo:tag added in Constructor), pass image with its reference or name, or image_id; list_images shows source and reference. Hardware: leave it out; the default is used. Set hardware minimums only when the app cannot run without a GPU or a lot of RAM. Use deploy_app/update_app once for the WHOLE application. The MCP builds, resolves service URLs, configures and starts services in the background. IDs are automatic. To wait, call get_deployment(wait_seconds=20) again as often as needed (a loop of such calls is fine); never perform the deployment steps yourself. When the user asks to deploy or build, wait until the deployment is finished before answering, then give the public URL or what failed. On failure, tell the user the failed stage/service; failure.log_tail and get_logs show the last build or service log lines. Do not use browser or debugging tools. For source files: sync_files to the desk before building (the MCP checks each Dockerfile on the disk and reports warnings); after a needs_upload pause, sync and call get_deployment with files_uploaded=true. Started is not readiness.`),
160
171
  });
161
172
  const register = (name, description, schema, fn, readOnly = false, budget = 20000, scope) => {
162
173
  const here = config.localDesk && DESK_DEFAULT.has(name) ? config.localDesk : undefined;
@@ -174,20 +185,28 @@ async function main() {
174
185
  }, async (args) => {
175
186
  try {
176
187
  await api.refresh();
177
- const result = await api.withBudget(budget, () => fn(scope
178
- ? resolveDeskUrl(
179
- // Inside a desk, a call that names no other desk acts on it.
180
- here &&
181
- !args?.desk_url &&
182
- (!args?.project_id ||
183
- args.project_id === here.projectId) &&
184
- (!args?.desk_id || args.desk_id === here.deskId)
185
- ? {
186
- ...args,
187
- desk_url: `${config.baseUrl}/research/projects/${here.projectId}/desks/${here.deskId}`,
188
- }
189
- : args, config.baseUrl, scope, config.baseUrlFixed)
190
- : args));
188
+ const result = await api.withBudget(budget, async () => {
189
+ const at = scope
190
+ ? resolveDeskUrl(
191
+ // Inside a desk, a call that names no other desk acts on it.
192
+ here &&
193
+ !args?.desk_url &&
194
+ (!args?.project_id || args.project_id === here.projectId) &&
195
+ (!args?.desk_id || args.desk_id === here.deskId)
196
+ ? {
197
+ ...args,
198
+ desk_url: `${config.baseUrl}/research/projects/${here.projectId}/desks/${here.deskId}`,
199
+ }
200
+ : args, config.baseUrl, scope, config.baseUrlFixed)
201
+ : args;
202
+ // A desk tool given only the project acts on its only desk, or asks which one.
203
+ if (scope === "desk" &&
204
+ name !== "list_images" &&
205
+ at?.project_id &&
206
+ !at.desk_id)
207
+ at.desk_id = await engine.deskFor(at.project_id);
208
+ return fn(at);
209
+ });
191
210
  return {
192
211
  content: [
193
212
  {
@@ -216,6 +235,7 @@ async function main() {
216
235
  message: err.message,
217
236
  http_status: err.status,
218
237
  api_error_code: err.apiCode,
238
+ ...err.details,
219
239
  }
220
240
  : {
221
241
  status: "internal_error",
@@ -6,7 +6,7 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "npx -y -p constructor-research-mcp@beta constructor-research-wait --hook claude-code",
9
+ "command": "npx -y -p constructor-research-mcp@latest constructor-research-wait --hook claude-code",
10
10
  "asyncRewake": true
11
11
  }
12
12
  ]
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "constructor-research": {
4
4
  "command": "npx",
5
- "args": ["-y", "constructor-research-mcp@beta"]
5
+ "args": ["-y", "constructor-research-mcp@latest"]
6
6
  }
7
7
  }
8
8
  }
@@ -5,7 +5,7 @@
5
5
  "hooks": [
6
6
  {
7
7
  "type": "command",
8
- "command": "npx -y -p constructor-research-mcp@beta constructor-research-wait --hook codex",
8
+ "command": "npx -y -p constructor-research-mcp@latest constructor-research-wait --hook codex",
9
9
  "timeout": 600,
10
10
  "statusMessage": "Waiting for Constructor deployments"
11
11
  }
@@ -1,6 +1,6 @@
1
1
  [mcp_servers.constructor-research]
2
2
  command = "npx"
3
- args = ["-y", "constructor-research-mcp@beta"]
3
+ args = ["-y", "constructor-research-mcp@latest"]
4
4
  # The first start downloads the package.
5
5
  startup_timeout_sec = 60
6
6
  tool_timeout_sec = 30
@@ -5,7 +5,7 @@ import { spawn } from "node:child_process";
5
5
  const WAIT = [
6
6
  "-y",
7
7
  "-p",
8
- "constructor-research-mcp@beta",
8
+ "constructor-research-mcp@latest",
9
9
  "constructor-research-wait",
10
10
  ];
11
11
  // Any CONSTRUCTOR_* settings your MCP entry sets besides the defaults.
@@ -4,7 +4,7 @@
4
4
  "servers": {
5
5
  "constructor-research": {
6
6
  "type": "local",
7
- "command": ["npx", "-y", "constructor-research-mcp@beta"]
7
+ "command": ["npx", "-y", "constructor-research-mcp@latest"]
8
8
  }
9
9
  }
10
10
  }
@@ -3,7 +3,7 @@
3
3
  "mcp": {
4
4
  "constructor-research": {
5
5
  "type": "local",
6
- "command": ["npx", "-y", "constructor-research-mcp@beta"]
6
+ "command": ["npx", "-y", "constructor-research-mcp@latest"]
7
7
  }
8
8
  }
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "constructor-research-mcp",
3
- "version": "0.4.0-beta.3",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Local deployment MCP for Constructor Research",
6
6
  "license": "MIT",
@@ -56,8 +56,5 @@
56
56
  "prettier": "3.9.10",
57
57
  "tsx": "4.23.15",
58
58
  "typescript": "7.0.2"
59
- },
60
- "publishConfig": {
61
- "tag": "beta"
62
59
  }
63
60
  }